5 Commits

Author SHA1 Message Date
0cb5c0e5d6 Use a faster command 2019-03-09 20:07:37 +07:00
32cf88bd2b Add CLEANTMP option 2019-03-08 20:11:10 +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
6cc8c4288f Check if udev is already run in stage2 by runit 2018-12-27 20:48:25 +07:00
21 changed files with 27 additions and 101 deletions

View File

@@ -28,7 +28,6 @@ RCSVD = \
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 \

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

@@ -27,7 +27,6 @@
# HAVE_CONTROLLER1_GROUPS="true"
# Verbose mode
# Set to "on" to enable details
# Set to 'yes' to remove all files from /tmp
# VERBOSE="off"
# CLEANTMP="no"

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

@@ -2,6 +2,7 @@
# 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}

View File

@@ -5,18 +5,15 @@
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"
[ "$CLEANTMP" == "yes" ] && find /tmp -maxdepth 1 -name '[!ajlq\.]*' -exec rm -rf -- {} +
}
case "$1" in

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,7 +16,6 @@ config(){
_index=$((_index + 1))
done
if [ -n "$KEYMAP" ]; then
ck_verbose && substat "Setting keymap to ${KEYMAP}"
loadkeys -q -u ${KEYMAP}
fi
}

View File

@@ -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"
@@ -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"

View File

@@ -4,14 +4,10 @@
. @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
}

View File

@@ -7,8 +7,6 @@ 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

View File

@@ -17,7 +17,7 @@ config(){
case "$1" in
start)
stat_busy "Setting hostname to $HOSTNAME"
stat_busy "Starting hostname"
config
add_daemon hostname
stat_done

View File

@@ -13,13 +13,13 @@ esac
case "$1" in
start)
stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
stat_busy "Adjusting hwclock"
hwclock $HWCLOCK_PARAMS || stat_die
add_daemon hwclock
stat_done
;;
stop)
stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
stat_busy "Adjusting hwclock"
hwclock --adjust $HWCLOCK_PARAMS || stat_die
rm_daemon hwclock
stat_done

View File

@@ -6,17 +6,14 @@
# 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 -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)
@@ -47,7 +44,7 @@ fsck_reboot() {
echo
sulogin -p
fi
echo "Automatic reboot in progress"
echo "Automatic reboot in progress..."
umount -a
mount -o remount,ro /
reboot -f
@@ -65,10 +62,8 @@ do_fsck(){
}
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
}

View File

@@ -3,12 +3,10 @@
# 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
mount -a -t "no${NETFS//,/,no}" -O no_netdev || stat_die mount-all
add_daemon mount-all
stat_done mount-all
;;

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

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

@@ -36,15 +36,7 @@ umount_fs() {
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
if (( ${#mounts[*]} )); then
umount -r "${mounts[@]}" || return 1
fi
return 0

View File

@@ -3,18 +3,16 @@
# 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 || stat_die swap
rm_daemon swap
stat_done swap
;;

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

@@ -4,14 +4,9 @@
. @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
[ -d /sys/firmware/efi ] && (mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
}
case "$1" in

View File

@@ -5,10 +5,15 @@
case "$1" in
start)
stat_busy "Starting udev daemon"
udevd --daemon || stat_die udev
add_daemon udev
stat_done udev
# check if runit already runs udevd
if ! pgrep -f "runsv udevd" >/dev/null 2>&1; then
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
fi
;;
stop)
stat_busy "Stopping udev"