|
#cloud-config |
|
|
|
# Installation Information |
|
|
|
# https://gist.github.com/mmitchel/4ca91fe57c21189476b9af4ae2a60893 |
|
|
|
### USER DEFINED ########################################### |
|
|
|
# apt: |
|
# http_proxy: 'http://windows_user:[email protected]:8080/' |
|
|
|
### INSTANCE SPECIFIC ###################################### |
|
|
|
locale: en_US.UTF-8 |
|
|
|
users: |
|
|
|
- name: user |
|
gecos: WSL Instance |
|
plain_text_passwd: password |
|
groups: [adm,dialout,disk,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev] |
|
shell: /bin/bash |
|
homedir: /home/user |
|
sudo: ['ALL=(ALL) NOPASSWD: ALL'] |
|
|
|
write_files: |
|
|
|
# Overwrite the original |
|
- path: /etc/wsl.conf |
|
owner: 'root:root' |
|
permissions: '0644' |
|
defer: false |
|
append: false |
|
content: | |
|
[boot] |
|
systemd=true |
|
[user] |
|
default=user |
|
[automount] |
|
enabled=true |
|
mountFsTab=true |
|
options="case=off,fmask=0077,dmask=0077" |
|
[network] |
|
hostname=wsl |
|
[interop] |
|
enabled=true |
|
appendWindowsPath=true |
|
[time] |
|
useWindowsTimezone=true |
|
|
|
# Overwrite the original |
|
- path: /etc/wsl-distribution.conf |
|
owner: 'root:root' |
|
permissions: '0644' |
|
defer: false |
|
append: false |
|
content: | |
|
[oobe] |
|
command = /usr/lib/wsl/wsl-setup |
|
defaultUid = 1000 |
|
defaultName = Ubuntu-24.04 |
|
[shortcut] |
|
icon = /usr/share/wsl/ubuntu.ico |
|
[windowsterminal] |
|
ProfileTemplate = /usr/share/wsl/terminal-profile.json |
|
|
|
# Overwrite the original |
|
- path: /usr/lib/wsl/wsl-setup |
|
owner: 'root:root' |
|
permissions: '0755' |
|
defer: false |
|
append: false |
|
content: | |
|
#!/bin/bash |
|
set -euo pipefail |
|
|
|
echo "Provisioning the new WSL instance $WSL_DISTRO_NAME" |
|
echo "This might take a while..." |
|
|
|
# Wait for cloud-init to finish if systemd and its service is enabled |
|
# by running the script located at the same dir as this one. |
|
this_dir=$(dirname "$(realpath $0)") |
|
source "${this_dir}/wait-for-cloud-init" |
|
|
|
echo "Terminate this WSL instance by exiting. Upon termination, set" |
|
echo "required environment variables by executing the following:" |
|
echo " setx.exe GNUPGHOME %USERPROFILE%\.gnupg" |
|
echo " setx.exe WSLENV USERNAME:USERPROFILE/p" |
|
echo "Finally, terminate all Windows Terminal instances. Allow WSL" |
|
echo "about 60 seconds to terminate. Start a new Windows Terminal" |
|
echo "and open an Ubuntu-24.04 instance." |
|
|
|
- path: /etc/profile.d/wsl-instance.sh |
|
owner: 'root:root' |
|
permissions: '0644' |
|
content: | |
|
# WSL Instance |
|
export XDG_RUNTIME_DIR=/run/user/$(id -u) |
|
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock |
|
if [ "$USER" != "root" ] ; then |
|
if [ -n "$USERPROFILE" ] ; then |
|
if [ -d "$USERPROFILE" ] ; then |
|
mkdir -p "$USERPROFILE/.config" && ln -sf "$USERPROFILE/.config" $HOME/.config && rm -f $HOME/.config/.config |
|
mkdir -p "$USERPROFILE/.gnupg" && ln -sf "$USERPROFILE/.gnupg" $HOME/.gnupg && rm -f $HOME/.gnupg/.gnupg |
|
mkdir -p "$USERPROFILE/.local/bin" |
|
export PATH="$USERPROFILE/.local/bin:$PATH" |
|
[[ -d $HOME/.ssh && ! -h $HOME/.ssh ]] && mv -f $HOME/.ssh $HOME/.ssh.old |
|
mkdir -p "$USERPROFILE/.ssh" && ln -sf "$USERPROFILE/.ssh" $HOME/.ssh && rm -f $HOME/.ssh/.ssh |
|
touch "$USERPROFILE/.netrc" && ln -sf "$USERPROFILE/.netrc" $HOME/.netrc |
|
touch "$USERPROFILE/.s3cfg" && ln -sf "$USERPROFILE/.s3cfg" $HOME/.s3cfg |
|
rm -fr $HOME/.config/systemd/user |
|
rm -fr $HOME/.config/systemd/user.control |
|
fi |
|
fi |
|
fi |
|
|
|
- path: /etc/sysctl.d/wsl-instance.conf |
|
owner: 'root:root' |
|
permissions: '0644' |
|
content: | |
|
fs.inotify.max_user_watches = 524288 |
|
|
|
- path: /etc/smbcredentials |
|
owner: 'root:root' |
|
permissions: '0600' |
|
content: | |
|
username=windows_user |
|
password=windows_password |
|
|
|
mounts: |
|
- ["# C:","/mnt/c","drvfs","defaults,nosuid,nodev,x-mount.mkdir","0","0"] |
|
- ["# M:","/mnt/m","drvfs","defaults,nosuid,nodev,x-mount.mkdir","0","0"] |
|
- ["# /src/path","/mnt/bind","none","bind,defaults,x-mount.mkdir","0","0"] |
|
- ["# //10.236.1.99/share","/mnt/share","cifs","credentials=/etc/smbcredentials,nosuid,nodev,x-mount.mkdir","0","0" ] |
|
|
|
package_reboot_if_required: true |
|
package_update: true |
|
package_upgrade: true |
|
|
|
packages: |
|
|
|
# Development |
|
- build-essential |
|
- chrpath |
|
- cpio |
|
- debianutils |
|
- diffstat |
|
- file |
|
- gawk |
|
- gcc |
|
- git |
|
- git-lfs |
|
- iputils-ping |
|
- libacl1 |
|
- liblz4-tool |
|
- locales |
|
- python3 |
|
- python3-git |
|
- python3-jinja2 |
|
- python3-pexpect |
|
- python3-pip |
|
- python3-subunit |
|
- socat |
|
- texinfo |
|
- unzip |
|
- wget |
|
- xz-utils |
|
- zstd |
|
|
|
# General |
|
# - wslu |
|
- curl |
|
- gnupg2 |
|
- htop |
|
- jq |
|
- pciutils |
|
- usbutils |
|
- python3-paho-mqtt |
|
- python3-serial |
|
- python3-serial-asyncio |
|
- python3-paramiko |
|
- python3-venv |
|
- uidmap |
|
- libxml2-utils |
|
|
|
# Disk and Filesystem |
|
- repo |
|
- rsync |
|
- s3cmd |
|
- dosfstools |
|
- e2fsprogs |
|
- btrfs-progs |
|
- cryptsetup |
|
- ostree |
|
- cifs-utils |
|
- parted |
|
|
|
runcmd: |
|
|
|
- | |
|
mkdir -p /srv/repo |
|
chmod 1777 /srv/repo |
|
touch /root/.hushlogin |
|
|
|
- | |
|
rsync -av /etc/skel/ /home/user/ |
|
touch /home/user/.hushlogin |
|
chown -R user:user /home/user |
|
|
|
- | |
|
shutdown --poweroff now |