2 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
6cc8c4288f Check if udev is already run in stage2 by runit 2018-12-27 20:48:25 +07:00
35 changed files with 188 additions and 652 deletions

View File

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

View File

@@ -6,7 +6,6 @@
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
. /etc/profile.d/locale.sh
. @RCDIR@/rc.conf
# width:
calc_columns () {
@@ -61,14 +60,6 @@ stat_busy() {
printf " ${C_OTHER}[${C_BUSY}busy${C_OTHER}]${C_CLEAR} "
}
substat() {
printf " ${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} \n"
}
ck_verbose() {
[[ "$VERBOSE" == "on" ]]
}
ck_daemon() {
[[ ! -f @RCRUNDIR@/started/$1 ]]
}

View File

@@ -26,8 +26,3 @@
# /sys/fs/cgroup in hybrid or legacy mode
# HAVE_CONTROLLER1_GROUPS="true"
# Verbose mode
# Set to "on" to enable details
# VERBOSE="off"

View File

@@ -12,7 +12,6 @@ mount_binfmt(){
[[ -z "$(ls $path)" ]] && continue
grep "^:" $path/* | \
while read -r line; do
ck_verbose && substat "Registering $line"
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || return 1
done
done

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,7 +1,8 @@
#!/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
. @RCDIR@/rc.conf
CGROUP_OPTS=nodev,noexec,nosuid
HAVE_CONTROLLER1_GROUPS=${HAVE_CONTROLLER1_GROUPS:-true}
@@ -35,61 +36,7 @@ cgroup1_base(){
}
cgroup1_controllers(){
${HAVE_CONTROLLER1_GROUPS} && [ -e /proc/cgroups ] && grep -qw cgroup /proc/filesystems || return 0
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
...skipping...
return 0
}

View File

@@ -5,30 +5,32 @@
cleaning(){
install -m0664 -o root -g utmp /dev/null /run/utmp
ck_verbose && substat "Created /run/utmp"
if [ ! -e /var/log/wtmp ]; then
install -m0664 -o root -g utmp /dev/null /var/log/wtmp
ck_verbose && substat "Created /var/log/wtmp"
fi
if [ ! -e /var/log/btmp ]; then
install -m0600 -o root -g utmp /dev/null /var/log/btmp
ck_verbose && substat "Created /var/log/btmp"
fi
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
ck_verbose && substat "Removed /etc/nologin, /forcefsck, /forcequotacheck, /fastboot"
}
case "$1" in
start)
stat_busy "Starting cleanup"
stat_busy "Cleaning up"
cleaning
add_daemon cleanup
stat_done
;;
stop)
stat_busy "Stopping cleanup"
halt -w || stat_die
halt -w # Well, this actually does nothing.
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
stat_done
;;

View File

@@ -7,7 +7,6 @@ config(){
[ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
TTYS=${TTYS:-6}
_index=0
ck_verbose && [ -n "$FONT" ] && substat "Setting font to ${FONT}"
while [ ${_index} -le $TTYS ]; do
if [ -n "$FONT" ]; then
setfont ${FONT_MAP:+-m $FONT_MAP} ${FONT_UNIMAP:+-u $FONT_UNIMAP} \
@@ -17,14 +16,13 @@ config(){
_index=$((_index + 1))
done
if [ -n "$KEYMAP" ]; then
ck_verbose && substat "Setting keymap to ${KEYMAP}"
loadkeys -q -u ${KEYMAP}
fi
}
case "$1" in
start)
stat_busy "Starting console-setup"
stat_busy "Setting up console fonts and keymaps"
config
add_daemon console-setup
stat_done
@@ -34,3 +32,4 @@ case "$1" in
exit 1
;;
esac

View File

@@ -1,7 +1,6 @@
#!/bin/bash
. @RCLIBDIR@/functions
do_unlock_device() {
# $1 = requested name
# $2 = source device
@@ -17,7 +16,7 @@ do_unlock_device() {
b=$1
else
printhl "Non-LUKS partitions are not supported at the moment."
continue
return 1
fi
if [[ $4 ]]; then
for i in ${4//,/ }; do
@@ -29,9 +28,10 @@ do_unlock_device() {
"keyfile-offset"*) opts+="--keyfile-offset ${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"
continue
return 1
;;
esac
done
@@ -72,7 +72,7 @@ do_unlock_device() {
do_unlock() {
local name=$1 device=$2 password=$3 options=$4
substat "Unlocking $1"
printf "${C_MAIN}Unlocking $1${C_CLEAR}\n"
if [[ ${options:0:2} =~ -. ]]; then
do_unlock_device "$name" "$device" "$password" "$options"
@@ -89,7 +89,9 @@ do_unlock() {
do_lock() {
#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() {
@@ -112,16 +114,24 @@ case "$1" in
stat_busy "Starting encrypted devices"
read_crypttab do_unlock
rc=$?
vgchange --sysinit -a y >/dev/null
# [[ -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
fi
(( rc || $? )) && stat_die
add_daemon cryptsetup
stat_done
;;
stop)
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=$?
read_crypttab do_lock
do_lock
(( rc || $? )) && stat_die
rm_daemon cryptsetup
stat_done

View File

@@ -1,29 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_devfs(){
ck_verbose && substat "Mounting /dev"
mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid
mkdir -p /dev/{pts,shm}
ck_verbose && substat "Mounting /dev/pts"
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
ck_verbose && substat "Mounting /dev/shm"
mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
ck_verbose && substat "Mounting /run"
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,28 +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
ck_verbose && substat "dmesg_restrict is enabled"
ck_verbose && substat "dmesg log can only be read by root"
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,25 +1,19 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
# Check local filesystems
fsck_all() {
if [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline); then
ck_verbose && substat "/forcefsck found, forcing fsck"
FORCEFSCK="-f"
elif [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); then
ck_verbose && substat "/fastboot found, canceling fsck"
return 0
elif [[ -e /run/initramfs/root-fsck ]]; then
ck_verbose && substat "Ignoring mounted filesystems in fsck"
IGNORE_MOUNTED="-M"
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() {
# $1 = exit code returned by fsck
# Ignore conditions 'FS errors corrected' and 'Cancelled by the user'
@@ -51,10 +45,9 @@ fsck_reboot() {
umount -a
mount -o remount,ro /
reboot -f
exit 0
}
do_fsck(){
do_fsck() {
if [[ -x $(type -P fsck) ]]; then
fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
declare -r fsckret=$?
@@ -64,29 +57,17 @@ do_fsck(){
fsck_reboot $fsckret
}
kill_all(){
ck_verbose && substat "Killing processes using SIGTERM"
pkill --inverse -s0,1 -TERM
sleep 1
ck_verbose && substat "Killing processes using SIGKILL"
pkill --inverse -s0,1 -KILL
}
case "$1" in
start)
stat_busy "Remounting rootfs to read-only"
mount -o remount,ro /
stat_done
stat_busy "Checking filesystems"
do_fsck
add_daemon misc
add_daemon fsck
stat_done
;;
stop)
stat_busy "Running kill-all"
kill_all
rm_daemon misc
stat_done
;;
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
echo "usage: $0 {start}"
;;
esac

View File

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

View File

@@ -33,4 +33,3 @@ case "$1" in
echo "usage: $0 {start|stop|restart}"
;;
esac

View File

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

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

@@ -4,12 +4,11 @@
. @RCLIBDIR@/functions
load_modules() {
local rc=0
local rc=0
/usr/bin/modules-load
(( rc+= $? ))
/usr/bin/modules-load
(( rc+=$? ))
return $rc
return $rc
}
case "$1" in
@@ -24,4 +23,3 @@ case "$1" in
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
ck_verbose && MOUNT_VERBOSE="-v"
case "$1" in
start)
stat_busy "Starting mount-all"
mount -a "${MOUNT_VERBOSE}" -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

@@ -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
start)
stat_busy "Starting random-seed"
stat_busy "Initializing random seed"
load_seed
add_daemon random-seed
stat_done
;;
stop)
stat_busy "Stopping random-seed"
stat_busy "Saving random seed"
save_seed
rm_daemon random-seed
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,71 +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
# There are differences between verbose and non-verbose method
# because iterating the array is considerably slower than the
# non-verbose method
if (( ${#mounts[*]} )) && ck_verbose; then
for ((i=0; i<${#mounts[*]}; i++)); do
substat "Unmounting ${mounts[i]}"
umount -r "${mounts[i]}" || return 1
done
elif (( ${#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

@@ -3,21 +3,19 @@
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
ck_verbose && SWAP_VERBOSE="-v"
case "$1" in
start)
stat_busy "Activating swap"
swapon -a "${SWAP_VERBOSE}" || stat_die swap
swapon -a || stat_die swap
add_daemon swap
stat_done swap
;;
;;
stop)
stat_busy "Deactivating swap"
swapoff -a "${SWAP_VERBOSE}" || stat_die swap
swapoff -a
rm_daemon swap
stat_done swap
;;
;;
*)
echo "usage: $0 {start|stop}"
exit 1

View File

@@ -3,12 +3,10 @@
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
! ck_verbose && QUIET="-q"
case "$1" in
start)
stat_busy "Loading sysctl settings"
sysctl "$QUIET" --system || stat_die sysctl
sysctl --system || stat_die sysctl
add_daemon sysctl
stat_done sysctl
;;

View File

@@ -1,28 +0,0 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_sysfs(){
ck_verbose && substat "Mounting /sys"
mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
ck_verbose && substat "Mounting /sys/kernel/security"
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
if [ -d /sys/firmware/efi ]; then
ck_verbose && substat "Mounting /sys/firmware/efi"
(mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
fi
}
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,20 +5,24 @@
case "$1" in
start)
stat_busy "Starting udev daemon"
udevd --daemon || stat_die udev
if ! pgrep -f "runsv udevd" >/dev/null; then
stat_busy "Starting udev and waiting for devices to settle"
udevd --daemon
udevadm trigger --action=add --type=subsystems
udevadm trigger --action=add --type=devices
udevadm settle
stat_done
fi
add_daemon udev
stat_done udev
;;
;;
stop)
stat_busy "Stopping udev"
udevadm control --exit || stat_die udev
rm_daemon udev
stat_done udev
;;
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
;;
esac