Overlay: sync init.d script structure ()

pull/1372/head
viktorxda 2024-03-31 23:38:59 +02:00 committed by GitHub
parent 1c14ca8786
commit 0041f26af3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 81 additions and 84 deletions

View File

@ -4,35 +4,25 @@ DAEMON="syslogd"
PIDFILE="/var/run/$DAEMON.pid"
SYSLOGD_ARGS="-C64 -t"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
# BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line
# and use "-m" to instruct start-stop-daemon to create one.
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
printf "Starting $DAEMON: "
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n $SYSLOGD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
case "$1" in

View File

@ -1,21 +1,27 @@
#!/bin/sh
DAEMON="rngd"
DAEMON_ARGS="-r /dev/urandom"
PID_FILE="/var/run/$DAEMON.pid"
PIDFILE="/var/run/$DAEMON.pid"
RNGD_ARGS="-r /dev/urandom"
start() {
echo "Starting $DAEMON..."
start-stop-daemon -S -q -x "/usr/sbin/$DAEMON" -- $DAEMON_ARGS
printf "Starting $DAEMON: "
start-stop-daemon -S -q -x "/usr/sbin/$DAEMON" -- $RNGD_ARGS
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
stop() {
echo "Stopping $DAEMON..."
# This daemon does not exit properly with the default TERM signal unless
# it's forced to work by something reading /dev/random. Killing it and
# removing its PID file is more straightforward.
start-stop-daemon -K -q -s KILL -p "$PID_FILE" -n "$DAEMON"
rm -f "$PID_FILE"
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -n "$DAEMON"
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
case "$1" in
@ -25,11 +31,12 @@ case "$1" in
restart|reload)
stop
sleep 1
start
;;
*)
echo "Usage: $0 {start|stop|restart|reload}" >&2
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac

View File

@ -2,7 +2,7 @@
case "$1" in
start)
echo "Loading kernel modules..."
echo "Loading modules..."
# load modules from /etc/modules
[ -r /etc/modules ] || exit 0

View File

@ -46,5 +46,3 @@ case "$1" in
exit 1
;;
esac
exit 0

View File

@ -4,35 +4,25 @@ DAEMON="ntpd"
PIDFILE="/var/run/$DAEMON.pid"
NTPD_ARGS="-n"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
# BusyBox' ntpd does not create a pidfile, so pass "-n" in the command line
# and use "-m" to instruct start-stop-daemon to create one.
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
printf "Starting $DAEMON: "
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $NTPD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
case "$1" in
@ -40,7 +30,7 @@ case "$1" in
"$1"
;;
reload)
restart|reload)
stop
sleep 1
start

View File

@ -1,14 +1,10 @@
#!/bin/sh
#
# Starts dropbear sshd.
#
# Allow a few customizations from a config file
test -r /etc/default/dropbear && . /etc/default/dropbear
DAEMON="dropbear"
PIDFILE="/var/run/$DAEMON.pid"
DROPBEAR_ARGS="-R -B -k -p 22 -K 300"
start() {
DROPBEAR_ARGS="$DROPBEAR_ARGS -R -B -k -p 22 -K 300"
# If /etc/dropbear is a symlink to /var/run/dropbear, and
# - the filesystem is RO (i.e. we can not rm the symlink),
# create the directory pointed to by the symlink.
@ -24,17 +20,25 @@ start() {
fi
fi
printf "Starting dropbear sshd: "
printf "Starting $DAEMON: "
umask 077
start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
[ $? = 0 ] && echo "OK" || echo "FAIL"
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $DROPBEAR_ARGS
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
stop() {
printf "Stopping dropbear sshd: "
start-stop-daemon -K -q -p /var/run/dropbear.pid
[ $? = 0 ] && echo "OK" || echo "FAIL"
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
case "$1" in
@ -44,6 +48,7 @@ case "$1" in
restart|reload)
stop
sleep 1
start
;;
@ -52,5 +57,3 @@ case "$1" in
exit 1
;;
esac
exit $?

View File

@ -4,37 +4,25 @@ DAEMON="crond"
PIDFILE="/var/run/$DAEMON.pid"
CROND_ARGS="-f -c /etc/crontabs"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
# The mini-snmpd does not create a pidfile, so pass "-n" in the command line
# and use "-m" to instruct start-stop-daemon to create one.
start() {
printf 'Starting %s: ' "$DAEMON"
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
# shellcheck disable=SC2086 # we need the word splitting
printf "Starting $DAEMON: "
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $CROND_ARGS
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
case "$1" in

View File

@ -0,0 +1,23 @@
#!/bin/sh
# Stop all init scripts in /etc/init.d executing them in reversed numerical order.
for i in $(ls -r /etc/init.d/S??*); do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set stop
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i stop
;;
esac
done

View File

@ -7,8 +7,7 @@ export TZ=$(cat /etc/TZ)
# Set the firmware creation time as the base system time
/bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12)
# Start all init scripts in /etc/init.d
# executing them in numerical order.
# Start all init scripts in /etc/init.d executing them in numerical order.
for i in /etc/init.d/S??*; do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
@ -19,7 +18,7 @@ for i in /etc/init.d/S??*; do
(
trap - INT QUIT TSTP
set start
$i
. $i
)
;;

View File

@ -108,6 +108,7 @@ free_resources() {
fi
/etc/init.d/S60crond stop
/etc/init.d/S49ntpd stop
/etc/init.d/S21rngd stop
/etc/init.d/S02klogd stop
/etc/init.d/S01syslogd stop
sleep 1

View File

@ -2,7 +2,7 @@
DAEMON="majestic"
PIDFILE="/var/run/$DAEMON.pid"
DAEMON_ARGS="-s"
MAJESTIC_ARGS="-s"
debug_majestic() {
[ -f /etc/coredump.conf ] && . /etc/coredump.conf
@ -13,9 +13,8 @@ debug_majestic() {
load_majestic() {
printf "Starting $DAEMON: "
start-stop-daemon -b -S -m -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" -- $DAEMON_ARGS
status=$?
if [ "$status" -eq 0 ]; then
start-stop-daemon -b -S -m -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" -- $MAJESTIC_ARGS
if [ $? = 0 ]; then
echo "OK"
else
echo "FAIL"
@ -23,7 +22,7 @@ load_majestic() {
}
start() {
logger -s -p daemon.info -t $(ipcinfo -v) "Loading video system has started..."
logger -s -p daemon.info -t $(ipcinfo -v) "Loading video system..."
export SENSOR=$(fw_printenv -n sensor)
debug_majestic
load_majestic
@ -32,8 +31,7 @@ start() {
stop() {
printf "Stopping $DAEMON: "
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
if [ $? = 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else