diff --git a/.github/workflows/wsl-test.yml b/.github/workflows/wsl-test.yml new file mode 100644 index 0000000..e7c1ccc --- /dev/null +++ b/.github/workflows/wsl-test.yml @@ -0,0 +1,22 @@ +name: WSL Install + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Fedora + run: | + .\setup.ps1 -UserName GitHub + wsl --distribution Fedora --user GitHub --exec /bin/bash -c "echo 'Hello from Fedora'" diff --git a/setup.ps1 b/setup.ps1 index c71416d..4f48ea1 100644 --- a/setup.ps1 +++ b/setup.ps1 @@ -29,9 +29,10 @@ if (!(Test-Path "$InstallDirectory\$DistroName")) { wsl --import "$DistroName" "$InstallDirectory\$DistroName" "$scriptDir\Fedora${Version}.tar.gz" $nixPath = wsl -e wslpath "$scriptDir" +$language = $(Get-WinSystemLocale).Name.Split('-')[0] # Launch to configure -wsl -d "$DistroName" "$nixPath/setup.sh" $UserName +wsl -d "$DistroName" "$nixPath/setup.sh" -u "'$UserName'" -l "'$language'" # Set default user as first non-root user Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq "$DistroName" | Set-ItemProperty -Name DefaultUid -Value 1000 diff --git a/setup.sh b/setup.sh index b37316c..7379b2f 100644 --- a/setup.sh +++ b/setup.sh @@ -1,6 +1,12 @@ #!/usr/bin/env sh -username=$1 +while getopts u:p:l: flag +do + case "${flag}" in + u) username=${OPTARG};; + l) language=${OPTARG};; + esac +done if [ -z "$username" ]; then echo "Please enter a new user name: " @@ -9,3 +15,7 @@ fi useradd -m -G adm,wheel,dialout,cdrom,floppy,audio,video $username passwd $username + +if [ -n "$language" ]; then + sudo dnf install -y "glibc-langpack-$language" +fi \ No newline at end of file