1 Commits

Author SHA1 Message Date
319d05e43c rc: build new instance from ground up, following void's scheme closely
This is meant to be an experiment (testing on a f2fs system to see
what's wrong with the old Arch initscript). However, this may be merged
into our mainline. If that *does* happen, I'll merge some of the old
scirpts (e.g. tmpfiles-setup, lvm) back, but some sv.d scripts (like netfs)
will need to be removed permanently.
2019-02-12 21:00:53 +07:00
32 changed files with 188 additions and 608 deletions

View File

@@ -16,34 +16,23 @@ RCBIN = \
script/modules-load script/modules-load
RCSVD = \ RCSVD = \
sv.d/root \
sv.d/binfmt \ sv.d/binfmt \
sv.d/bootlogd \ sv.d/cgroups \
sv.d/cleanup \ sv.d/cleanup \
sv.d/console-setup \ sv.d/console-setup \
sv.d/dmesg \ sv.d/fsck \
sv.d/hostname \ sv.d/hostname \
sv.d/hwclock \ sv.d/hwclock \
sv.d/kmod-static-nodes \ sv.d/kmod-static-nodes \
sv.d/misc \ sv.d/modules \
sv.d/mount-all \ sv.d/mount-fs \
sv.d/net-lo \ sv.d/net-lo \
sv.d/netfs \ sv.d/pseudofs \
sv.d/random-seed \ sv.d/random-seed \
sv.d/remount-root \
sv.d/swap \ sv.d/swap \
sv.d/sysctl \ sv.d/sysctl \
sv.d/sysusers \
sv.d/tmpfiles-dev \ sv.d/tmpfiles-dev \
sv.d/tmpfiles-setup \ sv.d/udev
sv.d/udev \
sv.d/udev-trigger \
sv.d/udev-settle \
sv.d/modules \
sv.d/sysfs \
sv.d/devfs \
sv.d/procfs \
sv.d/cgroups
# SYSINIT = \ # SYSINIT = \
# 01-sysfs \ # 01-sysfs \
@@ -131,42 +120,32 @@ install-rc:
install -d $(DESTDIR)$(RCDIR)/sysinit install -d $(DESTDIR)$(RCDIR)/sysinit
$(LN) $(RCSVDIR)/sysfs $(DESTDIR)$(RCDIR)/sysinit/01-sysfs $(LN) $(RCSVDIR)/pseudofs $(DESTDIR)$(RCDIR)/sysinit/01-pseudofs
$(LN) $(RCSVDIR)/procfs $(DESTDIR)$(RCDIR)/sysinit/02-procfs $(LN) $(RCSVDIR)/cgroups $(DESTDIR)$(RCDIR)/sysinit/02-cgroups
$(LN) $(RCSVDIR)/devfs $(DESTDIR)$(RCDIR)/sysinit/03-devfs $(LN) $(RCSVDIR)/kmod-static-nodes $(DESTDIR)$(RCDIR)/sysinit/03-kmod-static-nodes
$(LN) $(RCSVDIR)/cgroups $(DESTDIR)$(RCDIR)/sysinit/04-cgroups $(LN) $(RCSVDIR)/modules $(DESTDIR)$(RCDIR)/sysinit/04-modules
$(LN) $(RCSVDIR)/root $(DESTDIR)$(RCDIR)/sysinit/05-root $(LN) $(RCSVDIR)/tmpfiles-dev $(DESTDIR)$(RCDIR)/sysinit/05-tmpfiles-dev
$(LN) $(RCSVDIR)/hostname $(DESTDIR)$(RCDIR)/sysinit/10-hostname $(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/sysinit/06-udev
$(LN) $(RCSVDIR)/console-setup $(DESTDIR)$(RCDIR)/sysinit/10-console-setup
$(LN) $(RCSVDIR)/hwclock $(DESTDIR)$(RCDIR)/sysinit/15-hwclock $(LN) $(RCSVDIR)/hwclock $(DESTDIR)$(RCDIR)/sysinit/15-hwclock
$(LN) $(RCSVDIR)/kmod-static-nodes $(DESTDIR)$(RCDIR)/sysinit/20-kmod-static-nodes $(LN) $(RCSVDIR)/fsck $(DESTDIR)$(RCDIR)/sysinit/20-fsck
$(LN) $(RCSVDIR)/tmpfiles-dev $(DESTDIR)$(RCDIR)/sysinit/25-tmpfiles-dev $(LN) $(RCSVDIR)/mount-fs $(DESTDIR)$(RCDIR)/sysinit/30-mount-fs
$(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/sysinit/30-udev $(LN) $(RCSVDIR)/swap $(DESTDIR)$(RCDIR)/sysinit/31-swap
$(LN) $(RCSVDIR)/udev-trigger $(DESTDIR)$(RCDIR)/sysinit/31-udev-trigger $(LN) $(RCSVDIR)/random-seed $(DESTDIR)$(RCDIR)/sysinit/40-modules
$(LN) $(RCSVDIR)/modules $(DESTDIR)$(RCDIR)/sysinit/32-modules $(LN) $(RCSVDIR)/net-lo $(DESTDIR)$(RCDIR)/sysinit/41-net-lo
$(LN) $(RCSVDIR)/udev-settle $(DESTDIR)$(RCDIR)/sysinit/33-udev-settle $(LN) $(RCSVDIR)/hostname $(DESTDIR)$(RCDIR)/sysinit/42-hostname
$(LN) $(RCSVDIR)/console-setup $(DESTDIR)$(RCDIR)/sysinit/40-console-setup $(LN) $(RCSVDIR)/sysctl $(DESTDIR)$(RCDIR)/sysinit/55-sysctl
$(LN) $(RCSVDIR)/net-lo $(DESTDIR)$(RCDIR)/sysinit/45-net-lo $(LN) $(RCSVDIR)/binfmt $(DESTDIR)$(RCDIR)/sysinit/90-binfmt
$(LN) $(RCSVDIR)/misc $(DESTDIR)$(RCDIR)/sysinit/50-misc
$(LN) $(RCSVDIR)/remount-root $(DESTDIR)$(RCDIR)/sysinit/55-remount-root
$(LN) $(RCSVDIR)/mount-all $(DESTDIR)$(RCDIR)/sysinit/60-mount-all
$(LN) $(RCSVDIR)/swap $(DESTDIR)$(RCDIR)/sysinit/65-swap
$(LN) $(RCSVDIR)/random-seed $(DESTDIR)$(RCDIR)/sysinit/70-random-seed
$(LN) $(RCSVDIR)/tmpfiles-setup $(DESTDIR)$(RCDIR)/sysinit/75-tmpfiles-setup
$(LN) $(RCSVDIR)/sysusers $(DESTDIR)$(RCDIR)/sysinit/80-sysusers
$(LN) $(RCSVDIR)/dmesg $(DESTDIR)$(RCDIR)/sysinit/85-dmesg
$(LN) $(RCSVDIR)/sysctl $(DESTDIR)$(RCDIR)/sysinit/90-sysctl
$(LN) $(RCSVDIR)/binfmt $(DESTDIR)$(RCDIR)/sysinit/95-binfmt
$(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/sysinit/99-cleanup $(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/sysinit/99-cleanup
install -d $(DESTDIR)$(RCDIR)/shutdown install -d $(DESTDIR)$(RCDIR)/shutdown
$(LN) $(RCSVDIR)/random-seed $(DESTDIR)$(RCDIR)/shutdown/10-random-seed $(LN) $(RCSVDIR)/random-seed $(DESTDIR)$(RCDIR)/shutdown/10-random-seed
$(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/shutdown/20-cleanup $(LN) $(RCSVDIR)/hwclock $(DESTDIR)$(RCDIR)/shutdown/15-hwclock
$(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/shutdown/30-udev $(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/shutdown/30-udev
$(LN) $(RCSVDIR)/misc $(DESTDIR)$(RCDIR)/shutdown/40-misc $(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/shutdown/20-cleanup
$(LN) $(RCSVDIR)/swap $(DESTDIR)$(RCDIR)/shutdown/50-swap $(LN) $(RCSVDIR)/swap $(DESTDIR)$(RCDIR)/shutdown/50-swap
$(LN) $(RCSVDIR)/root $(DESTDIR)$(RCDIR)/shutdown/60-root $(LN) $(RCSVDIR)/mount-fs $(DESTDIR)$(RCDIR)/shutdown/60-mount-fs
$(LN) $(RCSVDIR)/remount-root $(DESTDIR)$(RCDIR)/shutdown/70-remount-root
install -d $(DESTDIR)$(MANDIR)/man8 install -d $(DESTDIR)$(MANDIR)/man8
install -m644 script/modules-load.8 $(DESTDIR)$(MANDIR)/man8 install -m644 script/modules-load.8 $(DESTDIR)$(MANDIR)/man8

View File

@@ -1,34 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
start_bootlogd(){
bootlogd -p /run/bootlogd.pid -l /var/log/boot.log || return 1
}
stop_bootlogd(){
[[ -f /run/bootlogd.pid ]] || return 0
touch /var/log/boot.log
kill $(< /run/bootlogd.pid)
rm -f /run/bootlogd.pid
}
case "$1" in
start)
stat_busy "Starting bootlogd"
start_bootlogd || stat_die bootlogd
add_daemon bootlogd
stat_done bootlogd
;;
stop)
stat_busy "Stopping bootlogd"
stop_bootlogd || stat_die bootlogd
rm_daemon bootlogd
stat_done bootlogd
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# sourcing our current rc.conf requires this to be a bash script sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions . @RCLIBDIR@/functions
. @RCDIR@/rc.conf . @RCDIR@/rc.conf
@@ -36,61 +36,7 @@ cgroup1_base(){
} }
cgroup1_controllers(){ cgroup1_controllers(){
${HAVE_CONTROLLER1_GROUPS} && [ -e /proc/cgroups ] && grep -qw cgroup /proc/filesystems || return 0 ...skipping...
while read -r name _ _ enabled _; do
case "${enabled}" in
1) if mountpoint -q "/sys/fs/cgroup/${name}";then continue;fi
local x
for x in $CGROUP_CONTROLLERS; do
[ "${name}" = "blkio" ] && [ "${x}" = "io" ] &&
continue 2
[ "${name}" = "${x}" ] &&
continue 2
done
mkdir "/sys/fs/cgroup/${name}"
mount -n -t cgroup -o "${CGROUP_OPTS},${name}" "${name}" "/sys/fs/cgroup/${name}"
;;
esac
done < /proc/cgroups
return 0
}
cgroup2_base(){
grep -qw cgroup2 /proc/filesystems || return 0
local base
base="$(cgroup2_find_path)"
mkdir -p "${base}"
mount -t cgroup2 none -o "${CGROUP_OPTS},nsdelegate" "${base}" 2> /dev/null ||
mount -t cgroup2 none -o "${CGROUP_OPTS}" "${base}"
return 0
}
cgroup2_controllers(){
grep -qw cgroup2 /proc/filesystems || return 0
local active cgroup_path x y
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 0
[ -e "${cgroup_path}/cgroup.controllers" ] && read -r active < "${cgroup_path}/cgroup.controllers"
for x in ${CGROUP_CONTROLLERS}; do
for y in ${active}; do
[ "$x" = "$y" ] && [ -e "${cgroup_path}/cgroup.subtree_control" ] &&
echo "+${x}" > "${cgroup_path}/cgroup.subtree_control"
done
done
return 0
}
cgroups_hybrid(){
cgroup1_base
cgroup2_base
cgroup2_controllers
cgroup1_controllers
return 0
}
cgroups_legacy(){
cgroup1_base
cgroup1_controllers
return 0 return 0
} }

View File

@@ -17,14 +17,20 @@ cleaning(){
case "$1" in case "$1" in
start) start)
stat_busy "Starting cleanup" stat_busy "Cleaning up"
cleaning cleaning
add_daemon cleanup add_daemon cleanup
stat_done stat_done
;; ;;
stop) stop)
stat_busy "Stopping cleanup" halt -w # Well, this actually does nothing.
halt -w || stat_die stat_busy "Sending TERM signal to processes"
pkill --inverse -s0,1 -TERM
sleep 1
stat_done
stat_busy "Sending KILL signal to processes"
pkill --inverse -s0,1 -KILL
sleep 1
rm_daemon cleanup rm_daemon cleanup
stat_done stat_done
;; ;;

View File

@@ -22,7 +22,7 @@ config(){
case "$1" in case "$1" in
start) start)
stat_busy "Starting console-setup" stat_busy "Setting up console fonts and keymaps"
config config
add_daemon console-setup add_daemon console-setup
stat_done stat_done
@@ -32,3 +32,4 @@ case "$1" in
exit 1 exit 1
;; ;;
esac esac

View File

@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
. @RCLIBDIR@/functions . @RCLIBDIR@/functions
do_unlock_device() { do_unlock_device() {
# $1 = requested name # $1 = requested name
# $2 = source device # $2 = source device
@@ -17,7 +16,7 @@ do_unlock_device() {
b=$1 b=$1
else else
printhl "Non-LUKS partitions are not supported at the moment." printhl "Non-LUKS partitions are not supported at the moment."
continue return 1
fi fi
if [[ $4 ]]; then if [[ $4 ]]; then
for i in ${4//,/ }; do for i in ${4//,/ }; do
@@ -29,9 +28,10 @@ do_unlock_device() {
"keyfile-offset"*) opts+="--keyfile-offset ${i##*=}" ;; "keyfile-offset"*) opts+="--keyfile-offset ${i##*=}" ;;
"key-slot"*) opts+="-S ${i##*=}" ;; "key-slot"*) opts+="-S ${i##*=}" ;;
*) *)
printhl "The option is not currently supported at the moment." printhl "The option '${i%%=*}' is not currently supported at the moment."
printhl "Partition '$2' cannot be unlocked."
printhl "Please add an issue to https://github.com/artix-linux/runit-rc" printhl "Please add an issue to https://github.com/artix-linux/runit-rc"
continue return 1
;; ;;
esac esac
done done
@@ -80,7 +80,6 @@ do_unlock() {
fi fi
do_unlock_device "$name" "$device" "$password" "$options" do_unlock_device "$name" "$device" "$password" "$options"
esac
failed=$? failed=$?
if (( $failed )); then if (( $failed )); then
printf "${C_FAIL}Unlocking of $1 failed.${C_CLEAR}\n" printf "${C_FAIL}Unlocking of $1 failed.${C_CLEAR}\n"
@@ -90,7 +89,9 @@ do_unlock() {
do_lock() { do_lock() {
#status "Detaching encrypted device ${1}" #status "Detaching encrypted device ${1}"
cryptsetup luksClose "$1" >/dev/null for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
[ ${v%%:*} = "0" ] && cryptsetup --debug close ${v##*:}
done
} }
read_crypttab() { read_crypttab() {
@@ -113,16 +114,24 @@ case "$1" in
stat_busy "Starting encrypted devices" stat_busy "Starting encrypted devices"
read_crypttab do_unlock read_crypttab do_unlock
rc=$? rc=$?
# [[ -f /run/sv.d/started/lvm2 ]] && vgchange --sysinit -a y >/dev/null
# Using the above, $? will return >0, which results in stat_die.
if [[ -f /run/sv.d/started/lvm2 ]]; then
vgchange --sysinit -a y >/dev/null vgchange --sysinit -a y >/dev/null
fi
(( rc || $? )) && stat_die (( rc || $? )) && stat_die
add_daemon cryptsetup add_daemon cryptsetup
stat_done stat_done
;; ;;
stop) stop)
stat_busy "Stopping encrypted devices" stat_busy "Stopping encrypted devices"
vgchange --sysinit -a n &>/dev/null #[[ -f /run/sv.d/started/lvm2 ]] && vgchange --sysinit -a n &>/dev/null
# Using the above, $? will return >0, which results in stat_die.
if [[ -f /run/sv.d/started/lvm2 ]]; then
vgchange --sysinit -a y >/dev/null
fi
rc=$? rc=$?
read_crypttab do_lock do_lock
(( rc || $? )) && stat_die (( rc || $? )) && stat_die
rm_daemon cryptsetup rm_daemon cryptsetup
stat_done stat_done

View File

@@ -1,25 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_devfs(){
mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid
mkdir -p /dev/{pts,shm}
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev
}
case "$1" in
start)
stat_busy "Mounting dev filesystem"
mount_devfs
add_daemon devfs
stat_done
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,26 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
config(){
if [[ -e /proc/sys/kernel/dmesg_restrict ]] &&
(( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then
install -Tm 0600 <( dmesg ) /var/log/dmesg.log
else
install -Tm 0644 <( dmesg ) /var/log/dmesg.log
fi
}
case "$1" in
start)
stat_busy "Saving dmesg log"
config
add_daemon dmesg
stat_done
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -1,9 +1,7 @@
#!/bin/bash #!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions . @RCLIBDIR@/functions
# Check local filesystems
fsck_all() { fsck_all() {
if [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline); then if [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline); then
FORCEFSCK="-f" FORCEFSCK="-f"
@@ -13,10 +11,9 @@ fsck_all() {
IGNORE_MOUNTED="-M" IGNORE_MOUNTED="-M"
fi fi
fsck -A -T -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} -- ${FORCEFSCK} fsck -A -T -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} ${FORCEFSCK}
} }
# Single-user login and/or automatic reboot after fsck (if needed)
fsck_reboot() { fsck_reboot() {
# $1 = exit code returned by fsck # $1 = exit code returned by fsck
# Ignore conditions 'FS errors corrected' and 'Cancelled by the user' # Ignore conditions 'FS errors corrected' and 'Cancelled by the user'
@@ -44,11 +41,10 @@ fsck_reboot() {
echo echo
sulogin -p sulogin -p
fi fi
echo "Automatic reboot in progress..." echo "Automatic reboot in progress"
umount -a umount -a
mount -o remount,ro / mount -o remount,ro /
reboot -f reboot -f
exit 0
} }
do_fsck() { do_fsck() {
@@ -61,27 +57,17 @@ do_fsck(){
fsck_reboot $fsckret fsck_reboot $fsckret
} }
kill_all(){
pkill --inverse -s0,1 -TERM
sleep 1
pkill --inverse -s0,1 -KILL
}
case "$1" in case "$1" in
start) start)
stat_busy "Remounting rootfs to read-only"
mount -o remount,ro /
stat_done
stat_busy "Checking filesystems" stat_busy "Checking filesystems"
do_fsck do_fsck
add_daemon misc add_daemon fsck
stat_done
;;
stop)
stat_busy "Running kill-all"
kill_all
rm_daemon misc
stat_done stat_done
;; ;;
*) *)
echo "usage: $0 {start|stop}" echo "usage: $0 {start}"
exit 1
;; ;;
esac esac

