summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-07 01:02:22 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-07 01:02:22 +0100
commit07ba00058350948a8a5e89aa312c6f5b12098d93 (patch)
treed07d8185e2a026f588146cf17e26648fc486222e
parent5f76e13946b91213cae66d423a90a27eda24dc1a (diff)
downloadrvnit-07ba00058350948a8a5e89aa312c6f5b12098d93.tar.gz
rvnit-07ba00058350948a8a5e89aa312c6f5b12098d93.tar.xz
rvnit-07ba00058350948a8a5e89aa312c6f5b12098d93.zip
add contrib
-rw-r--r--contrib/README2
-rwxr-xr-xcontrib/rvnit-init11
-rwxr-xr-xcontrib/rvnit/sv/00Kpoweroff11
-rwxr-xr-xcontrib/rvnit/sv/00Shello2
-rwxr-xr-xcontrib/rvnit/sv/01Spseudofs49
-rwxr-xr-xcontrib/rvnit/sv/02Sstatic-devnodes8
-rwxr-xr-xcontrib/rvnit/sv/03Skmods12
-rwxr-xr-xcontrib/rvnit/sv/04Sudev23
-rwxr-xr-xcontrib/rvnit/sv/05Sconsole-setup30
-rwxr-xr-xcontrib/rvnit/sv/06Sfilesystems79
-rwxr-xr-xcontrib/rvnit/sv/07Sswap9
-rwxr-xr-xcontrib/rvnit/sv/08Smisc30
-rwxr-xr-xcontrib/rvnit/sv/09Ssysctl24
-rwxr-xr-xcontrib/rvnit/sv/20Scleanup11
-rwxr-xr-xcontrib/rvnit/sv/30Dacpid2
-rwxr-xr-xcontrib/rvnit/sv/30Dudevd3
-rwxr-xr-xcontrib/rvnit/sv/40Ddhcpcd2
-rwxr-xr-xcontrib/rvnit/sv/45Snetup14
-rwxr-xr-xcontrib/rvnit/sv/50Dopensshd3
-rwxr-xr-xcontrib/rvnit/sv/90Dagetty-tty33
-rwxr-xr-xcontrib/rvnit/sv/90Dagetty-tty43
-rwxr-xr-xcontrib/rvnit/sv/90Dagetty-tty53
-rwxr-xr-xcontrib/rvnit/sv/90Dagetty-tty63
-rwxr-xr-xcontrib/rvnit/sv/99Dsulogin3
24 files changed, 340 insertions, 0 deletions
diff --git a/contrib/README b/contrib/README
new file mode 100644
index 0000000..09bd6b7
--- /dev/null
+++ b/contrib/README
@@ -0,0 +1,2 @@
+This directory contains totally unsupported scripts
+to boot Void Linux with rvnit.
diff --git a/contrib/rvnit-init b/contrib/rvnit-init
new file mode 100755
index 0000000..34b54b6
--- /dev/null
+++ b/contrib/rvnit-init
@@ -0,0 +1,11 @@
+#!/bin/bash
+PATH=/usr/bin:/usr/sbin
+export PATH
+
+# control tty
+exec </dev/tty1 >/dev/tty1 2>&1
+
+mountpoint -q /tmp || mount /tmp
+
+cd /etc/rvnit
+exec /bin/rvnit
diff --git a/contrib/rvnit/sv/00Kpoweroff b/contrib/rvnit/sv/00Kpoweroff
new file mode 100755
index 0000000..2fae082
--- /dev/null
+++ b/contrib/rvnit/sv/00Kpoweroff
@@ -0,0 +1,11 @@
+#!/bin/sh
+echo system halted.
+sync
+
+sleep 10
+
+if [ -n "$RVNIT_WANT_REBOOT" ]; then
+	reboot -f
+else
+	halt -f
+fi
diff --git a/contrib/rvnit/sv/00Shello b/contrib/rvnit/sv/00Shello
new file mode 100755
index 0000000..a57760b
--- /dev/null
+++ b/contrib/rvnit/sv/00Shello
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo Hello from rvnit
diff --git a/contrib/rvnit/sv/01Spseudofs b/contrib/rvnit/sv/01Spseudofs
new file mode 100755
index 0000000..94c9e85
--- /dev/null
+++ b/contrib/rvnit/sv/01Spseudofs
@@ -0,0 +1,49 @@
+#!/bin/sh
+# vim: set ts=4 sw=4 et:
+
+. /etc/runit/functions
+
+msg "Mounting pseudo-filesystems..."
+mountpoint -q /proc || mount -o nosuid,noexec,nodev -t proc proc /proc
+mountpoint -q /sys || mount -o nosuid,noexec,nodev -t sysfs sys /sys
+mountpoint -q /run || mount -o mode=0755,nosuid,nodev -t tmpfs run /run
+mountpoint -q /dev || mount -o mode=0755,nosuid -t devtmpfs dev /dev
+mkdir -p -m0755 /run/runit /run/lvm /run/user /run/lock /run/log /dev/pts /dev/shm
+mountpoint -q /dev/pts || mount -o mode=0620,gid=5,nosuid,noexec -n -t devpts devpts /dev/pts
+mountpoint -q /dev/shm || mount -o mode=1777,nosuid,nodev -n -t tmpfs shm /dev/shm
+mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
+
+if [ -z "$VIRTUALIZATION" ]; then
+    _cgroupv1=""
+    _cgroupv2=""
+
+    case "${CGROUP_MODE:-hybrid}" in
+        legacy)
+            _cgroupv1="/sys/fs/cgroup"
+            ;;
+        hybrid)
+            _cgroupv1="/sys/fs/cgroup"
+            _cgroupv2="${_cgroupv1}/unified"
+            ;;
+        unified)
+            _cgroupv2="/sys/fs/cgroup"
+            ;;
+    esac
+
+    # cgroup v1
+    if [ -n "$_cgroupv1" ]; then
+        mountpoint -q "$_cgroupv1" || mount -o mode=0755 -t tmpfs cgroup "$_cgroupv1"
+        while read -r _subsys_name _hierarchy _num_cgroups _enabled; do
+            [ "$_enabled" = "1" ] || continue
+            _controller="${_cgroupv1}/${_subsys_name}"
+            mkdir -p "$_controller"
+            mountpoint -q "$_controller" || mount -t cgroup -o "$_subsys_name" cgroup "$_controller"
+        done < /proc/cgroups
+    fi
+
+    # cgroup v2
+    if [ -n "$_cgroupv2" ]; then
+        mkdir -p "$_cgroupv2"
+        mountpoint -q "$_cgroupv2" || mount -t cgroup2 -o nsdelegate cgroup2 "$_cgroupv2"
+    fi
+fi
diff --git a/contrib/rvnit/sv/02Sstatic-devnodes b/contrib/rvnit/sv/02Sstatic-devnodes
new file mode 100755
index 0000000..ef747a4
--- /dev/null
+++ b/contrib/rvnit/sv/02Sstatic-devnodes
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Some kernel modules must be loaded before starting udev(7).
+# Load them by looking at the output of `kmod static-nodes`.
+
+for f in $(kmod static-nodes 2>/dev/null|awk '/Module/ {print $2}'); do
+	modprobe -bq $f 2>/dev/null
+done
diff --git a/contrib/rvnit/sv/03Skmods b/contrib/rvnit/sv/03Skmods
new file mode 100755
index 0000000..f25fb10
--- /dev/null
+++ b/contrib/rvnit/sv/03Skmods
@@ -0,0 +1,12 @@
+#!/bin/sh
+# vim: set ts=4 sw=4 et:
+
+. /etc/runit/functions
+
+[ -n "$VIRTUALIZATION" ] && return 0
+# Do not try to load modules if kernel does not support them.
+[ ! -e /proc/modules ] && return 0
+
+msg "Loading kernel modules..."
+modules-load -v | tr '\n' ' ' | sed 's:insmod [^ ]*/::g; s:\.ko\(\.gz\)\? ::g'
+echo
diff --git a/contrib/rvnit/sv/04Sudev b/contrib/rvnit/sv/04Sudev
new file mode 100755
index 0000000..d1b0697
--- /dev/null
+++ b/contrib/rvnit/sv/04Sudev
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+[ -n "$VIRTUALIZATION" ] && return 0
+
+if [ -x /usr/lib/systemd/systemd-udevd ]; then
+    _udevd=/usr/lib/systemd/systemd-udevd
+elif [ -x /sbin/udevd -o -x /bin/udevd ]; then
+    _udevd=udevd
+else
+    msg_warn "cannot find udevd!"
+fi
+
+if [ -n "${_udevd}" ]; then
+    msg "Starting udev and waiting for devices to settle..."
+    ${_udevd} --daemon
+    udevadm trigger --action=add --type=subsystems
+    udevadm trigger --action=add --type=devices
+    udevadm settle
+fi
diff --git a/contrib/rvnit/sv/05Sconsole-setup b/contrib/rvnit/sv/05Sconsole-setup
new file mode 100755
index 0000000..966121b
--- /dev/null
+++ b/contrib/rvnit/sv/05Sconsole-setup
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+[ -n "$VIRTUALIZATION" ] && return 0
+
+TTYS=${TTYS:-12}
+if [ -n "$FONT" ]; then
+    msg "Setting up TTYs font to '${FONT}'..."
+
+    _index=0
+    while [ ${_index} -le $TTYS ]; do
+        setfont ${FONT_MAP:+-m $FONT_MAP} ${FONT_UNIMAP:+-u $FONT_UNIMAP} \
+                $FONT -C "/dev/tty${_index}"
+        _index=$((_index + 1))
+    done
+fi
+
+if [ -n "$KEYMAP" ]; then
+    msg "Setting up keymap to '${KEYMAP}'..."
+    loadkeys -q -u ${KEYMAP}
+fi
+
+if [ -n "$HARDWARECLOCK" ]; then
+    msg "Setting up RTC to '${HARDWARECLOCK}'..."
+    TZ=$TIMEZONE hwclock --systz \
+        ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z) --noadjfile} || emergency_shell
+fi
diff --git a/contrib/rvnit/sv/06Sfilesystems b/contrib/rvnit/sv/06Sfilesystems
new file mode 100755
index 0000000..bc72eca
--- /dev/null
+++ b/contrib/rvnit/sv/06Sfilesystems
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+[ -n "$VIRTUALIZATION" ] && return 0
+
+msg "Remounting rootfs read-only..."
+mount -o remount,ro / || emergency_shell
+
+if [ -x /sbin/dmraid -o -x /bin/dmraid ]; then
+    msg "Activating dmraid devices..."
+    dmraid -i -ay
+fi
+
+if [ -x /bin/btrfs ]; then
+    msg "Activating btrfs devices..."
+    btrfs device scan || emergency_shell
+fi
+
+if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
+    msg "Activating LVM devices..."
+    vgchange --sysinit -a ay || emergency_shell
+fi
+
+if [ -e /etc/crypttab ]; then
+    msg "Activating encrypted devices..."
+    awk -f /etc/runit/crypt.awk /etc/crypttab
+
+    if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
+        msg "Activating LVM devices for dm-crypt..."
+        vgchange --sysinit -a ay || emergency_shell
+    fi
+fi
+
+if [ -x /usr/bin/zpool -a -x /usr/bin/zfs ]; then
+    if [ -e /etc/zfs/zpool.cache ]; then
+        msg "Importing cached ZFS pools..."
+        zpool import -N -a -c /etc/zfs/zpool.cache
+    else
+        msg "Scanning for and importing ZFS pools..."
+        zpool import -N -a -o cachefile=none
+    fi
+
+    msg "Mounting ZFS file systems..."
+    zfs mount -a -l
+
+    msg "Sharing ZFS file systems..."
+    zfs share -a
+
+    # NOTE(dh): ZFS has ZVOLs, block devices on top of storage pools.
+    # In theory, it would be possible to use these as devices in
+    # dmraid, btrfs, LVM and so on. In practice it's unlikely that
+    # anybody is doing that, so we aren't supporting it for now.
+fi
+
+[ -f /fastboot ] && FASTBOOT=1
+[ -f /forcefsck ] && FORCEFSCK="-f"
+for arg in $(cat /proc/cmdline); do
+    case $arg in
+        fastboot) FASTBOOT=1;;
+        forcefsck) FORCEFSCK="-f";;
+    esac
+done
+
+if [ -z "$FASTBOOT" ]; then
+    msg "Checking filesystems:"
+    fsck -A -T -a -t noopts=_netdev $FORCEFSCK
+    if [ $? -gt 1 ]; then
+        emergency_shell
+    fi
+fi
+
+msg "Mounting rootfs read-write..."
+mount -o remount,rw / || emergency_shell
+
+msg "Mounting all non-network filesystems..."
+mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || emergency_shell
diff --git a/contrib/rvnit/sv/07Sswap b/contrib/rvnit/sv/07Sswap
new file mode 100755
index 0000000..4327a1e
--- /dev/null
+++ b/contrib/rvnit/sv/07Sswap
@@ -0,0 +1,9 @@
+#!/bin/sh
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+[ -n "$VIRTUALIZATION" ] && return 0
+
+msg "Initializing swap..."
+swapon -a || emergency_shell
diff --git a/contrib/rvnit/sv/08Smisc b/contrib/rvnit/sv/08Smisc
new file mode 100755
index 0000000..ad11691
--- /dev/null
+++ b/contrib/rvnit/sv/08Smisc
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /etc/rc.conf
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+install -m0664 -o root -g utmp /dev/null /run/utmp
+halt -B  # for wtmp
+
+if [ -z "$VIRTUALIZATION" ]; then
+    msg "Initializing random seed..."
+    cp /var/lib/random-seed /dev/urandom >/dev/null 2>&1 || true
+fi
+
+msg "Setting up loopback interface..."
+ip link set up dev lo
+
+[ -r /etc/hostname ] && read -r HOSTNAME < /etc/hostname
+if [ -n "$HOSTNAME" ]; then
+    msg "Setting up hostname to '${HOSTNAME}'..."
+    printf "%s" "$HOSTNAME" > /proc/sys/kernel/hostname
+else
+    msg_warn "Didn't setup a hostname!"
+fi
+
+if [ -n "$TIMEZONE" ]; then
+    msg "Setting up timezone to '${TIMEZONE}'..."
+    ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
+fi
diff --git a/contrib/rvnit/sv/09Ssysctl b/contrib/rvnit/sv/09Ssysctl
new file mode 100755
index 0000000..1763223
--- /dev/null
+++ b/contrib/rvnit/sv/09Ssysctl
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+. /etc/runit/functions
+
+# vim: set ts=4 sw=4 et:
+
+if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
+    msg "Loading sysctl(8) settings..."
+    mkdir -p /run/vsysctl.d
+    for i in /run/sysctl.d/*.conf \
+        /etc/sysctl.d/*.conf \
+        /usr/local/lib/sysctl.d/*.conf \
+        /usr/lib/sysctl.d/*.conf; do
+
+        if [ -e "$i" ] && [ ! -e "/run/vsysctl.d/${i##*/}" ]; then
+            ln -s "$i" "/run/vsysctl.d/${i##*/}"
+        fi
+    done
+    for i in /run/vsysctl.d/*.conf; do
+        sysctl -p "$i"
+    done
+    rm -rf -- /run/vsysctl.d
+    sysctl -p /etc/sysctl.conf
+fi
diff --git a/contrib/rvnit/sv/20Scleanup b/contrib/rvnit/sv/20Scleanup
new file mode 100755
index 0000000..6310892
--- /dev/null
+++ b/contrib/rvnit/sv/20Scleanup
@@ -0,0 +1,11 @@
+#!/bin/sh
+# vim: set ts=4 sw=4 et:
+
+if [ ! -e /var/log/wtmp ]; then
+	install -m0664 -o root -g utmp /dev/null /var/log/wtmp
+fi
+if [ ! -e /var/log/btmp ]; then
+	install -m0600 -o root -g utmp /dev/null /var/log/btmp
+fi
+install -dm1777 /tmp/.X11-unix /tmp/.ICE-unix
+rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
diff --git a/contrib/rvnit/sv/30Dacpid b/contrib/rvnit/sv/30Dacpid
new file mode 100755
index 0000000..69a45d1
--- /dev/null
+++ b/contrib/rvnit/sv/30Dacpid
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec acpid -f -l
diff --git a/contrib/rvnit/sv/30Dudevd b/contrib/rvnit/sv/30Dudevd
new file mode 100755
index 0000000..a3a396b
--- /dev/null
+++ b/contrib/rvnit/sv/30Dudevd
@@ -0,0 +1,3 @@
+#!/bin/sh
+udevadm control --exit
+exec udevd 2>&1
diff --git a/contrib/rvnit/sv/40Ddhcpcd b/contrib/rvnit/sv/40Ddhcpcd
new file mode 100755
index 0000000..71fdfe3
--- /dev/null
+++ b/contrib/rvnit/sv/40Ddhcpcd
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec dhcpcd -B -M 2>&1
diff --git a/contrib/rvnit/sv/45Snetup b/contrib/rvnit/sv/45Snetup
new file mode 100755
index 0000000..02082f4
--- /dev/null
+++ b/contrib/rvnit/sv/45Snetup
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+exec 2>&1
+
+count=10
+while ! ping -c1 8.8.8.8; do
+	sleep 1
+	count=$((count-1))
+	if [ $count -eq 0 ]; then
+		exit 1
+	fi
+done
+
+exit 0
diff --git a/contrib/rvnit/sv/50Dopensshd b/contrib/rvnit/sv/50Dopensshd
new file mode 100755
index 0000000..2cfbce4
--- /dev/null
+++ b/contrib/rvnit/sv/50Dopensshd
@@ -0,0 +1,3 @@
+#!/bin/sh
+ssh-keygen -A >/dev/null 2>&1
+exec /usr/bin/sshd -D
diff --git a/contrib/rvnit/sv/90Dagetty-tty3 b/contrib/rvnit/sv/90Dagetty-tty3
new file mode 100755
index 0000000..419ea49
--- /dev/null
+++ b/contrib/rvnit/sv/90Dagetty-tty3
@@ -0,0 +1,3 @@
+#!/bin/sh
+tty=${0##*-}
+exec agetty "${tty}" 38400 linux
diff --git a/contrib/rvnit/sv/90Dagetty-tty4 b/contrib/rvnit/sv/90Dagetty-tty4
new file mode 100755
index 0000000..419ea49
--- /dev/null
+++ b/contrib/rvnit/sv/90Dagetty-tty4
@@ -0,0 +1,3 @@
+#!/bin/sh
+tty=${0##*-}
+exec agetty "${tty}" 38400 linux
diff --git a/contrib/rvnit/sv/90Dagetty-tty5 b/contrib/rvnit/sv/90Dagetty-tty5
new file mode 100755
index 0000000..419ea49
--- /dev/null
+++ b/contrib/rvnit/sv/90Dagetty-tty5
@@ -0,0 +1,3 @@
+#!/bin/sh
+tty=${0##*-}
+exec agetty "${tty}" 38400 linux
diff --git a/contrib/rvnit/sv/90Dagetty-tty6 b/contrib/rvnit/sv/90Dagetty-tty6
new file mode 100755
index 0000000..419ea49
--- /dev/null
+++ b/contrib/rvnit/sv/90Dagetty-tty6
@@ -0,0 +1,3 @@
+#!/bin/sh
+tty=${0##*-}
+exec agetty "${tty}" 38400 linux
diff --git a/contrib/rvnit/sv/99Dsulogin b/contrib/rvnit/sv/99Dsulogin
new file mode 100755
index 0000000..3c708e0
--- /dev/null
+++ b/contrib/rvnit/sv/99Dsulogin
@@ -0,0 +1,3 @@
+#!/bin/sh
+tty=/dev/tty2
+exec sulogin <$tty >$tty