-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.ps1
94 lines (73 loc) · 3.62 KB
/
update.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(600,400)
$Form.Text='Update miiShop'
$Form.FormBorderStyle = 'Fixed3D'
$Form.MaximizeBox = $false
$miiShopRoot=(get-item $PSScriptRoot).Parent.FullName
$icoPath=(Resolve-Path ('{0}\images\favicon.ico' -f $miiShopRoot)).Path
$Form.Icon = $icoPath
$dateFormat = 'M-d-y-hh_mm_ss'
$date=(get-date).ToString($dateFormat)
$outputLog = "$miiShopRoot\logs\update_$date.log"
############################################## Start functions
function Write-OutLog
{
param($message)
if($outputBox.text -eq '')
{
#output to text box (empty)
$outputMessage = ('{0} - {1}' -f $(get-date -Format 'yyyy-MM-dd HH:mm:ss') ,$message)
$outputBox.text=$outputMessage
#output to log file
$message | out-file -FilePath $outputLog -Append
#refresh form
$Form.Refresh()
}
else
{
#output to text box (1 row or more already in box)
$priorText=$outputBox.text+"`r`n"
$outputMessage = ('{0}{1} - {2}' -f $priorText,$(get-date -Format 'yyyy-MM-dd HH:mm:ss'),$message)
$outputBox.Text=$outputMessage
#output to log file
$message | out-file -FilePath $outputLog -Append
#refresh form
$Form.Refresh()
}
}
function Start-Update
{
Set-Location $PSScriptRoot
Write-OutLog -message 'Downloading the most current miiShop core files'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/bin/makeMain.ps1" -OutFile '.\makeMain.ps1'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/bin/nginxSetup.ps1" -OutFile '.\nginxSetup.ps1'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/bin/settings.ps1" -OutFile '.\settings.ps1'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/bin/startmiiShop.ps1" -OutFile '.\startmiiShop.ps1'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/miiShop.ps1" -OutFile '..\miiShop.ps1'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/start.bat" -OutFile '..\start.bat'
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Engarak/MiiShop/master/main.mnu" -OutFile '..\main.mnu'
Write-OutLog -message 'Downloading completed. Please close out all miiShop windows and re-launch it.'
}
############################################## end functions
############################################## Start text fields
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Location = New-Object System.Drawing.Size(10,10)
$outputBox.Size = New-Object System.Drawing.Size(565,300)
$outputBox.MultiLine = $True
$outputBox.ScrollBars = "Vertical"
$outputBox.ReadOnly = $True
$Form.Controls.Add($outputBox)
############################################## end text fields
############################################## Start buttons
$btnClose = New-Object System.Windows.Forms.Button
$btnClose.Location = New-Object System.Drawing.Size(230,320)
$btnClose.Size = New-Object System.Drawing.Size(110,30)
$btnClose.Text = "&Close"
$btnClose.Add_Click({$Form.close()})
$Form.Controls.AddRange(@($btnClose))
############################################## end buttons
$Form.Add_load({Start-Update})
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()