From f9b84b4967282cd6da931b7ea2569557937d4e24 Mon Sep 17 00:00:00 2001 From: Shokara Kou Date: Fri, 13 May 2022 11:50:43 -0400 Subject: add sinit and perp replaces sysvinit. perp can be used alongside crux's rc scripts, but i didn't try that. --- perp/.footprint | 59 +++++++++++++++++++++++++++++++++++++++++++++ perp/.md5sum | 1 + perp/Pkgfile | 19 +++++++++++++++ perp/post-install | 4 ++++ sinit/.footprint | 13 ++++++++++ sinit/.md5sum | 5 ++++ sinit/Pkgfile | 33 +++++++++++++++++++++++++ sinit/poweroff | 2 ++ sinit/rc.conf | 3 +++ sinit/rc.init | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ sinit/rc.shutdown | 47 ++++++++++++++++++++++++++++++++++++ sinit/reboot | 2 ++ 12 files changed, 260 insertions(+) create mode 100644 perp/.footprint create mode 100644 perp/.md5sum create mode 100644 perp/Pkgfile create mode 100644 perp/post-install create mode 100644 sinit/.footprint create mode 100644 sinit/.md5sum create mode 100644 sinit/Pkgfile create mode 100644 sinit/poweroff create mode 100644 sinit/rc.conf create mode 100644 sinit/rc.init create mode 100644 sinit/rc.shutdown create mode 100644 sinit/reboot diff --git a/perp/.footprint b/perp/.footprint new file mode 100644 index 0000000..d2a965e --- /dev/null +++ b/perp/.footprint @@ -0,0 +1,59 @@ +drwxr-xr-x root/root sbin/ +-rwxr-xr-x root/root sbin/perp-setup +-rwxr-xr-x root/root sbin/perpboot +-rwxr-xr-x root/root sbin/perpctl +-rwxr-xr-x root/root sbin/perpd +-rwxr-xr-x root/root sbin/perphup +-rwxr-xr-x root/root sbin/perpls +-rwxr-xr-x root/root sbin/perpok +-rwxr-xr-x root/root sbin/perpstat +-rwxr-xr-x root/root sbin/runargs +-rwxr-xr-x root/root sbin/runargv0 +-rwxr-xr-x root/root sbin/runchoom +-rwxr-xr-x root/root sbin/rundetach +-rwxr-xr-x root/root sbin/rundeux +-rwxr-xr-x root/root sbin/runenv +-rwxr-xr-x root/root sbin/runfile +-rwxr-xr-x root/root sbin/runlimit +-rwxr-xr-x root/root sbin/runlock +-rwxr-xr-x root/root sbin/runpause +-rwxr-xr-x root/root sbin/runsession +-rwxr-xr-x root/root sbin/runtool +-rwxr-xr-x root/root sbin/runtrap +-rwxr-xr-x root/root sbin/runuid +-rwxr-xr-x root/root sbin/sissylog +-rwxr-xr-x root/root sbin/tinylog +-rwxr-xr-x root/root sbin/tinylog_run +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/share/ +drwxr-xr-x root/root usr/share/man/ +drwxr-xr-x root/root usr/share/man/man5/ +-rw-r--r-- root/root usr/share/man/man5/perpetrate.5.gz +drwxr-xr-x root/root usr/share/man/man8/ +-rw-r--r-- root/root usr/share/man/man8/perp-setup.8.gz +-rw-r--r-- root/root usr/share/man/man8/perp_intro.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpboot.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpctl.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpd.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpetrate.8.gz +-rw-r--r-- root/root usr/share/man/man8/perphup.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpls.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpok.8.gz +-rw-r--r-- root/root usr/share/man/man8/perpstat.8.gz +-rw-r--r-- root/root usr/share/man/man8/runargs.8.gz +-rw-r--r-- root/root usr/share/man/man8/runargv0.8.gz +-rw-r--r-- root/root usr/share/man/man8/runchoom.8.gz +-rw-r--r-- root/root usr/share/man/man8/rundetach.8.gz +-rw-r--r-- root/root usr/share/man/man8/rundeux.8.gz +-rw-r--r-- root/root usr/share/man/man8/runenv.8.gz +-rw-r--r-- root/root usr/share/man/man8/runfile.8.gz +-rw-r--r-- root/root usr/share/man/man8/runlimit.8.gz +-rw-r--r-- root/root usr/share/man/man8/runlock.8.gz +-rw-r--r-- root/root usr/share/man/man8/runpause.8.gz +-rw-r--r-- root/root usr/share/man/man8/runsession.8.gz +-rw-r--r-- root/root usr/share/man/man8/runtool.8.gz +-rw-r--r-- root/root usr/share/man/man8/runtools_intro.8.gz +-rw-r--r-- root/root usr/share/man/man8/runtrap.8.gz +-rw-r--r-- root/root usr/share/man/man8/runuid.8.gz +-rw-r--r-- root/root usr/share/man/man8/sissylog.8.gz +-rw-r--r-- root/root usr/share/man/man8/tinylog.8.gz diff --git a/perp/.md5sum b/perp/.md5sum new file mode 100644 index 0000000..d3ab623 --- /dev/null +++ b/perp/.md5sum @@ -0,0 +1 @@ +a2acc7425d556d9635a25addcee9edb5 perp-2.07.tar.gz diff --git a/perp/Pkgfile b/perp/Pkgfile new file mode 100644 index 0000000..af63eca --- /dev/null +++ b/perp/Pkgfile @@ -0,0 +1,19 @@ +# Description: persistent process supervisor/service managment framework +# URL: http://b0llix.net/perp/ +# Maintainer: Shokara Kou, kou at 13f0 dot net +# Depends on: + +name=perp +version=2.07 +release=1 +source=(http://b0llix.net/$name/distfiles/$name-$version.tar.gz) + +build() { + cd $name-$version + + sed '/BINDIR/ s/\/usr//' conf.mk > conf.mk.tmp + mv conf.mk.tmp conf.mk + + make + make DESTDIR=$PKG install +} diff --git a/perp/post-install b/perp/post-install new file mode 100644 index 0000000..9a47bdc --- /dev/null +++ b/perp/post-install @@ -0,0 +1,4 @@ +#!/bin/sh +groupadd log +useradd -r log +perp-setup /etc/perp diff --git a/sinit/.footprint b/sinit/.footprint new file mode 100644 index 0000000..92edcc3 --- /dev/null +++ b/sinit/.footprint @@ -0,0 +1,13 @@ +drwxr-xr-x root/root bin/ +-rwxr-xr-x root/root bin/poweroff +-rwxr-xr-x root/root bin/reboot +-rwxr-xr-x root/root bin/sinit +drwxr-xr-x root/root etc/ +-rw-r--r-- root/root etc/rc.conf +-rwxr-xr-x root/root etc/rc.init +-rwxr-xr-x root/root etc/rc.shutdown +drwxr-xr-x root/root sbin/ +lrwxrwxrwx root/root sbin/init -> /bin/sinit +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/man8/ +-rw-r--r-- root/root usr/man8/sinit.8 diff --git a/sinit/.md5sum b/sinit/.md5sum new file mode 100644 index 0000000..f1cf8fc --- /dev/null +++ b/sinit/.md5sum @@ -0,0 +1,5 @@ +dfd17c0b4f0ce941f4b7492e497fae0b poweroff +9ce036092ec6320a2f5d27abc41a25b7 rc.conf +a55a9362936986a1aad4b9a4186722a4 rc.init +37d30c23a48271712ae53175be980423 rc.shutdown +415e4e2648e9bb30e9281c3e5e48f48e reboot diff --git a/sinit/Pkgfile b/sinit/Pkgfile new file mode 100644 index 0000000..738a01a --- /dev/null +++ b/sinit/Pkgfile @@ -0,0 +1,33 @@ +# Description: suckless init, based on felker's minimal init +# URL: https://git.suckless.org/sinit/file/README.html +# Maintainer: Shokara Kou, kou at 13f0 dot net +# Depends on: + +name=sinit +commit=28c44b6 +version=git-$commit +release=1 +source=(poweroff reboot rc.conf rc.init rc.shutdown) + +gitsource=git://git.suckless.org/$name/ + +build() { + git clone $gitsource + cd $name + git checkout $commit + + sed 's/bin/etc/' config.def.h >config.h + + make + make PREFIX=/ MANPREFIX=/usr DESTDIR=$PKG install + + mkdir $PKG/sbin + ln -s /bin/sinit $PKG/sbin/init + + install -Dt $PKG/bin -m755 $SRC/poweroff + install -Dt $PKG/bin -m755 $SRC/reboot + + install -Dt $PKG/etc -m644 $SRC/rc.conf + install -Dt $PKG/etc -m755 $SRC/rc.init + install -Dt $PKG/etc -m755 $SRC/rc.shutdown +} diff --git a/sinit/poweroff b/sinit/poweroff new file mode 100644 index 0000000..b33bc03 --- /dev/null +++ b/sinit/poweroff @@ -0,0 +1,2 @@ +#!/bin/sh +kill -USR1 1 diff --git a/sinit/rc.conf b/sinit/rc.conf new file mode 100644 index 0000000..5cf7280 --- /dev/null +++ b/sinit/rc.conf @@ -0,0 +1,3 @@ +HOSTNAME=crux +INTERFACE=eth0 +TIMEZONE="UTC" diff --git a/sinit/rc.init b/sinit/rc.init new file mode 100644 index 0000000..aab0073 --- /dev/null +++ b/sinit/rc.init @@ -0,0 +1,72 @@ +#!/bin/sh +umask 022 + +. /etc/rc.conf + +echo "CRUX booting" + +/bin/mount -n -t proc -o nosuid,noexec,nodev proc /proc +/bin/mount -n -t sysfs -o nosuid,noexec,nodev sysfs /sys + +/bin/mount -n -t tmpfs -o nosuid,mode=0755 dev /dev +/bin/mkdir -p /dev/pts +/bin/mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts + +/bin/mount -o remount,ro / + +echo Running smdev +/bin/smdev -s + +echo Setting smdev as the kernel hotplug +echo /bin/smdev >/proc/sys/kernel/hotplug + +cd /dev +/bin/ln -sf /proc/self/fd/0 stdin +/bin/ln -sf /proc/self/fd/1 stdout +/bin/ln -sf /proc/self/fd/2 stderr +/bin/ln -sf /proc/self/fd fd +cd - >/dev/null + +echo Checking filesystems +/bin/fsck -ATa +if [ $? -eq 1 ]; then + echo Filesystems error exist, fix manually. + /bin/sh + /bin/halt -r +fi + +echo Remounting root as read-write +/bin/mount -o remount,rw / + +echo Mounting filesystems +/bin/mount -a + +/bin/hostname $HOSTNAME + +echo Bringing up loopback +/bin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host +/bin/ip link set lo up + +echo Setting hwclock +[ -n "$TIMEZONE" ] && export TZ="$TIMEZONE" +/bin/hwclock -s -u /dev/rtc0 +unset TZ + +[ -f /etc/random-seed ] && /bin/cat /etc/random-seed >/dev/urandom +/bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null + +echo Enabling core dumps +ulimit -c unlimited + +if [ -x /etc/rc.local ]; then + echo Running rc.local + /etc/rc.local +fi + +: >/var/run/utmp + +echo +/bin/sh -c '/bin/respawn /bin/getty /dev/tty1 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty2 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty3 linux' &>/dev/null & +/bin/sh -c '/bin/respawn /bin/getty /dev/tty4 linux' &>/dev/null & diff --git a/sinit/rc.shutdown b/sinit/rc.shutdown new file mode 100644 index 0000000..24cc606 --- /dev/null +++ b/sinit/rc.shutdown @@ -0,0 +1,47 @@ +#!/bin/sh +umask 022 + +. /etc/rc.conf + +case "$1" in +reboot|poweroff) ;; +*) + echo "Invalid action '$1' for rc.shutdown" >&2 + exit 1 + ;; +esac + +# avoid staircase effect by setting linefeed mode +echo; /bin/stty onlcr + +echo Shutting down + +echo Saving system clock +[ -n "$TIMEZONE" ] && export TZ="$TIMEZONE" +/bin/hwclock -w -u /dev/rtc0 +unset TZ + +/bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null + +echo Sending TERM to all processes +/bin/killall5 -s TERM +/bin/sleep 3 +echo Sending KILL to all processes +/bin/killall5 -s KILL + +echo Remounting root as read-only +/bin/mount -o remount,ro / + +echo Unmounting filesystems +/bin/umount -a + +/bin/sync +/bin/sleep 3 +wait + +echo Good bye. + +case "$1" in +reboot) /bin/halt -r ;; +poweroff) /bin/halt -p ;; +esac diff --git a/sinit/reboot b/sinit/reboot new file mode 100644 index 0000000..3d05840 --- /dev/null +++ b/sinit/reboot @@ -0,0 +1,2 @@ +#!/bin/sh +kill -INT 1 -- cgit v1.2.3