View File

@@ -9,16 +9,15 @@ config(){
if [[ -s /etc/hostname ]]; then if [[ -s /etc/hostname ]]; then
HOSTNAME=$(< /etc/hostname) HOSTNAME=$(< /etc/hostname)
fi fi
if [[ $HOSTNAME ]]; then
echo "$HOSTNAME" >| /proc/sys/kernel/hostname
fi
} }
case "$1" in case "$1" in
start) start)
stat_busy "Starting hostname"
config config
stat_busy "Setting hostname to $HOSTNAME"
if [[ $HOSTNAME ]]; then
echo "$HOSTNAME" >| /proc/sys/kernel/hostname
fi
add_daemon hostname add_daemon hostname
stat_done stat_done
;; ;;

View File

@@ -13,13 +13,13 @@ esac
case "$1" in case "$1" in
start) start)
stat_busy "Adjusting hwclock" stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
hwclock $HWCLOCK_PARAMS || stat_die hwclock $HWCLOCK_PARAMS || stat_die
add_daemon hwclock add_daemon hwclock
stat_done stat_done
;; ;;
stop) stop)
stat_busy "Adjusting hwclock" stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
hwclock --adjust $HWCLOCK_PARAMS || stat_die hwclock --adjust $HWCLOCK_PARAMS || stat_die
rm_daemon hwclock rm_daemon hwclock
stat_done stat_done
@@ -33,4 +33,3 @@ case "$1" in
echo "usage: $0 {start|stop|restart}" echo "usage: $0 {start|stop|restart}"
;; ;;
esac esac

