add common wsl step in config.sh
This commit is contained in:
parent
3148f40c81
commit
2bca3f5354
51
config.sh
51
config.sh
@ -776,6 +776,57 @@ EOF
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# WSL
|
# WSL
|
||||||
|
function common_wsl_steps() {
|
||||||
|
echo 'LC_MESSAGES=en_US.UTF-8' >> /etc/locale.conf
|
||||||
|
cat > /etc/wsl-distribution.conf << EOF
|
||||||
|
[oobe]
|
||||||
|
# Command run the first time the user opens an interactive shell.
|
||||||
|
# If the command returns non-zero, it is considered unsuccessful and the
|
||||||
|
# user won't be able to open a shell.
|
||||||
|
command = /usr/libexec/wsl/oobe.sh
|
||||||
|
# Default UID for user the distribution starts with.
|
||||||
|
defaultUid = 1000
|
||||||
|
# Default name the distribution is registered under.
|
||||||
|
# This is used when the user double-clicks to install, or uses
|
||||||
|
# wsl --install --from-file ./Fedora.wsl
|
||||||
|
defaultName = Rocky
|
||||||
|
|
||||||
|
#[shortcut]
|
||||||
|
# Must be .ico format and smaller than 10MB.
|
||||||
|
#icon = /usr/lib/wsl/my-icon.ico
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p /usr/libexec/wsl/
|
||||||
|
cat > /usr/libexec/wsl/oobe.sh << EOF
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ue
|
||||||
|
|
||||||
|
echo 'Please create a default UNIX user account. The username does not need to match your Windows username.'
|
||||||
|
echo 'For more information visit: https://aka.ms/wslusers'
|
||||||
|
|
||||||
|
if getent passwd 1000 > /dev/null ; then
|
||||||
|
echo 'User account already exists, skipping creation'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prompt from the username
|
||||||
|
read -p 'Enter new UNIX username: ' username
|
||||||
|
|
||||||
|
# Create the user
|
||||||
|
/usr/sbin/useradd -m -G wheel --uid 1000 "\$username"
|
||||||
|
|
||||||
|
cat > /etc/sudoers.d/wsluser << EOSUDOER
|
||||||
|
## Ensure the WSL initial user can use sudo
|
||||||
|
\$username ALL=(ALL) NOPASSWD: ALL
|
||||||
|
EOSUDOER
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/libexec/wsl/oobe.sh
|
||||||
|
cat > /etc/wsl.conf << EOF
|
||||||
|
[boot]
|
||||||
|
systemd=true
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user