16 Commits

Author SHA1 Message Date
nikolar
e0c4e306e4 Add binfmt.d from artix-cgroups 2024-04-30 16:33:05 +02:00
nikolar
69fa6e4394 Migrate to artix-cgroups 2024-04-30 16:32:55 +02:00
Nikola
2530c4aadd Change default for cgroups to unified (cgroups2). 2024-04-15 11:46:36 +02:00
Qontinuum
5d00408a16 Edit procfs.in
Make procfs respect options in fstab
Remove nosuid,noexec,nodev mount options since they are not support by
procfs anyway
2023-11-01 14:08:58 +01:00
Qontinuum
26fa40633d Move to new Artix sysusers/tmpfiles binary names 2023-08-18 18:51:47 +02:00
fab1c43983 add /tmp cleanup 2021-05-14 11:48:42 +07:00
9f6718f5de hwclock: read from rc.conf 2021-01-22 08:46:50 +07:00
c0c2ab41a8 devfs: add symlinks and needed files if not exist yet 2020-09-15 11:01:24 +07:00
4be15079e2 binfmt: add an option to run it once without adding it to running daemons 2020-08-25 07:55:32 +07:00
Martin Castillo
2314c2630f udev.in: stop: only try to stop udevd when it's running
Since udevd is now started again in stage 2 and stopped by
runsvdir on shutdown, we only try to stop it with udevadm,
if there is an instance running.  This might be the case if
something went wrong and stage 2 couldn't start udevd for some
reason, so the instance from stage 1 wasn't terminated.

When starting udevd in stage 1, runsvdir isn't running yet, so
there is no need to check for already running instances.
2020-04-04 14:50:39 +07:00
Martin Castillo
38c52b18dc binfmt.in: fix grep invocation
If any directory has more than one file, grep prefixes matching lines with
the filenames. -h suppresses that.
2020-03-09 07:56:55 +07:00
cbbed45ce3 fix hwclock command 2019-11-06 19:46:41 +07:00
667dee6b9c fix hwclock 2019-11-06 09:18:56 +07:00
dudemanguy
451fe75e69 use "-T linux" if $TERM is dumb or empty 2019-09-13 11:50:13 +07:00
a6df81b8fb Remove rc script for netfs
Since network services are started on stage 2, I'm going to delete this.
A replacement runit service will be added in the future.
2019-02-12 21:20:53 +07:00
1df9ca6564 Do not check for mounted fs 2019-02-12 21:19:44 +07:00
37 changed files with 611 additions and 263 deletions

View File

@@ -16,23 +16,34 @@ RCBIN = \
script/modules-load
RCSVD = \
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
sv.d/root \
sv.d/binfmt \
sv.d/binfmt.d \
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/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
# SYSINIT = \
# 01-sysfs \
@@ -120,32 +131,44 @@ install-rc:
install -d $(DESTDIR)$(RCDIR)/sysinit
$(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)/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)/hwclock $(DESTDIR)$(RCDIR)/sysinit/15-hwclock
$(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)/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)/binfmt.d $(DESTDIR)$(RCDIR)/sysinit/97-binfmt.d
$(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)/hwclock $(DESTDIR)$(RCDIR)/shutdown/15-hwclock
$(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/shutdown/30-udev
$(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/shutdown/20-cleanup
$(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/shutdown/30-udev
$(LN) $(RCSVDIR)/hwclock $(DESTDIR)$(RCDIR)/shutdown/35-hwclock
$(LN) $(RCSVDIR)/misc $(DESTDIR)$(RCDIR)/shutdown/40-misc
$(LN) $(RCSVDIR)/swap $(DESTDIR)$(RCDIR)/shutdown/50-swap
$(LN) $(RCSVDIR)/mount-fs $(DESTDIR)$(RCDIR)/shutdown/60-mount-fs
$(LN) $(RCSVDIR)/root $(DESTDIR)$(RCDIR)/shutdown/60-root
$(LN) $(RCSVDIR)/remount-root $(DESTDIR)$(RCDIR)/shutdown/70-remount-root
install -d $(DESTDIR)$(MANDIR)/man8
install -m644 script/modules-load.8 $(DESTDIR)$(MANDIR)/man8

View File

@@ -1,18 +1,18 @@
#!/bin/bash
# This is run by the kernel after the last task is removed from a
# control group in the openrc hierarchy.
# control group in the artix hierarchy.
# Copyright (c) 2007-2015 The OpenRC Authors.
# See the Authors file at the top-level directory of this distribution and
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
# https://github.com/OpenRC/artix/blob/master/AUTHORS
#
# This file is part of OpenRC. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
# distribution and at https://github.com/OpenRC/artix/blob/master/LICENSE
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
cgroup=/sys/fs/cgroup/openrc
cgroup=/sys/fs/cgroup/artix
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ -d ${cgroup}/"$1" ]; then
rmdir ${cgroup}/"$1"

View File

@@ -201,7 +201,11 @@ run_shutdown(){
calc_columns
# disable colors on broken terminals
TERM_COLORS=$(tput colors 2>/dev/null)
if [[ -z "$TERM" || "$TERM" = "dumb" ]]; then
TERM_COLORS=$(tput colors -T linux 2>/dev/null)
else
TERM_COLORS=$(tput colors 2>/dev/null)
fi
if (( $? != 3 )); then
case $TERM_COLORS in
*[!0-9]*) USECOLOR="";;

View File

@@ -13,7 +13,7 @@
# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and
# cgroups version 1 on /sys/fs/cgroup
# CGROUP_MODE="hybrid"
# CGROUP_MODE="unified"
# This is a list of controllers which should be enabled for cgroups version 2.
# If hybrid mode is being used, controllers listed here will not be
@@ -26,3 +26,9 @@
# /sys/fs/cgroup in hybrid or legacy mode
# HAVE_CONTROLLER1_GROUPS="true"
# This switch controls whether or not /tmp will be cleaned.
# /tmp will only be cleaned if it is set to "y". Generally it is recommended to
# mount /tmp as tmpfs.
# CLEANTMP="n"

17
sv.d/binfmt.d.in Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
case "$1" in
start)
stat_busy "Running binfmt.d"
/usr/lib/artix/binfmt.sh || stat_die binfmt.d
add_daemon binfmt.d
stat_done binfmt.d
;;
*)
echo "usage: $0 {start|once}"
exit 1
;;
esac

