Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
82bf65d4fa | |||
f8a8bc673b | |||
65e0733db7 | |||
d9721360b1 | |||
![]() |
a3bcf72edb | ||
f3b0b94b3b | |||
![]() |
d100216548 |
47
3
47
3
@@ -11,49 +11,10 @@ if [ -e /run/runit/reboot ]; then
|
|||||||
chmod 100 /run/runit/reboot
|
chmod 100 /run/runit/reboot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
|
||||||
msg "Waiting for services to stop..."
|
|
||||||
sv force-stop /run/runit/service/*
|
|
||||||
sv exit /run/runit/service/*
|
|
||||||
|
|
||||||
[ -x /etc/runit/rc.shutdown ] && /etc/runit/rc.shutdown
|
[ -x /etc/runit/rc.shutdown ] && /etc/runit/rc.shutdown
|
||||||
|
|
||||||
msg "Saving random seed..."
|
for f in /etc/runit/shutdown-services/*.sh; do
|
||||||
( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
|
[ -r $f ] && . $f
|
||||||
|
done
|
||||||
|
|
||||||
if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
|
msg "Stage 3 completed."
|
||||||
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
|
|
||||||
fi
|
|
||||||
|
|
||||||
halt -w # for utmp
|
|
||||||
|
|
||||||
if [ -z "$VIRTUALIZATION" ]; then
|
|
||||||
msg "Stopping udev..."
|
|
||||||
udevadm control --exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
msg "Sending TERM signal to processes..."
|
|
||||||
pkill --inverse -s0,1 -TERM
|
|
||||||
sleep 1
|
|
||||||
msg "Sending KILL signal to processes..."
|
|
||||||
pkill --inverse -s0,1 -KILL
|
|
||||||
|
|
||||||
if [ -z "$VIRTUALIZATION" ]; then
|
|
||||||
msg "Unmounting filesystems, disabling swap..."
|
|
||||||
swapoff -a
|
|
||||||
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
|
|
||||||
msg "Remounting rootfs read-only..."
|
|
||||||
mount -o remount,ro /
|
|
||||||
fi
|
|
||||||
|
|
||||||
sync
|
|
||||||
|
|
||||||
if [ -z "$VIRTUALIZATION" ]; then
|
|
||||||
deactivate_vgs
|
|
||||||
deactivate_crypt
|
|
||||||
if [ -e /run/runit/reboot ] && command -v kexec >/dev/null; then
|
|
||||||
msg "Triggering kexec..."
|
|
||||||
kexec -e 2>/dev/null
|
|
||||||
# not reached when kexec was successful.
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
2
Makefile
2
Makefile
@@ -26,7 +26,9 @@ install:
|
|||||||
install -d ${DESTDIR}/etc/runit/sv
|
install -d ${DESTDIR}/etc/runit/sv
|
||||||
install -d ${DESTDIR}/etc/runit/runsvdir
|
install -d ${DESTDIR}/etc/runit/runsvdir
|
||||||
install -d ${DESTDIR}/etc/runit/core-services
|
install -d ${DESTDIR}/etc/runit/core-services
|
||||||
|
install -d ${DESTDIR}/etc/runit/shutdown-services
|
||||||
install -m644 core-services/*.sh ${DESTDIR}/etc/runit/core-services
|
install -m644 core-services/*.sh ${DESTDIR}/etc/runit/core-services
|
||||||
|
install -m644 shutdown-services/*.sh ${DESTDIR}/etc/runit/shutdown-services
|
||||||
install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit
|
install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit
|
||||||
install -m644 functions $(DESTDIR)/etc/runit
|
install -m644 functions $(DESTDIR)/etc/runit
|
||||||
install -m644 crypt.awk ${DESTDIR}/etc/runit
|
install -m644 crypt.awk ${DESTDIR}/etc/runit
|
||||||
|
15
README.md
15
README.md
@@ -4,21 +4,24 @@ This repository contains the runit init scripts for the Artix Linux
|
|||||||
distribution.
|
distribution.
|
||||||
|
|
||||||
This work is based on Void Linux's
|
This work is based on Void Linux's
|
||||||
[runit-void](https://github.com/voidlinux/void-runit). Patches to Void
|
[void-runit](https://github.com/voidlinux/void-runit). Patches to Void
|
||||||
Linux's repo will also be applied here.
|
Linux's repo will also be applied here.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
- GNU coreutils
|
||||||
- A POSIX shell
|
- A POSIX shell
|
||||||
- A POSIX awk
|
- A POSIX awk
|
||||||
- procps-ng (needs pkill -s0,1)
|
- procps-ng (needs pkill -s0,1)
|
||||||
- runit
|
- runit
|
||||||
|
- opentmpfiles
|
||||||
|
- opensysusers
|
||||||
|
|
||||||
### How to use it
|
### How to use it
|
||||||
|
|
||||||
To see enabled services for "current" runlevel:
|
To see enabled services for "current" runlevel:
|
||||||
|
|
||||||
$ ls -l /var/service
|
$ ls -l /run/runit/service
|
||||||
|
|
||||||
To see available runlevels (default and single, which just runs sulogin):
|
To see available runlevels (default and single, which just runs sulogin):
|
||||||
|
|
||||||
@@ -26,21 +29,21 @@ To see available runlevels (default and single, which just runs sulogin):
|
|||||||
|
|
||||||
To enable and start a service into the "current" runlevel:
|
To enable and start a service into the "current" runlevel:
|
||||||
|
|
||||||
# ln -s /etc/runit/sv/<service> /var/service
|
# ln -s /etc/runit/sv/<service> /run/runit/service
|
||||||
|
|
||||||
To disable and remove a service:
|
To disable and remove a service:
|
||||||
|
|
||||||
# rm -f /var/service/<service>
|
# rm -f /run/runit/service/<service>
|
||||||
|
|
||||||
To view status of all services for "current" runlevel:
|
To view status of all services for "current" runlevel:
|
||||||
|
|
||||||
# sv status /var/service/*
|
# sv status /run/runit/service/*
|
||||||
|
|
||||||
Feel free to send patches and contribute with improvements!
|
Feel free to send patches and contribute with improvements!
|
||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
|
|
||||||
runit-cromnix is in the public domain.
|
runit-artix is in the public domain.
|
||||||
|
|
||||||
To the extent possible under law, the creator of this work has waived
|
To the extent possible under law, the creator of this work has waived
|
||||||
all copyright and related or neighboring rights to this work.
|
all copyright and related or neighboring rights to this work.
|
||||||
|
@@ -2,5 +2,5 @@
|
|||||||
# Load them by looking at the output of `kmod static-nodes`.
|
# 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
|
for f in $(kmod static-nodes 2>/dev/null|awk '/Module/ {print $2}'); do
|
||||||
modprobe -q $f 2>/dev/null
|
modprobe -bq $f 2>/dev/null
|
||||||
done
|
done
|
||||||
|
@@ -10,6 +10,11 @@ else
|
|||||||
msg_warn "cannot find udevd!"
|
msg_warn "cannot find udevd!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -x /usr/bin/tmpfiles ]; then
|
||||||
|
msg "Setting up tmpfiles.d entries for /dev..."
|
||||||
|
tmpfiles --prefix=/dev --create --boot
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${_udevd}" ]; then
|
if [ -n "${_udevd}" ]; then
|
||||||
msg "Starting udev and waiting for devices to settle..."
|
msg "Starting udev and waiting for devices to settle..."
|
||||||
${_udevd} --daemon
|
${_udevd} --daemon
|
||||||
|
@@ -21,4 +21,11 @@ if [ -n "$TIMEZONE" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
msg "Setting up sysusers.d entries..."
|
msg "Setting up sysusers.d entries..."
|
||||||
sysusers
|
if [ -x /usr/bin/sysusers ]; then
|
||||||
|
sysusers
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "Setting up tmpfiles.d entries..."
|
||||||
|
if [ -x /usr/bin/tmpfiles ]; then
|
||||||
|
tmpfiles --exclude-prefix=/dev --create --remove --boot
|
||||||
|
fi
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
|
if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
|
||||||
msg "Loading sysctl(8) settings..."
|
msg "Loading sysctl(8) settings..."
|
||||||
for i in /run/sysctl.d/*.conf \
|
for i in /run/sysctl.d/*.conf \
|
||||||
/etc/sysctl.d/*.conf \
|
|
||||||
/usr/local/lib/sysctl.d/*.conf \
|
/usr/local/lib/sysctl.d/*.conf \
|
||||||
/usr/lib/sysctl.d/*.conf \
|
/usr/lib/sysctl.d/*.conf \
|
||||||
/etc/sysctl.conf; do
|
/etc/sysctl.conf \
|
||||||
|
/etc/sysctl.d/*.conf; do
|
||||||
|
|
||||||
if [ -e "$i" ]; then
|
if [ -e "$i" ]; then
|
||||||
printf '* Applying %s ...\n' "$i"
|
printf '* Applying %s ...\n' "$i"
|
||||||
|
@@ -7,5 +7,6 @@ fi
|
|||||||
if [ ! -e /var/log/btmp ]; then
|
if [ ! -e /var/log/btmp ]; then
|
||||||
install -m0600 -o root -g utmp /dev/null /var/log/btmp
|
install -m0600 -o root -g utmp /dev/null /var/log/btmp
|
||||||
fi
|
fi
|
||||||
install -dm1777 /tmp/.X11-unix /tmp/.ICE-unix
|
rm -rf /tmp
|
||||||
|
install -dm1777 /tmp /tmp/.X11-unix /tmp/.ICE-unix
|
||||||
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
||||||
|
3
shutdown-services/00-stop-services.sh
Normal file
3
shutdown-services/00-stop-services.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
msg "Waiting for services to stop..."
|
||||||
|
sv force-stop /run/runit/service/*
|
||||||
|
sv exit /run/runit/service/*
|
2
shutdown-services/01-random-seed.sh
Normal file
2
shutdown-services/01-random-seed.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
msg "Saving random seed..."
|
||||||
|
( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
|
6
shutdown-services/02-hwclock.sh
Normal file
6
shutdown-services/02-hwclock.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
if [ -z "$VIRTUALIZATION" ] && [ -n "$HARDWARECLOCK" ]; then
|
||||||
|
msg "Saving hardware clock..."
|
||||||
|
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
|
||||||
|
fi
|
||||||
|
|
||||||
|
halt -w # for utmp
|
4
shutdown-services/03-stop-udev.sh
Normal file
4
shutdown-services/03-stop-udev.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
if [ -z "$VIRTUALIZATION" ]; then
|
||||||
|
msg "Stopping udev..."
|
||||||
|
udevadm control --exit
|
||||||
|
fi
|
5
shutdown-services/04-killall.sh
Normal file
5
shutdown-services/04-killall.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
msg "Sending TERM signal to processes..."
|
||||||
|
pkill --inverse -s0,1 -TERM
|
||||||
|
sleep 1
|
||||||
|
msg "Sending KILL signal to processes..."
|
||||||
|
pkill --inverse -s0,1 -KILL
|
8
shutdown-services/97-mount-ro.sh
Normal file
8
shutdown-services/97-mount-ro.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
if [ -z "$VIRTUALIZATION" ]; then
|
||||||
|
msg "Unmounting filesystems, disabling swap..."
|
||||||
|
swapoff -a
|
||||||
|
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
|
||||||
|
msg "Remounting rootfs read-only..."
|
||||||
|
mount -o remount,ro /
|
||||||
|
fi
|
||||||
|
sync
|
9
shutdown-services/98-deactivate-crypt.sh
Normal file
9
shutdown-services/98-deactivate-crypt.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
if [ -z "$VIRTUALIZATION" ]; then
|
||||||
|
deactivate_vgs
|
||||||
|
deactivate_crypt
|
||||||
|
if [ -e /run/runit/reboot ] && command -v kexec >/dev/null; then
|
||||||
|
msg "Triggering kexec..."
|
||||||
|
kexec -e 2>/dev/null
|
||||||
|
# not reached when kexec was successful.
|
||||||
|
fi
|
||||||
|
fi
|
Reference in New Issue
Block a user