Refactor chocolatey script
This commit is contained in:
parent
7770ef04a1
commit
754dc5483c
2 changed files with 16 additions and 13 deletions
|
@ -184,6 +184,7 @@ $null = New-Module {
|
||||||
# Essentials
|
# Essentials
|
||||||
. "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
. "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
||||||
. "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
. "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
||||||
|
. "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Collection "common") {
|
if (Test-Collection "common") {
|
||||||
|
|
|
@ -6,6 +6,7 @@ param(
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Software/PowerShell/Profile.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
|
@ -16,24 +17,25 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
& $Installer -Action ([InstallerAction]::Configure)
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
|
[string] $backup = $null;
|
||||||
$nativeProfile = powershell -c '$PROFILE';
|
$nativeProfile = powershell -c '$PROFILE';
|
||||||
|
|
||||||
|
if (Test-Path -PathType Leaf $nativeProfile) {
|
||||||
|
$backup = "${nativeProfile}_";
|
||||||
|
Move-Item $nativeProfile $backup;
|
||||||
|
}
|
||||||
|
|
||||||
$null = New-Item -Force $nativeProfile;
|
$null = New-Item -Force $nativeProfile;
|
||||||
choco install -y --force chocolatey;
|
choco install -y --force chocolatey;
|
||||||
Copy-Item -Force $nativeProfile $PROFILE;
|
|
||||||
|
|
||||||
Push-Location ~;
|
Add-PowerShellProfileStatement `
|
||||||
$files = @($nativeProfile, $PROFILE) | ForEach-Object { Resolve-Path -Relative $_ };
|
-DefaultUser `
|
||||||
Pop-Location;
|
-Category "chocolatey" `
|
||||||
|
-Script (Get-Content $nativeProfile | Out-String) `
|
||||||
|
-Append;
|
||||||
|
|
||||||
foreach ($path in $files) {
|
if ($backup) {
|
||||||
$fullName = "$env:SystemDrive/Users/Default/$path";
|
Move-Item $backup $nativeProfile;
|
||||||
$dirName = Split-Path -Parent $fullName;
|
|
||||||
|
|
||||||
if (-not (Test-Path -PathType Container $dirName)) {
|
|
||||||
$null = New-Item -Force -ItemType Directory $dirName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Copy-Item -Force ~/"$path" $fullName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Import-Module "$env:ChocolateyInstall/helpers/chocolateyProfile.psm1";
|
Import-Module "$env:ChocolateyInstall/helpers/chocolateyProfile.psm1";
|
||||||
|
|
Loading…
Reference in a new issue