-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up some housekeeping to run on every domain start. Only do the minimal still for a usable SEL environment * install additional packages * install the current /etc/selrc * Include work-around for microsoft/WSL#4189 * set hostname to WSL distro name * run /etc/rc.local Signed-off-by: Dean Troyer <[email protected]>
- Loading branch information
1 parent
7ef0597
commit ed92586
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
# bootstrap-sel.sh - Boostrap new SEL (development) | ||
# | ||
# * install minimal packages | ||
# * install /etc/selrc | ||
# | ||
# Run bootstrap-sel.sh without a local repo: | ||
# | ||
# curl https://raw.githubusercontent.com/dtroyer-salad/wsl-ansible/main/bootstrap-sel.sh | bash -s | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
# Keep track of the current script directory. | ||
TOP_DIR=$(cd $(dirname "$0") && pwd) | ||
|
||
# Ensure we have the basics | ||
if [[ -r /etc/os-release ]]; then | ||
source /etc/os-release | ||
ID_LIKE=${ID_LIKE:-$ID} | ||
case "$ID_LIKE" in | ||
debian) | ||
# Debian/Ubuntu | ||
sudo apt-get update | ||
sudo apt-get -y install curl git gpg make screen vim wget | ||
;; | ||
fedora) | ||
# Fedora/RHEL/OEL | ||
sudo dnf -y install curl git gpg make screen vim wget | ||
;; | ||
esac | ||
fi | ||
|
||
BOOT=$(grep -i "\[boot\]" /etc/wsl.conf) | ||
if [[ -z $BOOT ]]; then | ||
# Add boot section to wsl.conf to run rc.local | ||
echo -e "[boot]\ncommand = \"/etc/selrc\n\"" >>/etc/wsl.conf | ||
fi | ||
|
||
# Get current selrc | ||
curl -R https://raw.githubusercontent.com/dtroyer-salad/wsl-ansible/main/selrc -o /etc/selrc | ||
chmod 755 /etc/selrc | ||
|
||
. /etc/selrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh -e | ||
# | ||
# selrc | ||
# | ||
# This iscript is traditionally executed at the end of each multiuser | ||
# runlevel, however in WSL there is no SysVInit or systemd by default. | ||
# This incarnation is launched via /etc/wsl.conf: | ||
# | ||
# [boot] | ||
# command="/etc/selrc" | ||
# | ||
|
||
set -x | ||
|
||
# cgroups work-around | ||
# This is a work-around for https://github.com/microsoft/WSL/issues/4189 | ||
# that is still open as of 2024-04 | ||
mkdir -p /sys/fs/cgroup/systemd | ||
mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd | ||
|
||
# Fixup hosts | ||
if [[ -n $WSL_DISTRO_NAME ]]; then | ||
echo $WSL_DISTRO_NAME >/etc/hostname | ||
hostname -F /etc/hostname | ||
fi | ||
sed -i "s/^\(127.0.1.1[[:space:]]*\).*$/\1 $WSL_DISTRO_NAME.\t$WSL_DISTRO_NAME/" /etc/hosts | ||
|
||
# Run rc.local | ||
if [[ -x /etc/rc.local ]]; then | ||
. /etc/rc.local | ||
fi |