crux-initscripts

hacked CRUX initscripts to work with sinit
git clone git://git.2f30.org/crux-initscripts
Log | Files | Refs | README

commit 9a6a87c5c252724b04a5fb119f728c6ace76445f
Author: sin <sin@2f30.org>
Date:   Wed, 23 Apr 2014 15:14:36 +0100

Initial commit

Diffstat:
AREADME | 10++++++++++
Aetc/rc | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/rc.conf | 12++++++++++++
Aetc/rc.d/crond | 23+++++++++++++++++++++++
Aetc/rc.d/exim | 27+++++++++++++++++++++++++++
Aetc/rc.d/inetd | 23+++++++++++++++++++++++
Aetc/rc.d/net | 27+++++++++++++++++++++++++++
Aetc/rc.d/rsyncd | 23+++++++++++++++++++++++
Aetc/rc.d/sshd | 40++++++++++++++++++++++++++++++++++++++++
Aetc/rc.d/sysklogd | 23+++++++++++++++++++++++
Aetc/rc.local | 6++++++
Aetc/rc.modules | 8++++++++
Aetc/rc.multi | 35+++++++++++++++++++++++++++++++++++
Aetc/rc.shutdown | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/rc.single | 37+++++++++++++++++++++++++++++++++++++
Asbin/poweroff | 3+++
Asbin/reboot | 3+++
17 files changed, 480 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,10 @@ +I've packaged up the CRUX initscripts and hacked them up a bit +to use sinit + some of ubase's tools. + +To set it up, pull sinit[0] and ubase[1] and copy sinit +and respawn to sbin. + +Remove halt/reboot/shutdown from your system. + +[0] http://git.suckless.org/sinit/ +[1] http://git.suckless.org/ubase/ diff --git a/etc/rc b/etc/rc @@ -0,0 +1,123 @@ +#!/bin/bash +# +# /etc/rc: system boot script +# + +echo "The system is coming up. Please wait." + +# Load configuration +. /etc/rc.conf + +# Start udev +/bin/mount -t proc none /proc +/bin/mount -t sysfs none /sys +/sbin/start_udev + +# Create device-mapper device nodes and scan for LVM volume groups +if [ -x /sbin/lvm ]; then + /sbin/vgscan --mknodes --ignorelockingfailure + /sbin/vgchange --ignorelockingfailure -a y +fi + +# Scan for btrfs volumes to simplify fstab entries +if [ -r /sys/fs/btrfs ]; then + /sbin/btrfs dev scan +fi + +# Mount root read-only +/bin/mount -o remount,ro / + +if [ -f /forcefsck ]; then +FORCEFSCK="-f" +fi + +# Check filesystems +/sbin/fsck $FORCEFSCK -A -T -C -a +if [ $? -gt 1 ]; then + echo + echo "*************** FILESYSTEM CHECK FAILED ******************" + echo "* *" + echo "* Please repair manually and reboot. Note that the root *" + echo "* file system is currently mounted read-only. To remount *" + echo "* it read-write type: mount -n -o remount,rw / *" + echo "* When you exit the maintainance shell the system will *" + echo "* reboot automatically. *" + echo "* *" + echo "************************************************************" + echo + /sbin/sulogin -p + echo "Automatic reboot in progress..." + /bin/umount -a -r + /bin/mount -o remount,ro / + /sbin/reboot -f + exit 0 +fi + +# Mount local filesystems +/bin/mount -o remount,rw / +/bin/mount -a -O no_netdev + +# Activate swap +/sbin/swapon -a + +# Clean up misc files +: > /var/run/utmp +/bin/rm -rf /forcefsck /fastboot /etc/nologin /etc/shutdownpid +(cd /var/run && /usr/bin/find . -name "*.pid" -delete) +(cd /var/lock && /usr/bin/find . ! -type d -delete) +(cd /tmp && /usr/bin/find . ! -name . -delete) +/bin/mkdir -m 1777 /tmp/.ICE-unix + +# Set kernel variables +/sbin/sysctl -p > /dev/null + +# Update shared library links +/sbin/ldconfig + +# Configure host name +if [ "$HOSTNAME" ]; then + echo "hostname: $HOSTNAME" + /bin/hostname $HOSTNAME +fi + +# Load random seed +/bin/cat /var/lib/urandom/seed > /dev/urandom + +# Configure system clock +if [ "$TIMEZONE" ]; then + /bin/ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime +fi +/sbin/hwclock --hctosys + +# Load console font +if [ "$FONT" ]; then + echo "font: $FONT" + /usr/bin/setfont $FONT +fi + +# Load console keymap +if [ "$KEYMAP" ]; then + echo "keyboard: $KEYMAP" + /usr/bin/loadkeys -q $KEYMAP +fi + +# Screen blanks after 15 minutes idle time +/usr/bin/setterm -blank 15 + +# Run module initialization script +if [ -x /etc/rc.modules ]; then + /etc/rc.modules +fi + +# Save boot messages +/bin/dmesg > /var/log/boot + +#if [ -x /etc/rc.single ]; then +# /etc/rc.single +#fi + +if [ -x /etc/rc.multi ]; then + /etc/rc.multi +fi + +# End of file diff --git a/etc/rc.conf b/etc/rc.conf @@ -0,0 +1,12 @@ +# +# /etc/rc.conf: system configuration +# + +FONT=default +KEYMAP=us +TIMEZONE=UTC +HOSTNAME=host +SYSLOG=sysklogd +SERVICES=(net crond) + +# End of file diff --git a/etc/rc.d/crond b/etc/rc.d/crond @@ -0,0 +1,23 @@ +#!/bin/sh +# +# /etc/rc.d/crond: start/stop cron daemon +# + +case $1 in +start) + /usr/sbin/crond -S -l info + ;; +stop) + killall -q /usr/sbin/crond + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac + +# End of file diff --git a/etc/rc.d/exim b/etc/rc.d/exim @@ -0,0 +1,26 @@ +#!/bin/sh +# +# /etc/rc.d/exim: start/stop exim daemon +# + +case $1 in +start) + /usr/sbin/exim -bd -q15m + ;; +stop) + killall -q /usr/sbin/exim + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +reload) + kill -s HUP $(pidof exim) + ;; +*) + echo "usage: $0 [start|stop|restart|reload]" + ;; +esac + +# End of file +\ No newline at end of file diff --git a/etc/rc.d/inetd b/etc/rc.d/inetd @@ -0,0 +1,23 @@ +#!/bin/sh +# +# /etc/rc.d/inetd: start/stop inet daemon +# + +case $1 in +start) + /usr/sbin/inetd + ;; +stop) + killall -q /usr/sbin/inetd + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac + +# End of file diff --git a/etc/rc.d/net b/etc/rc.d/net @@ -0,0 +1,27 @@ +#!/bin/sh +# +# /etc/rc.d/net: start/stop network +# + +case $1 in +start) + # loopback + /sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host + /sbin/ip link set lo up + /sbin/dhcpcd -t 10 + ;; +stop) + /sbin/dhcpcd -x + /sbin/ip link set lo down + /sbin/ip addr del 127.0.0.1/8 dev lo + ;; +restart) + $0 stop + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac + +# End of file diff --git a/etc/rc.d/rsyncd b/etc/rc.d/rsyncd @@ -0,0 +1,23 @@ +#!/bin/sh +# +# /etc/rc.d/rsyncd: start/stop rsyncd daemon +# + +case $1 in +start) + /usr/bin/rsync --daemon + ;; +stop) + kill `cat /var/run/rsyncd.pid` + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac + +# End of file diff --git a/etc/rc.d/sshd b/etc/rc.d/sshd @@ -0,0 +1,40 @@ +#!/bin/sh +# +# /etc/rc.d/sshd: start/stop ssh daemon +# + +case $1 in +start) + if [ ! -f /etc/ssh/ssh_host_key ]; then + /usr/bin/ssh-keygen -t rsa1 -N "" -f /etc/ssh/ssh_host_key > /dev/null + fi + if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then + /usr/bin/ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key > /dev/null + fi + if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then + /usr/bin/ssh-keygen -t dsa -N "" -f /etc/ssh/ssh_host_dsa_key > /dev/null + fi + if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then + /usr/bin/ssh-keygen -t ecdsa -N "" -f /etc/ssh/ssh_host_ecdsa_key > /dev/null + fi + /usr/sbin/sshd + ;; +stop) + if [ -f /var/run/sshd.pid ]; then + kill $(< /var/run/sshd.pid) + rm -f /var/run/sshd.pid + else + killall -q /usr/sbin/sshd + fi + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac + +# End of file diff --git a/etc/rc.d/sysklogd b/etc/rc.d/sysklogd @@ -0,0 +1,23 @@ +#!/bin/sh +# +# /etc/rc.d/sysklogd: start/stop sysklogd logging daemons +# + +case $1 in +start) + /usr/sbin/syslogd + /usr/sbin/klogd -c 4 + ;; +stop) + /usr/bin/killall syslogd + /usr/bin/killall klogd + ;; +restart) + $0 stop + sleep 2 + $0 start + ;; +*) + echo "usage: $0 [start|stop|restart]" + ;; +esac diff --git a/etc/rc.local b/etc/rc.local @@ -0,0 +1,6 @@ +#!/bin/bash +# +# /etc/rc.local: local multi-user startup script +# + +# End of file diff --git a/etc/rc.modules b/etc/rc.modules @@ -0,0 +1,8 @@ +#!/bin/bash +# +# /etc/rc.modules: module initialization script +# + +/sbin/depmod -a + +# End of file diff --git a/etc/rc.multi b/etc/rc.multi @@ -0,0 +1,35 @@ +#!/bin/bash +# +# /etc/rc.multi: multi-user startup script +# + +# Load configuration +. /etc/rc.conf + +# Start services +if [ "$SYSLOG" -o "${SERVICES[*]}" ]; then + echo -n "starting services:" + if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then + echo -n " $SYSLOG" + /etc/rc.d/$SYSLOG start &> /dev/null || echo -n "[ERROR]" + fi + for service in ${SERVICES[@]}; do + echo -n " $service" + /etc/rc.d/$service start &> /tmp/rc.$$ || echo -n "[ERROR]" + /usr/bin/logger -t $service -f /tmp/rc.$$ + /bin/rm -f /tmp/rc.$$ + done + echo +fi + +# Run local startup script +if [ -x /etc/rc.local ]; then + /etc/rc.local +fi + +/sbin/respawn /sbin/agetty -8 -s 38400 tty1 linux +/sbin/respawn /sbin/agetty -8 -s 38400 tty2 linux +/sbin/respawn /sbin/agetty -8 -s 38400 tty3 linux +/sbin/respawn /sbin/agetty -8 -s 38400 tty4 linux + +# End of file diff --git a/etc/rc.shutdown b/etc/rc.shutdown @@ -0,0 +1,57 @@ +#!/bin/bash +# +# /etc/rc.shutdown: system shutdown script +# + +# Load configuration +. /etc/rc.conf + +# Set linefeed mode to avoid staircase effect +/bin/stty onlcr + +echo "The system is coming down. Please wait." + +# Shutdown services +if [ "${SERVICES[*]}" ]; then + for service in "${SERVICES[@]}"; do + R_SERVICES=($service ${R_SERVICES[@]}) + done + for service in "${R_SERVICES[@]}"; do + /etc/rc.d/$service stop &> /tmp/rc.$$ + /usr/bin/logger -t $service -f /tmp/rc.$$ + /bin/rm -f /tmp/rc.$$ + done +fi + +# Terminate all processes +/sbin/killall5 -15 +/bin/sleep 5 +/sbin/killall5 -9 + +# Save random seed +/bin/dd if=/dev/urandom of=/var/lib/urandom/seed count=1 2> /dev/null + +# Save system clock +/sbin/hwclock --systohc + +# Turn off swap +/sbin/swapoff -a + +# Unmount file systems +/bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs +if [ -x /sbin/lvm ]; then + /sbin/vgchange --ignorelockingfailure -a n +fi +/bin/umount -a -r + +# Remount root filesystem read-only +/bin/mount -o remount,ro / + +# Power off or reboot +if [ "$1" = "poweroff" ]; then + /sbin/halt -p +else + /sbin/halt -r +fi + +# End of file diff --git a/etc/rc.single b/etc/rc.single @@ -0,0 +1,37 @@ +#!/bin/bash +# +# /etc/rc.single: single-user startup script +# + +# Load configuration +. /etc/rc.conf + +# Shutdown services +if [ "${SERVICES[*]}" ]; then + for service in "${SERVICES[@]}"; do + R_SERVICES=($service ${R_SERVICES[@]}) + done + for service in "${R_SERVICES[@]}"; do + /etc/rc.d/$service stop &> /tmp/rc.$$ + /usr/bin/logger -t $service -f /tmp/rc.$$ + /bin/rm -f /tmp/rc.$$ + done +fi + +# Terminate all processes +/sbin/killall5 -15 +/bin/sleep 5 +/sbin/killall5 -9 + +if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then + /etc/rc.d/$SYSLOG start &> /dev/null +fi + +source /etc/profile + +# Start a shell for recovery +while :; do + /bin/sh +done + +# End of file diff --git a/sbin/poweroff b/sbin/poweroff @@ -0,0 +1,3 @@ +#!/bin/sh + +kill -s USR1 1 diff --git a/sbin/reboot b/sbin/reboot @@ -0,0 +1,3 @@ +#!/bin/sh + +kill -s INT 1