Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
18183a020f | |||
d080a0f876 | |||
009ef13a19 | |||
793a262ba7 | |||
9399960b23 | |||
740058e9a8 | |||
03756d0913 | |||
821e832d53 | |||
883dc1b167 | |||
53fef66cbd |
4
Makefile
4
Makefile
@@ -18,7 +18,6 @@ RCBIN = \
|
|||||||
RCSVD = \
|
RCSVD = \
|
||||||
sv.d/root \
|
sv.d/root \
|
||||||
sv.d/binfmt \
|
sv.d/binfmt \
|
||||||
sv.d/binfmt.d \
|
|
||||||
sv.d/bootlogd \
|
sv.d/bootlogd \
|
||||||
sv.d/cleanup \
|
sv.d/cleanup \
|
||||||
sv.d/console-setup \
|
sv.d/console-setup \
|
||||||
@@ -29,6 +28,7 @@ RCSVD = \
|
|||||||
sv.d/misc \
|
sv.d/misc \
|
||||||
sv.d/mount-all \
|
sv.d/mount-all \
|
||||||
sv.d/net-lo \
|
sv.d/net-lo \
|
||||||
|
sv.d/netfs \
|
||||||
sv.d/random-seed \
|
sv.d/random-seed \
|
||||||
sv.d/remount-root \
|
sv.d/remount-root \
|
||||||
sv.d/swap \
|
sv.d/swap \
|
||||||
@@ -156,7 +156,6 @@ install-rc:
|
|||||||
$(LN) $(RCSVDIR)/dmesg $(DESTDIR)$(RCDIR)/sysinit/85-dmesg
|
$(LN) $(RCSVDIR)/dmesg $(DESTDIR)$(RCDIR)/sysinit/85-dmesg
|
||||||
$(LN) $(RCSVDIR)/sysctl $(DESTDIR)$(RCDIR)/sysinit/90-sysctl
|
$(LN) $(RCSVDIR)/sysctl $(DESTDIR)$(RCDIR)/sysinit/90-sysctl
|
||||||
$(LN) $(RCSVDIR)/binfmt $(DESTDIR)$(RCDIR)/sysinit/95-binfmt
|
$(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
|
$(LN) $(RCSVDIR)/cleanup $(DESTDIR)$(RCDIR)/sysinit/99-cleanup
|
||||||
|
|
||||||
install -d $(DESTDIR)$(RCDIR)/shutdown
|
install -d $(DESTDIR)$(RCDIR)/shutdown
|
||||||
@@ -164,7 +163,6 @@ install-rc:
|
|||||||
$(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)/cleanup $(DESTDIR)$(RCDIR)/shutdown/20-cleanup
|
||||||
$(LN) $(RCSVDIR)/udev $(DESTDIR)$(RCDIR)/shutdown/30-udev
|
$(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)/misc $(DESTDIR)$(RCDIR)/shutdown/40-misc
|
||||||
$(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)/root $(DESTDIR)$(RCDIR)/shutdown/60-root
|
||||||
|
@@ -1,18 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This is run by the kernel after the last task is removed from a
|
# This is run by the kernel after the last task is removed from a
|
||||||
# control group in the artix hierarchy.
|
# control group in the openrc hierarchy.
|
||||||
|
|
||||||
# Copyright (c) 2007-2015 The OpenRC Authors.
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
||||||
# See the Authors file at the top-level directory of this distribution and
|
# See the Authors file at the top-level directory of this distribution and
|
||||||
# https://github.com/OpenRC/artix/blob/master/AUTHORS
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
||||||
#
|
#
|
||||||
# This file is part of OpenRC. It is subject to the license terms in
|
# 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
|
# the LICENSE file found in the top-level directory of this
|
||||||
# distribution and at https://github.com/OpenRC/artix/blob/master/LICENSE
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
||||||
# This file may not be copied, modified, propagated, or distributed
|
# This file may not be copied, modified, propagated, or distributed
|
||||||
# except according to the terms contained in the LICENSE file.
|
# except according to the terms contained in the LICENSE file.
|
||||||
|
|
||||||
cgroup=/sys/fs/cgroup/artix
|
cgroup=/sys/fs/cgroup/openrc
|
||||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||||
if [ -d ${cgroup}/"$1" ]; then
|
if [ -d ${cgroup}/"$1" ]; then
|
||||||
rmdir ${cgroup}/"$1"
|
rmdir ${cgroup}/"$1"
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
|
||||||
. /etc/profile.d/locale.sh
|
. /etc/profile.d/locale.sh
|
||||||
|
. @RCDIR@/rc.conf
|
||||||
|
|
||||||
# width:
|
# width:
|
||||||
calc_columns () {
|
calc_columns () {
|
||||||
@@ -60,6 +61,14 @@ stat_busy() {
|
|||||||
printf " ${C_OTHER}[${C_BUSY}busy${C_OTHER}]${C_CLEAR} "
|
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() {
|
ck_daemon() {
|
||||||
[[ ! -f @RCRUNDIR@/started/$1 ]]
|
[[ ! -f @RCRUNDIR@/started/$1 ]]
|
||||||
}
|
}
|
||||||
@@ -201,11 +210,7 @@ run_shutdown(){
|
|||||||
calc_columns
|
calc_columns
|
||||||
|
|
||||||
# disable colors on broken terminals
|
# disable colors on broken terminals
|
||||||
if [[ -z "$TERM" || "$TERM" = "dumb" ]]; then
|
TERM_COLORS=$(tput colors 2>/dev/null)
|
||||||
TERM_COLORS=$(tput colors -T linux 2>/dev/null)
|
|
||||||
else
|
|
||||||
TERM_COLORS=$(tput colors 2>/dev/null)
|
|
||||||
fi
|
|
||||||
if (( $? != 3 )); then
|
if (( $? != 3 )); then
|
||||||
case $TERM_COLORS in
|
case $TERM_COLORS in
|
||||||
*[!0-9]*) USECOLOR="";;
|
*[!0-9]*) USECOLOR="";;
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and
|
# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and
|
||||||
# cgroups version 1 on /sys/fs/cgroup
|
# cgroups version 1 on /sys/fs/cgroup
|
||||||
|
|
||||||
# CGROUP_MODE="unified"
|
# CGROUP_MODE="hybrid"
|
||||||
|
|
||||||
# This is a list of controllers which should be enabled for cgroups version 2.
|
# 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
|
# If hybrid mode is being used, controllers listed here will not be
|
||||||
@@ -27,8 +27,7 @@
|
|||||||
|
|
||||||
# HAVE_CONTROLLER1_GROUPS="true"
|
# HAVE_CONTROLLER1_GROUPS="true"
|
||||||
|
|
||||||
# This switch controls whether or not /tmp will be cleaned.
|
# Verbose mode
|
||||||
# /tmp will only be cleaned if it is set to "y". Generally it is recommended to
|
# Set to "on" to enable details
|
||||||
# mount /tmp as tmpfs.
|
|
||||||
|
|
||||||
# CLEANTMP="n"
|
# VERBOSE="off"
|
||||||
|
@@ -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 "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
|
|
@@ -7,17 +7,12 @@ mount_binfmt(){
|
|||||||
mountpoint -q /proc/sys/fs/binfmt_misc || \
|
mountpoint -q /proc/sys/fs/binfmt_misc || \
|
||||||
mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc || return 1
|
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
|
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
|
||||||
[[ ! -d $path ]] && continue
|
[[ ! -d $path ]] && continue
|
||||||
[[ -z "$(ls $path)" ]] && continue
|
[[ -z "$(ls $path)" ]] && continue
|
||||||
grep -h "^:" $path/* | \
|
grep "^:" $path/* | \
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
|
ck_verbose && substat "Registering $line"
|
||||||
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || return 1
|
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register || return 1
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@@ -33,13 +28,8 @@ case "$1" in
|
|||||||
add_daemon binfmt
|
add_daemon binfmt
|
||||||
stat_done binfmt
|
stat_done binfmt
|
||||||
;;
|
;;
|
||||||
once)
|
|
||||||
stat_busy "Running binfmt"
|
|
||||||
mount_binfmt || stat_die binfmt
|
|
||||||
stat_done
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "usage: $0 {start|once}"
|
echo "usage: $0 {start}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
115
sv.d/cgroups.in
115
sv.d/cgroups.in
@@ -3,10 +3,123 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
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(){
|
||||||
|
${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
|
||||||
|
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
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Mounting cgroups filesystem"
|
stat_busy "Mounting cgroups filesystem"
|
||||||
/usr/lib/artix/mount-cgroups.sh|| stat_die cgroups
|
mount_cgs || stat_die cgroups
|
||||||
add_daemon cgroups
|
add_daemon cgroups
|
||||||
stat_done cgroups
|
stat_done cgroups
|
||||||
;;
|
;;
|
||||||
|
@@ -2,20 +2,21 @@
|
|||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
cleaning(){
|
cleaning(){
|
||||||
install -m0664 -o root -g utmp /dev/null /run/utmp
|
install -m0664 -o root -g utmp /dev/null /run/utmp
|
||||||
|
ck_verbose && substat "Created /run/utmp"
|
||||||
if [ ! -e /var/log/wtmp ]; then
|
if [ ! -e /var/log/wtmp ]; then
|
||||||
install -m0664 -o root -g utmp /dev/null /var/log/wtmp
|
install -m0664 -o root -g utmp /dev/null /var/log/wtmp
|
||||||
|
ck_verbose && substat "Created /var/log/wtmp"
|
||||||
fi
|
fi
|
||||||
if [ ! -e /var/log/btmp ]; then
|
if [ ! -e /var/log/btmp ]; then
|
||||||
install -m0600 -o root -g utmp /dev/null /var/log/btmp
|
install -m0600 -o root -g utmp /dev/null /var/log/btmp
|
||||||
|
ck_verbose && substat "Created /var/log/btmp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
||||||
|
ck_verbose && substat "Removed /etc/nologin, /forcefsck, /forcequotacheck, /fastboot"
|
||||||
[ "$CLEANTMP" = y ] && rm -rf /tmp/*
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@@ -7,6 +7,7 @@ config(){
|
|||||||
[ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
|
[ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
|
||||||
TTYS=${TTYS:-6}
|
TTYS=${TTYS:-6}
|
||||||
_index=0
|
_index=0
|
||||||
|
ck_verbose && [ -n "$FONT" ] && substat "Setting font to ${FONT}"
|
||||||
while [ ${_index} -le $TTYS ]; do
|
while [ ${_index} -le $TTYS ]; do
|
||||||
if [ -n "$FONT" ]; then
|
if [ -n "$FONT" ]; then
|
||||||
setfont ${FONT_MAP:+-m $FONT_MAP} ${FONT_UNIMAP:+-u $FONT_UNIMAP} \
|
setfont ${FONT_MAP:+-m $FONT_MAP} ${FONT_UNIMAP:+-u $FONT_UNIMAP} \
|
||||||
@@ -16,6 +17,7 @@ config(){
|
|||||||
_index=$((_index + 1))
|
_index=$((_index + 1))
|
||||||
done
|
done
|
||||||
if [ -n "$KEYMAP" ]; then
|
if [ -n "$KEYMAP" ]; then
|
||||||
|
ck_verbose && substat "Setting keymap to ${KEYMAP}"
|
||||||
loadkeys -q -u ${KEYMAP}
|
loadkeys -q -u ${KEYMAP}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@ do_unlock_device() {
|
|||||||
do_unlock() {
|
do_unlock() {
|
||||||
local name=$1 device=$2 password=$3 options=$4
|
local name=$1 device=$2 password=$3 options=$4
|
||||||
|
|
||||||
printf "${C_MAIN}Unlocking $1${C_CLEAR}\n"
|
substat "Unlocking $1"
|
||||||
|
|
||||||
if [[ ${options:0:2} =~ -. ]]; then
|
if [[ ${options:0:2} =~ -. ]]; then
|
||||||
do_unlock_device "$name" "$device" "$password" "$options"
|
do_unlock_device "$name" "$device" "$password" "$options"
|
||||||
@@ -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"
|
||||||
|
@@ -4,35 +4,15 @@
|
|||||||
. @RCLIBDIR@/functions
|
. @RCLIBDIR@/functions
|
||||||
|
|
||||||
mount_devfs(){
|
mount_devfs(){
|
||||||
mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid
|
ck_verbose && substat "Mounting /dev"
|
||||||
|
mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid
|
||||||
# seed /dev with some things that might be needed (for example,
|
mkdir -p /dev/{pts,shm}
|
||||||
# xudev doesn't do this compared to eudev), code from OpenRC
|
ck_verbose && substat "Mounting /dev/pts"
|
||||||
|
|
||||||
# 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/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
|
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
|
ck_verbose && substat "Mounting /run"
|
||||||
|
mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@@ -7,6 +7,8 @@ config(){
|
|||||||
if [[ -e /proc/sys/kernel/dmesg_restrict ]] &&
|
if [[ -e /proc/sys/kernel/dmesg_restrict ]] &&
|
||||||
(( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then
|
(( $(< /proc/sys/kernel/dmesg_restrict) == 1 )); then
|
||||||
install -Tm 0600 <( dmesg ) /var/log/dmesg.log
|
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
|
else
|
||||||
install -Tm 0644 <( dmesg ) /var/log/dmesg.log
|
install -Tm 0644 <( dmesg ) /var/log/dmesg.log
|
||||||
fi
|
fi
|
||||||
|
@@ -17,7 +17,7 @@ config(){
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Starting hostname"
|
stat_busy "Setting hostname to $HOSTNAME"
|
||||||
config
|
config
|
||||||
add_daemon hostname
|
add_daemon hostname
|
||||||
stat_done
|
stat_done
|
||||||
|
@@ -1,26 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. @RCLIBDIR@/functions
|
. @RCLIBDIR@/functions
|
||||||
. @RCDIR@/rc.conf
|
|
||||||
|
|
||||||
|
HWCLOCK_PARAMS="--systz"
|
||||||
HARDWARECLOCK=${HARDWARECLOCK:-UTC}
|
HARDWARECLOCK=${HARDWARECLOCK:-UTC}
|
||||||
|
|
||||||
case $HARDWARECLOCK in
|
case $HARDWARECLOCK in
|
||||||
UTC) HWCLOCK_PARAMS+=" --utc" ;;
|
UTC) HWCLOCK_PARAMS+=" --utc --noadjfile" ;;
|
||||||
localtime) HWCLOCK_PARAMS+=" --localtime" ;;
|
localtime) HWCLOCK_PARAMS+=" --localtime --noadjfile" ;;
|
||||||
*) HWCLOCK_PARAMS="";;
|
*) HWCLOCK_PARAMS="";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Adjusting hwclock"
|
stat_busy "Adjusting hwclock to ${HARDWARECLOCK}"
|
||||||
hwclock --systz $HWCLOCK_PARAMS --noadjfile || 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 --systohc $HWCLOCK_PARAMS || stat_die
|
hwclock --adjust $HWCLOCK_PARAMS || stat_die
|
||||||
rm_daemon hwclock
|
rm_daemon hwclock
|
||||||
stat_done
|
stat_done
|
||||||
;;
|
;;
|
||||||
|
@@ -6,14 +6,17 @@
|
|||||||
# Check local filesystems
|
# 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
|
||||||
|
ck_verbose && substat "/forcefsck found, forcing fsck"
|
||||||
FORCEFSCK="-f"
|
FORCEFSCK="-f"
|
||||||
elif [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); then
|
elif [[ -f /fastboot ]] || in_array fastboot $(< /proc/cmdline); then
|
||||||
|
ck_verbose && substat "/fastboot found, canceling fsck"
|
||||||
return 0
|
return 0
|
||||||
elif [[ -e /run/initramfs/root-fsck ]]; then
|
elif [[ -e /run/initramfs/root-fsck ]]; then
|
||||||
|
ck_verbose && substat "Ignoring mounted filesystems in fsck"
|
||||||
IGNORE_MOUNTED="-M"
|
IGNORE_MOUNTED="-M"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fsck -A -T -M -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} -- ${FORCEFSCK}
|
fsck -A -T -C${FSCK_FD} -a -t no${NETFS//,/,no},noopts=_netdev ${IGNORE_MOUNTED} -- ${FORCEFSCK}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Single-user login and/or automatic reboot after fsck (if needed)
|
# Single-user login and/or automatic reboot after fsck (if needed)
|
||||||
@@ -44,7 +47,7 @@ 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
|
||||||
@@ -62,8 +65,10 @@ do_fsck(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
kill_all(){
|
kill_all(){
|
||||||
|
ck_verbose && substat "Killing processes using SIGTERM"
|
||||||
pkill --inverse -s0,1 -TERM
|
pkill --inverse -s0,1 -TERM
|
||||||
sleep 1
|
sleep 1
|
||||||
|
ck_verbose && substat "Killing processes using SIGKILL"
|
||||||
pkill --inverse -s0,1 -KILL
|
pkill --inverse -s0,1 -KILL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
ck_verbose && MOUNT_VERBOSE="-v"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Starting mount-all"
|
stat_busy "Starting mount-all"
|
||||||
mount -a -t "no${NETFS//,/,no}" -O no_netdev || stat_die mount-all
|
mount -a "${MOUNT_VERBOSE}" -t "no${NETFS//,/,no}" -O no_netdev || stat_die mount-all
|
||||||
add_daemon mount-all
|
add_daemon mount-all
|
||||||
stat_done mount-all
|
stat_done mount-all
|
||||||
;;
|
;;
|
||||||
|
@@ -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
|
||||||
|
34
sv.d/netfs.in
Normal file
34
sv.d/netfs.in
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/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
|
@@ -4,18 +4,7 @@
|
|||||||
. @RCLIBDIR@/functions
|
. @RCLIBDIR@/functions
|
||||||
|
|
||||||
mount_procfs(){
|
mount_procfs(){
|
||||||
grep -v '^#' /etc/fstab | grep /proc | {
|
mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev
|
||||||
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
|
case "$1" in
|
||||||
|
10
sv.d/root.in
10
sv.d/root.in
@@ -36,7 +36,15 @@ umount_fs() {
|
|||||||
mounts=("$target" "${mounts[@]}")
|
mounts=("$target" "${mounts[@]}")
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( ${#mounts[*]} )); then
|
# 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
|
umount -r "${mounts[@]}" || return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
@@ -3,16 +3,18 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
ck_verbose && SWAP_VERBOSE="-v"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Activating swap"
|
stat_busy "Activating swap"
|
||||||
swapon -a || stat_die swap
|
swapon -a "${SWAP_VERBOSE}" || stat_die swap
|
||||||
add_daemon swap
|
add_daemon swap
|
||||||
stat_done swap
|
stat_done swap
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stat_busy "Deactivating swap"
|
stat_busy "Deactivating swap"
|
||||||
swapoff -a || stat_die swap
|
swapoff -a "${SWAP_VERBOSE}" || stat_die swap
|
||||||
rm_daemon swap
|
rm_daemon swap
|
||||||
stat_done swap
|
stat_done swap
|
||||||
;;
|
;;
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
! ck_verbose && QUIET="-q"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Loading sysctl settings"
|
stat_busy "Loading sysctl settings"
|
||||||
sysctl --system || stat_die sysctl
|
sysctl "$QUIET" --system || stat_die sysctl
|
||||||
add_daemon sysctl
|
add_daemon sysctl
|
||||||
stat_done sysctl
|
stat_done sysctl
|
||||||
;;
|
;;
|
||||||
|
@@ -4,9 +4,14 @@
|
|||||||
. @RCLIBDIR@/functions
|
. @RCLIBDIR@/functions
|
||||||
|
|
||||||
mount_sysfs(){
|
mount_sysfs(){
|
||||||
|
ck_verbose && substat "Mounting /sys"
|
||||||
mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev
|
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
|
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)
|
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
|
case "$1" in
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Starting sysusers"
|
stat_busy "Starting sysusers"
|
||||||
esysusers
|
sysusers
|
||||||
add_daemon sysusers
|
add_daemon sysusers
|
||||||
stat_done
|
stat_done
|
||||||
;;
|
;;
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Starting tmpfiles-dev"
|
stat_busy "Starting tmpfiles-dev"
|
||||||
etmpfiles --prefix=/dev --create --boot || stat_die tmpfiles-dev
|
tmpfiles --prefix=/dev --create --boot || stat_die tmpfiles-dev
|
||||||
add_daemon tmpfiles-dev
|
add_daemon tmpfiles-dev
|
||||||
stat_done tmpfiles-dev
|
stat_done tmpfiles-dev
|
||||||
;;
|
;;
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
stat_busy "Starting tmpfiles-setup"
|
stat_busy "Starting tmpfiles-setup"
|
||||||
etmpfiles --exclude-prefix=/dev --create --remove --boot || stat_die tmpfiles-setup
|
tmpfiles --exclude-prefix=/dev --create --remove --boot || stat_die tmpfiles-setup
|
||||||
add_daemon tmpfiles-setup
|
add_daemon tmpfiles-setup
|
||||||
stat_done tmpfiles-setup
|
stat_done tmpfiles-setup
|
||||||
;;
|
;;
|
||||||
|
@@ -7,15 +7,12 @@ case "$1" in
|
|||||||
start)
|
start)
|
||||||
stat_busy "Starting udev daemon"
|
stat_busy "Starting udev daemon"
|
||||||
udevd --daemon || stat_die udev
|
udevd --daemon || stat_die udev
|
||||||
# Note: This is only needed for initialization, udev will
|
|
||||||
# be controlled by runit on stage 2.
|
|
||||||
add_daemon udev
|
add_daemon udev
|
||||||
stat_done udev
|
stat_done udev
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stat_busy "Stopping udev"
|
stat_busy "Stopping udev"
|
||||||
# check whether udevd might still be running.
|
udevadm control --exit || stat_die udev
|
||||||
! pgrep -f "udevd" >/dev/null 2>&1 || udevadm control --exit || stat_die udev
|
|
||||||
rm_daemon udev
|
rm_daemon udev
|
||||||
stat_done udev
|
stat_done udev
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user