-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.ps1
115 lines (90 loc) · 3.73 KB
/
setup.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# setup.ps1
# Script to backup, update, and copy over all files from CSGOConfigs
# bf2c952cec1100d5cbe11f32735a14e4f6956bf47a61e0bac036b64ae86ff011 setup.ps1
function Write-ProgressHelper {
param (
[int]$StepNumber,
[string]$Message
)
Write-Progress -Activity 'CSGOConfigs' -Status $Message -PercentComplete (($StepNumber / $steps) * 100)
}
function DownloadGitHubRepository {
param(
[Parameter(Mandatory=$True)]
[string] $Name,
[Parameter(Mandatory=$True)]
[string] $Author,
[Parameter(Mandatory=$False)]
[string] $Branch = "master",
[Parameter(Mandatory=$False)]
[string] $Location = "c:\temp"
)
$ZipFile = "$location\$Name.zip"
New-Item $ZipFile -ItemType File -Force
$RepositoryZipUrl = "https://api.github.com/repos/$Author/$Name/zipball/$Branch"
Invoke-RestMethod -Uri $RepositoryZipUrl -OutFile $ZipFile
Expand-Archive -Path $ZipFile -DestinationPath $Location -Force
Remove-Item -Path $ZipFile -Force
}
$configs = @(
'autoexec.cfg'
'watchdemo.cfg'
'crosshairs.cfg'
'buybinds.cfg'
)
$skipUpdate = 1
$script:steps = (($configs.Count * 2) + 4)
$stepCounter = 0
$userdata = "${env:ProgramFiles(x86)}\Steam\userdata\"
$cfgdir = "\730\local\cfg"
$date = Get-Date
$dateStr = Get-Date $date -Format "yyyMMdd"
$ids = @(Get-ChildItem "${env:ProgramFiles(x86)}\Steam\userdata\" | Out-GridView -Title 'Choose a steam id' -PassThru)
$x=$userdata+$ids+$cfgdir
Write-Host 'Selected'$x
$title = 'Install'
$question = 'Are you sure you want to proceed?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 0)
if ($decision -eq 0) {
Write-Host ':)'
} else {
Write-Host 'Exiting...'
exit
}
if (!$skipUpdate) {
$title = 'Update'
$question = 'Would you like to download updates?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 0) {
DownloadGitHubRepository -Name CSGOConfigs -Author gitdek -Location $PSScriptRoot
}
}
Write-Host "Backing up files..."
foreach ($k in $configs) {
Rename-Item -Path $x\$k -NewName $x\$k.$dateStr.backup -ErrorAction Ignore
Write-ProgressHelper -Message "Backing up $k..." -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
}
Copy-Item $x\video.txt -Destination $x\video.txt.$dateStr.backup -ErrorAction Ignore
Write-ProgressHelper -Message 'Backing up files...' -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
Copy-Item $x\config.cfg -Destination $x\config.cfg.$dateStr.backup -ErrorAction Ignore
Write-ProgressHelper -Message 'Backing up files...' -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
Rename-Item -Path "${env:ProgramFiles(x86)}\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\resource\ui\RadioPanel.txt" -NewName "${env:ProgramFiles(x86)}\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\resource\ui\RadioPanel.txt.$dateStr.backup" -ErrorAction Ignore
Write-ProgressHelper -Message 'Backing up files...' -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
Write-Host "Copying over files..."
foreach ($c in $configs) {
Copy-Item "$PSScriptRoot\$c" -Destination "$x\$c" -ErrorAction Ignore
Write-ProgressHelper -Message "Copying $PSScriptRoot\$c to $x\$c ..." -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
}
Copy-Item $PSScriptRoot\RadioPanel.txt -Destination "${env:ProgramFiles(x86)}\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\resource\ui\RadioPanel.txt" -ErrorAction Ignore
Write-ProgressHelper -Message 'Backing up files...' -StepNumber ($stepCounter++)
Start-Sleep -Seconds 1
$lo = (Get-Content .\autoexec.cfg)[2] -split "(:)" # Parse from autoexec the launch options
Write-Host 'Complete! Please make sure your launch options to:'
Write-Host $lo[2].trim()