Skip to content

Commit

Permalink
feat: wsl_boot
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonos committed Oct 13, 2023
1 parent a40f552 commit 20cf1ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .assets/provision/autoexec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
# :script executed on WSL startup via [boot] command defined in wsl.conf
10 changes: 8 additions & 2 deletions wsl/wsl_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,15 @@ process {
'[ -d $HOME/miniconda3 ] && python="true" || python="false";',
'[ -f $HOME/.ssh/id_ed25519 ] && ssh_key="true" || ssh_key="false";',
'[ -d /mnt/wslg ] && wslg="true" || wslg="false";',
'[ -x /etc/autoexec.sh ] && wsl_boot="true" || wsl_boot="false";',
'git_user_name="$(git config --global --get user.name 2>/dev/null)";',
'[ -n "$git_user_name" ] && git_user="true" || git_user="false";',
'git_user_email="$(git config --global --get user.email 2>/dev/null)";',
'[ -n "$git_user_email" ] && git_email="true" || git_email="false";',
'grep -qw "systemd.*true" /etc/wsl.conf 2>/dev/null && systemd="true" || systemd="false";',
'grep -Fqw "dark" /etc/profile.d/gtk_theme.sh 2>/dev/null && gtkd="true" || gtkd="false";',
'printf "{\"user\":\"$(id -un)\",\"shell\":$shell,\"k8s_base\":$k8s_base,\"k8s_ext\":$k8s_ext,',
'\"omp\":$omp,\"az\":$az,\"wslg\":$wslg,\"python\":$python,\"systemd\":$systemd,\"gtkd\":$gtkd,',
'printf "{\"user\":\"$(id -un)\",\"shell\":$shell,\"k8s_base\":$k8s_base,\"k8s_ext\":$k8s_ext,\"omp\":$omp,',
'\"az\":$az,\"wslg\":$wslg,\"wsl_boot\":$wsl_boot,\"python\":$python,\"systemd\":$systemd,\"gtkd\":$gtkd,',
'\"pwsh\":$pwsh,\"zsh\":$zsh,\"git_user\":$git_user,\"git_email\":$git_email,\"ssh_key\":$ssh_key}"'
)
# check existing distro setup
Expand Down Expand Up @@ -287,6 +288,11 @@ process {
Write-Warning 'SSL certificate problem: self-signed certificate in certificate chain. Script execution halted.'
exit
}
# *boot setup
if (-not $chk.wsl_boot) {
wsl.exe --distribution $Distro --user root install -m 0755 .assets/provision/autoexec.sh /etc
Set-WslConf -Distro $Distro -ConfDict ([ordered]@{ boot = @{ command = '"[ -x /etc/autoexec.sh ] && /etc/autoexec.sh || true"' } })
}
switch ($scopes) {
distrobox {
Write-Host 'installing distrobox...' -ForegroundColor Cyan
Expand Down

0 comments on commit 20cf1ff

Please sign in to comment.