View File

@@ -7,10 +7,16 @@ mount_binfmt(){
mountpoint -q /proc/sys/fs/binfmt_misc || \
mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc || return 1
for files in /proc/sys/fs/binfmt_misc/*; do
[ "$files" = /proc/sys/fs/binfmt_misc/register ] && continue
[ "$files" = /proc/sys/fs/binfmt_misc/status ] && continue
echo -1 > "$files"
done
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
[[ ! -d $path ]] && continue
[[ -z "$(ls $path)" ]] && continue
grep "^:" $path/* | \
grep -h "^:" $path/* | \
while read -r line; do
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || return 1
done
@@ -27,8 +33,13 @@ case "$1" in
add_daemon binfmt
stat_done binfmt
;;
once)
stat_busy "Running binfmt"
mount_binfmt || stat_die binfmt
stat_done
;;
*)
echo "usage: $0 {start}"
echo "usage: $0 {start|once}"
exit 1
;;
esac

34
sv.d/bootlogd.in Normal file
View File

@@ -0,0 +1,34 @@
#!/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,72 +1,12 @@
#!/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}
CGROUP_MODE=${CGROUP_MODE:-hybrid}
CGROUP_CONTROLLERS=""
cgroup2_find_path(){
if grep -qw cgroup2 /proc/filesystems; then
case "${CGROUP_MODE}" in
hybrid) printf "/sys/fs/cgroup/unified" ;;
unified) printf "/sys/fs/cgroup" ;;
esac
fi
return 0
}
cgroup1_base(){
grep -qw cgroup /proc/filesystems || return 0
if ! mountpoint -q /sys/fs/cgroup; then
local opts="${CGROUP_OPTS},mode=755,size=${rc_cgroupsize:-10m}"
mount -n -t tmpfs -o "${opts}" cgroup_root /sys/fs/cgroup
fi
if ! mountpoint -q /sys/fs/cgroup/openrc; then
local agent="@RCLIBDIR@/cgroup-release-agent"
mkdir /sys/fs/cgroup/openrc
mount -n -t cgroup -o none,${CGROUP_OPTS},name=openrc,release_agent="$agent" openrc /sys/fs/cgroup/openrc
printf 1 > /sys/fs/cgroup/openrc/notify_on_release
fi
return 0
}
cgroup1_controllers(){
...skipping...
return 0
}
cgroups_unified(){
cgroup2_base
cgroup2_controllers
return 0
}
mount_cgroups(){
case "${CGROUP_MODE}" in
hybrid) cgroups_hybrid ;;
legacy) cgroups_legacy ;;
unified) cgroups_unified ;;
esac
return 0
}
mount_cgs(){
if [ -d /sys/fs/cgroup ];then
mount_cgroups
return 0
fi
return 1
}
case "$1" in
start)
stat_busy "Mounting cgroups filesystem"
mount_cgs || stat_die cgroups
/usr/lib/artix/mount-cgroups.sh|| stat_die cgroups
add_daemon cgroups
stat_done cgroups
;;

View File

@@ -2,6 +2,7 @@
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
. @RCDIR@/rc.conf
cleaning(){
install -m0664 -o root -g utmp /dev/null /run/utmp
@@ -13,24 +14,20 @@ cleaning(){
fi
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
[ "$CLEANTMP" = y ] && rm -rf /tmp/*
}
case "$1" in
start)
stat_busy "Cleaning up"
stat_busy "Starting cleanup"
cleaning
add_daemon cleanup
stat_done
;;
stop)
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
stat_busy "Stopping cleanup"
halt -w || stat_die
rm_daemon cleanup
stat_done
;;

View File

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

View File

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

49
sv.d/devfs.in Normal file
View File

@@ -0,0 +1,49 @@
#!/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
# seed /dev with some things that might be needed (for example,
# xudev doesn't do this compared to eudev), code from OpenRC
# creating /dev/console, /dev/tty and /dev/tty1 to be able to write
# to $CONSOLE with/without bootsplash before udevd creates it
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
[ -c /dev/tty1 ] || mknod -m 620 /dev/tty1 c 4 1
[ -c /dev/tty ] || mknod -m 666 /dev/tty c 5 0
# udevd will dup its stdin/stdout/stderr to /dev/null
# and we do not want a file which gets buffered in ram
[ -c /dev/null ] || mknod -m 666 /dev/null c 1 3
# so udev can add its start-message to dmesg
[ -c /dev/kmsg ] || mknod -m 660 /dev/kmsg c 1 11
# extra symbolic links not provided by default
[ -e /dev/fd ] || ln -snf /proc/self/fd /dev/fd
[ -e /dev/stdin ] || ln -snf /proc/self/fd/0 /dev/stdin
[ -e /dev/stdout ] || ln -snf /proc/self/fd/1 /dev/stdout
[ -e /dev/stderr ] || ln -snf /proc/self/fd/2 /dev/stderr
[ -e /proc/kcore ] && ln -snf /proc/kcore /dev/core
mkdir -p /dev/pts /dev/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

26
sv.d/dmesg.in Normal file
View File

@@ -0,0 +1,26 @@
#!/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

@@ -9,15 +9,16 @@ 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 "Starting 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

@@ -1,26 +1,26 @@
#!/bin/bash
. @RCLIBDIR@/functions
. @RCDIR@/rc.conf
HWCLOCK_PARAMS="--systz"
HARDWARECLOCK=${HARDWARECLOCK:-UTC}
case $HARDWARECLOCK in
UTC) HWCLOCK_PARAMS+=" --utc --noadjfile" ;;
localtime) HWCLOCK_PARAMS+=" --localtime --noadjfile" ;;
UTC) HWCLOCK_PARAMS+=" --utc" ;;
localtime) HWCLOCK_PARAMS+=" --localtime" ;;
*) HWCLOCK_PARAMS="";;
esac
case "$1" in
start)
stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
hwclock $HWCLOCK_PARAMS || stat_die
stat_busy "Adjusting hwclock"
hwclock --systz $HWCLOCK_PARAMS --noadjfile || stat_die
add_daemon hwclock
stat_done
;;
stop)
stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
hwclock --adjust $HWCLOCK_PARAMS || stat_die
stat_busy "Adjusting hwclock"
hwclock --systohc $HWCLOCK_PARAMS || stat_die
rm_daemon hwclock
stat_done
;;
@@ -33,3 +33,4 @@ case "$1" in
echo "usage: $0 {start|stop|restart}"
;;
esac

View File

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

22
sv.d/lvm-monitoring.in Normal file
View File

@@ -0,0 +1,22 @@
#!/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

22
sv.d/lvm.in Normal file
View File

@@ -0,0 +1,22 @@
#!/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

@@ -1,7 +1,9 @@
#!/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
FORCEFSCK="-f"
@@ -11,9 +13,10 @@ fsck_all() {
IGNORE_MOUNTED="-M"
fi
fsck -A -T -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} ${FORCEFSCK}
fsck -A -T -M -C${FSCK_FD} -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'
@@ -41,13 +44,14 @@ fsck_reboot() {
echo
sulogin -p
fi
echo "Automatic reboot in progress"
echo "Automatic reboot in progress..."
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=$?
@@ -57,17 +61,27 @@ do_fsck() {
fsck_reboot $fsckret
}
kill_all(){
pkill --inverse -s0,1 -TERM
sleep 1
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 fsck
add_daemon misc
stat_done
;;
;;
stop)
stat_busy "Running kill-all"
kill_all
rm_daemon misc
stat_done
;;
*)
echo "usage: $0 {start}"
;;
echo "usage: $0 {start|stop}"
exit 1
;;
esac

View File

@@ -4,11 +4,12 @@
. @RCLIBDIR@/functions
load_modules() {
local rc=0
/usr/bin/modules-load
(( rc+= $? ))
local rc=0
return $rc
/usr/bin/modules-load
(( rc+=$? ))
return $rc
}
case "$1" in
@@ -23,3 +24,4 @@ case "$1" in
exit 1
;;
esac

17
sv.d/mount-all.in Normal file
View File

@@ -0,0 +1,17 @@
#!/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

View File

@@ -1,27 +0,0 @@
#!/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
start)
stat_busy "Setting up loopback interface"
stat_busy "Starting net-lo"
ip link set up dev lo || stat_die
add_daemon net-lo
stat_done

32
sv.d/procfs.in Normal file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# sourcing our current rc.conf requires this to be a bash script
. @RCLIBDIR@/functions
mount_procfs(){
grep -v '^#' /etc/fstab | grep /proc | {
read -r spec file vfstype mntopts x
if ! mountpoint -q /proc; then
if [ "$spec" -a "$file" -a "$vfstype" -a "$mntopts" ]; then
mount -t "$vfstype" "$spec" "$file" -o "$mntopts"
else
mount -t proc proc /proc
fi
elif [ "$spec" -a "$file" -a "$vfstype" -a "$mntopts" ] && mountpoint -q /proc; then
mount -t "$vfstype" "$spec" "$file" -o "remount,$mntopts"
fi
}
}
case "$1" in
start)
stat_busy "Mounting proc filesystem"
mount_procfs
add_daemon procfs
stat_done
;;
*)
echo "usage: $0 {start}"
exit 1
;;
esac

View File

@@ -1,50 +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
}
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 "Initializing random seed"
stat_busy "Starting random-seed"
load_seed
add_daemon random-seed
stat_done
;;
stop)
stat_busy "Saving random seed"
stat_busy "Stopping random-seed"
save_seed
rm_daemon random-seed
stat_done

24
sv.d/remount-root.in Normal file
View File

@@ -0,0 +1,24 @@
#!/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

63
sv.d/root.in Normal file
View File

@@ -0,0 +1,63 @@
#!/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

@@ -9,13 +9,13 @@ case "$1" in
swapon -a || stat_die swap
add_daemon swap
stat_done swap
;;
;;
stop)
stat_busy "Deactivating swap"
swapoff -a
swapoff -a || stat_die swap
rm_daemon swap
stat_done swap
;;
;;
*)
echo "usage: $0 {start|stop}"
exit 1

23
sv.d/sysfs.in Normal file
View File

@@ -0,0 +1,23 @@
#!/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

17
sv.d/sysusers.in Normal file
View File

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

35
sv.d/timezone.in Normal file
View File

@@ -0,0 +1,35 @@
#!/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

@@ -6,7 +6,7 @@
case "$1" in
start)
stat_busy "Starting tmpfiles-dev"
tmpfiles --prefix=/dev --create --boot || stat_die tmpfiles-dev
etmpfiles --prefix=/dev --create --boot || stat_die tmpfiles-dev
add_daemon tmpfiles-dev
stat_done tmpfiles-dev
;;

17
sv.d/tmpfiles-setup.in Normal file
View File

@@ -0,0 +1,17 @@
#!/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"
etmpfiles --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

19
sv.d/udev-settle.in Normal file
View File

@@ -0,0 +1,19 @@
#!/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

21
sv.d/udev-trigger.in Normal file
View File

@@ -0,0 +1,21 @@
#!/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,24 +5,23 @@
case "$1" in
start)
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
stat_busy "Starting udev daemon"
udevd --daemon || stat_die udev
# Note: This is only needed for initialization, udev will
# be controlled by runit on stage 2.
add_daemon udev
;;
stat_done udev
;;
stop)
stat_busy "Stopping udev"
udevadm control --exit || stat_die udev
# check whether udevd might still be running.
! pgrep -f "udevd" >/dev/null 2>&1 || udevadm control --exit || stat_die udev
rm_daemon udev
stat_done udev
;;
;;
*)
echo "usage: $0 {start|stop}"
exit 1
;;
;;
esac