-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.ps1
116 lines (80 loc) · 2.47 KB
/
bootstrap.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
116
#Set-ExecutionPolicy Unrestricted
Clear-Host
# Load scripts
Push-Location "$PSScriptRoot\src"
. ".\bootstrap-functions.ps1"
. ".\helpers.ps1"
. ".\programs.ps1"
Pop-Location
Push-Location "$PSScriptRoot\src\lib"
Get-ChildItem -Filter *.ps1 | ForEach-Object { . $_.FullName }
Pop-Location
Push-Location "$PSScriptRoot\src\modules"
Get-ChildItem | ForEach-Object { . $_.FullName }
Pop-Location
Import-Module "$PSScriptRoot\src\lib\PSYaml"
if (!(Is-Admin)) {
Write-Host "RunAs Administrator..."
Exit
}
Write-Title "Configure You Windows" $false
Write-Host "Because registry editing is so much fun"
Write-Host "Boxstarter Url: https://gist.github.com/Laoujin/12f5d2f76d51ee6c0a49"
Push-Location "$PSScriptRoot\config\"
# Turn features on/off
$globalConfig = ConvertFrom-JsonFile "$PSScriptRoot\modules.json"
# Start bootstrapping
Write-Title "BOOTSTRAP"
Get-Childitem "$PSScriptRoot\bootstrap" -Filter *.yml -Recurse | Foreach-Object {
Write-Title $_.BaseName.ToUpper()
$_.FullName
$conf = ConvertFrom-Yaml -Path $_.FullName
Process-Modules $conf $true
}
Write-Title "PROGRAMS"
if ($globalConfig."Process-Programs") {
$chocoNames = Get-Content "$PSScriptRoot\config\chocolatey.txt"
Process-Programs $chocoNames
} else {
Write-Host "Skipping programs per config" -ForegroundColor Red
}
# TODO: Check DSC instead of this ...
Pop-Location
return
# Read configuration
$config = ConvertFrom-JsonFile "$PSScriptRoot\bootstrap.json"
# Content of file:
# {
# "windows":
# {
# "explorer":
# {
# "registry":
# {
# "showThisPCFolders": "hide",
# "showOneDrive": "hide",
# "showHiddenFilesFoldersDrives": "show",
# "showFileExtensions": "show",
# "showProtectedOSFiles": "show",
# "showFullPathInTitleBar": "show",
# "showNetworkIconInNavigationPane": "hide",
# "showLibrariesInWindowsExplorer": "show",
# "enableAeroWindowsShake": "disabled"
# }
# }
# }
# }
Write-Title "WINDOWS EXPLORER"
$windowsConfig = ConvertFrom-JsonFile "$PSScriptRoot\src\windows.json"
$explorerOptions = Get-JsonObjectKeys $config.windows.explorer.registry
foreach ($explorerOption in $explorerOptions) {
$explorerConfig = $windowsConfig.explorer.registry.$explorerOption
$explorerValue = $config.windows.explorer.registry.$explorerOption
if (-not $explorerConfig) {
Write-Error "No configuration found for $explorerOption"
} else {
$explorerConfig | Add-Member "value" $explorerValue
Update-RegistryKey $explorerConfig | Write-Background
}
}
Pop-Location