View File

@@ -3,15 +3,16 @@
# sourcing our current rc.conf requires this to be a bash script # sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions . @RCLIBDIR@/functions
conig(){ config() {
[[ -d /run/tmpfiles.d ]] || mkdir /run/tmpfiles.d for f in $(kmod static-nodes 2>/dev/null|awk '/Module/ {print $2}'); do
kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf modprobe -bq $f 2>/dev/null
done
} }
case "$1" in case "$1" in
start) start)
stat_busy "Starting kmod-static-nodes" stat_busy "Loading static kernel modules"
conig config
add_daemon kmod-static-nodes add_daemon kmod-static-nodes
stat_done stat_done
;; ;;

View File

@@ -1,22 +0,0 @@
#!/bin/bash
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Starting monitoring of LVM2 groups"
vgchange --monitor y >/dev/null || stat_die
add_daemon lvm-monitoring
stat_done
;;
stop)
stat_busy "Stopping monitoring of LVM2 groups"
vgchange --monitor n || stat_die
rm_daemon lvm-monitoring
stat_done
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -1,22 +0,0 @@
#!/bin/bash
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Starting LVM2 groups"
vgchange --sysinit -a y >/dev/null || stat_die
add_daemon lvm
stat_done
;;
stop)
stat_busy "Stopping LVM2 groups"
vgchange --sysinit -a n &>/dev/null || stat_die
rm_daemon lvm
stat_done
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -5,7 +5,6 @@
load_modules() { load_modules() {
local rc=0 local rc=0
/usr/bin/modules-load /usr/bin/modules-load
(( rc+= $? )) (( rc+= $? ))
@@ -24,4 +23,3 @@ case "$1" in
exit 1 exit 1
;; ;;
esac esac

View File

@@ -1,17 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Starting mount-all"
mount -a -t "no${NETFS//,/,no}" -O no_netdev || stat_die mount-all
add_daemon mount-all
stat_done mount-all
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

27
sv.d/mount-fs.in Normal file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Mounting / read-write"
mount -o remount,rw / || stat_die mount-fs
stat_done
stat_busy "Mounting all non-network filesystems"
mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || stat_die mount-fs
add_daemon mount-fs
stat_done
;;
stop)
stat_busy "Unmounting filesystems"
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
stat_done
stat_busy "Remounting / read-only"
mount -o remount,ro /
stat_done
sync
;;
*)
echo "usage: $0 {start|stop}"
;;
esac

