From 7dbd28039c23a3d30162a329afe5187d54094261 Mon Sep 17 00:00:00 2001 From: Minhyeok Park Date: Mon, 20 Jan 2025 20:21:09 +0900 Subject: [PATCH] refactor: update init.ps1 to remove unnecessary software installations, change download sources, and improve service management commands --- init-next.ps1 | 15 +++++++++++++ init-nowsl.ps1 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ init.ps1 | 47 ++++++----------------------------------- 3 files changed, 78 insertions(+), 41 deletions(-) create mode 100644 init-next.ps1 create mode 100644 init-nowsl.ps1 diff --git a/init-next.ps1 b/init-next.ps1 new file mode 100644 index 0000000..6ba2dc1 --- /dev/null +++ b/init-next.ps1 @@ -0,0 +1,15 @@ +wsl --import Arch ./Arch ./Arch/rootfs.tar.gz +wsl pacman-keyring --init +wsl pacman-keyring --populate +wsl pacman -Sy archlinux-keyring +wsl pacman -Syu git zsh base base-devel + +wsl useradd -m -G wheel -s /bin/zsh pmh +wsl sh -c "echo '%wheel ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/wheel" +wsl sh -c "echo pmh:password | chpasswd" +wsl sh -c "printf '[user]\ndefault=pmh' >> /etc/wsl.conf" + +wsl --shutdown +wsl git clone https://aur.archlinux.org/yay.git ~/yay +wsl sh -c "cd ~/yay && makepkg -si --noconfirm" +wsl yay -Syu curl wget vim terraform eksctl kubectl helm jq aws-cli-v2 diff --git a/init-nowsl.ps1 b/init-nowsl.ps1 new file mode 100644 index 0000000..d2fb126 --- /dev/null +++ b/init-nowsl.ps1 @@ -0,0 +1,57 @@ +Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser +Start-Process powershell -Verb runAs "Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0" + +winget install ` + --disable-interactivity ` + --accept-source-agreements ` + --force ` + ` + Microsoft.WindowsTerminal ` + Microsoft.VisualStudioCode ` + Hashicorp.Terraform ` + Amazon.AWSCLI ` + Kubernetes.kubectl ` + Helm.Helm ` + Derailed.k9s ` + eksctl.eksctl ` + vim.vim ` + Git.Git ` + ahmetb.kubectx ` + ahmetb.kubens ` + Zen-Team.Zen-Browser ` + DEVCOM.JetBrainsMonoNerdFont + +New-Item -Path $profile -ItemType "file" -Force + +@' +Set-Alias -Name kubectl -Value kubecolor +Set-Alias -Name k -Value kubectl + +Set-Alias -Name kubectl -Value kubecolor +Set-Alias -Name k -Value kubectl + +function ka { k apply -f $args } +function kg { k get -f $args } +function kd { k describe -f $args } +function kx { k delete -f $args } + +function ti { terraform init $args } +function ta { terraform apply $args } +function taa { terraform apply --auto-approve $args } + +$env:EDITOR = "code -w" +$env:PATH = "$env:PATH;C:\Program Files\Vim\vim91;" +'@ | ` +Out-File -FilePath $profile + +Set-Location ~/Desktop + +$ProgressPreference = 'SilentlyContinue' +Invoke-WebRequest -useb https://releases.pmh.codes/cocktail.tar -OutFile cocktail.tar +Invoke-WebRequest -useb https://releases.pmh.codes/koishi.zip -OutFile koishi.zip + +tar -xvf cocktail.tar +Expand-Archive koishi.zip + +Start-Process powershell -Verb runAs "Set-Service ssh-agent -StartupType Automatic" +Start-Process powershell -Verb runAs "Start-Service ssh-agent" diff --git a/init.ps1 b/init.ps1 index 8b74d9c..38b6f02 100644 --- a/init.ps1 +++ b/init.ps1 @@ -9,53 +9,18 @@ winget install ` --force ` ` Microsoft.WindowsTerminal ` - Mozilla.Firefox ` Microsoft.VisualStudioCode ` - Hashicorp.Terraform ` - Amazon.AWSCLI ` - Kubernetes.kubectl ` - Helm.Helm ` - Derailed.k9s ` - eksctl.eksctl ` - vim.vim ` - Git.Git ` - ahmetb.kubectx ` - ahmetb.kubens ` - Docker.DockerDesktop ` Zen-Team.Zen-Browser ` DEVCOM.JetBrainsMonoNerdFont -New-Item -Path $profile -ItemType "file" -Force - -@' -Set-Alias -Name kubectl -Value kubecolor -Set-Alias -Name k -Value kubectl - -Set-Alias -Name kubectl -Value kubecolor -Set-Alias -Name k -Value kubectl - -function ka { k apply -f $args } -function kg { k get -f $args } -function kd { k describe -f $args } -function kx { k delete -f $args } - -function ti { terraform init $args } -function ta { terraform apply $args } -function taa { terraform apply --auto-approve $args } - -$env:EDITOR = "code -w" -$env:PATH = "$env:PATH;C:\Program Files\Vim\vim91;" -'@ | ` -Out-File -FilePath $profile - -Set-Location ~/Desktop - $ProgressPreference = 'SilentlyContinue' -Invoke-WebRequest -useb https://releases.pmh.codes/cocktail.tar -OutFile cocktail.tar +Invoke-WebRequest -useb https://github.com/yuk7/ArchWSL/releases/latest/download/Arch.zip -OutFile Arch.zip Invoke-WebRequest -useb https://releases.pmh.codes/koishi.zip -OutFile koishi.zip -tar -xvf cocktail.tar +Expand-Archive Arch.zip Expand-Archive koishi.zip -Set-Service ssh-agent -StartupType Automatic -Start-Service ssh-agent +Start-Process powershell -Verb runAs "Set-Service ssh-agent -StartupType Automatic" +Start-Process powershell -Verb runAs "Start-Service ssh-agent" + +Write-Output "After reboot, please run init-next.ps1"