Skip to content

Commit

Permalink
Determine windows locale for installing in fedora (#7)
Browse files Browse the repository at this point in the history
* Determine windows locale for installing in fedora
* Add workflow to validate scripts
* Use getopts
  • Loading branch information
scaryrawr authored Dec 12, 2024
1 parent eb45858 commit 13e01ad
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/wsl-test.yml
Original file line number Diff line number Diff line change
@@ -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'"
3 changes: 2 additions & 1 deletion setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -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: "
Expand All @@ -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

0 comments on commit 13e01ad

Please sign in to comment.