View File

@@ -5,7 +5,7 @@
case "$1" in case "$1" in
start) start)
stat_busy "Starting net-lo" stat_busy "Setting up loopback interface"
ip link set up dev lo || stat_die ip link set up dev lo || stat_die
add_daemon net-lo add_daemon net-lo
stat_done stat_done

View File

@@ -1,34 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Mounting network filesystems"
mount -a -t "$NETFS"
rc=$?
mount -a -O _netdev
(( rc || $? )) && stat_die
add_daemon netfs
stat_done
;;
stop)
stat_busy "Unmounting network filesystems"
umount -a -f -O _netdev
rc=$?
umount -a -f -t "$NETFS"
(( rc || $? )) && stat_die
rm_daemon netfs
stat_done
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@@ -1,21 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_procfs(){
mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
}
case "$1" in
start)
stat_busy "Mounting proc filesystem"
mount_procfs
add_daemon procfs
stat_done
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

50
sv.d/pseudofs.in Normal file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_procfs(){
mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
}
mount_sysfs() {
mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
if [ -d /sys/firmware/efi ]; then
mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars
fi
}
mount_runfs() {
mountpoint -q /run || mount -o mode=0755,nosuid,nodev -t tmpfs run /run
mkdir -p /run/{runit,lvm,user,lock,log}
}
mount_devfs() {
mountpoint -q /dev || mount -o mode=0755,nosuid -t devtmpfs dev /dev
mkdir -p -m0755 /dev/{pts,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
}
case "$1" in
start)
stat_busy "Mounting proc filesystem"
mount_procfs
stat_done
stat_busy "Mounting sys filesystem"
mount_sysfs
stat_done
stat_busy "Mounting run filesystem"
mount_runfs
stat_done
stat_busy "Mounting devfs"
mount_devfs
stat_done
add_daemon pseudofs
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -14,13 +14,13 @@ save_seed(){
case "$1" in case "$1" in
start) start)
stat_busy "Starting random-seed" stat_busy "Initializing random seed"
load_seed load_seed
add_daemon random-seed add_daemon random-seed
stat_done stat_done
;; ;;
stop) stop)
stat_busy "Stopping random-seed" stat_busy "Saving random seed"
save_seed save_seed
rm_daemon random-seed rm_daemon random-seed
stat_done stat_done

View File

@@ -1,24 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Remounting root filesystem rw"
mount -o remount,rw / || stat_die remount-root
add_daemon remount-root
stat_done remount-root
;;
stop)
stat_busy "Remounting root filesystem ro"
mount -o remount,ro / || stat_die remount-root
sync
rm_daemon remount-root
stat_done remount-root
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -1,63 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_fs(){
findmnt / --options ro &>/dev/null || mount -o remount,ro / || return 1
return 0
}
# umount_fs(){
# umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
# }
umount_fs() {
findmnt -mrunRo TARGET,FSTYPE,OPTIONS / | {
while read -r target fstype options; do
# interpret the ascii chars, such as \x20 (space)
printf -v target '%b' "$target"
# match only targeted fstypes
if [[ $1 && $1 != "$fstype" ]]; then
continue
fi
# do not unmount API filesystems
if [[ $target = /@(proc|sys|run|dev|dev/pts) ]]; then
continue
fi
# avoid networked devices
IFS=, read -ra opts <<< "$options"
if in_array _netdev "${opts[@]}"; then
continue
fi
mounts=("$target" "${mounts[@]}")
done
if (( ${#mounts[*]} )); then
umount -r "${mounts[@]}" || return 1
fi
return 0
}
}
case "$1" in
start)
stat_busy "Mounting filesystems"
mount_fs || stat_die root
add_daemon root
stat_done root
;;
stop)
stat_busy "Unounting filesystems"
umount_fs || stat_die root
rm_daemon root
stat_done root
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -12,7 +12,7 @@ case "$1" in
;; ;;
stop) stop)
stat_busy "Deactivating swap" stat_busy "Deactivating swap"
swapoff -a || stat_die swap swapoff -a
rm_daemon swap rm_daemon swap
stat_done swap stat_done swap
;; ;;

View File

@@ -1,23 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_sysfs(){
mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
[ -d /sys/firmware/efi ] && (mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
}
case "$1" in
start)
stat_busy "Mounting sys filesystem"
mount_sysfs
add_daemon sysfs
stat_done
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,17 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Starting sysusers"
sysusers
add_daemon sysusers
stat_done
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,35 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Setting timezone"
zonefile=/usr/share/zoneinfo/$TIMEZONE
# [[ $TIMEZONE ]] || return 1
if [[ ! -L /etc/localtime && /etc/localtime -ef $zonefile ]]; then
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
add_daemon timezone
stat_done
;;
stop)
stat_busy "Setting timezone"
zonefile=/usr/share/zoneinfo/$TIMEZONE
# [[ $TIMEZONE ]] || return 1
if [[ ! -L /etc/localtime && /etc/localtime -ef $zonefile ]]; then
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
rm_daemon timezone
stat_done
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -1,17 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Starting tmpfiles-setup"
tmpfiles --exclude-prefix=/dev --create --remove --boot || stat_die tmpfiles-setup
add_daemon tmpfiles-setup
stat_done tmpfiles-setup
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,19 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Waiting for udev uevents to be processed"
udevadm settle || stat_die udev-settle
calc_columns
add_daemon udev-settle
stat_done udev-settle
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,21 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Triggering udev uevents"
udevadm trigger --action=add --type=subsystems
ret=$?
udevadm trigger --action=add --type=devices
(( ret || $? )) && stat_die udev-trigger
add_daemon udev-trigger
stat_done udev-trigger
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -5,15 +5,15 @@
case "$1" in case "$1" in
start) start)
# check if runit already runs udevd if ! pgrep -f "runsv udevd" >/dev/null; then
if ! pgrep -f "runsv udevd" >/dev/null 2>&1; then stat_busy "Starting udev and waiting for devices to settle"
stat_busy "Starting udev daemon" udevd --daemon
udevd --daemon || stat_die udev udevadm trigger --action=add --type=subsystems
# Note: This is only needed for initialization, udev will udevadm trigger --action=add --type=devices
# be controlled by runit on stage 2. udevadm settle
add_daemon udev stat_done
stat_done udev
fi fi
add_daemon udev
;; ;;
stop) stop)
stat_busy "Stopping udev" stat_busy "Stopping udev"
@@ -26,4 +26,3 @@ case "$1" in
exit 1 exit 1
;; ;;
esac esac