mirror of https://github.com/OpenIPC/firmware.git
Overlay: sync init.d script structure (#1369)
parent
1c14ca8786
commit
0041f26af3
|
@ -4,35 +4,25 @@ DAEMON="syslogd"
|
||||||
PIDFILE="/var/run/$DAEMON.pid"
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
SYSLOGD_ARGS="-C64 -t"
|
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() {
|
start() {
|
||||||
printf 'Starting %s: ' "$DAEMON"
|
printf "Starting $DAEMON: "
|
||||||
# shellcheck disable=SC2086 # we need the word splitting
|
|
||||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n $SYSLOGD_ARGS
|
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n $SYSLOGD_ARGS
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
printf 'Stopping %s: ' "$DAEMON"
|
printf "Stopping $DAEMON: "
|
||||||
start-stop-daemon -K -q -p "$PIDFILE"
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
rm -f "$PIDFILE"
|
rm -f "$PIDFILE"
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
|
@ -1,21 +1,27 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DAEMON="rngd"
|
DAEMON="rngd"
|
||||||
DAEMON_ARGS="-r /dev/urandom"
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
PID_FILE="/var/run/$DAEMON.pid"
|
RNGD_ARGS="-r /dev/urandom"
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo "Starting $DAEMON..."
|
printf "Starting $DAEMON: "
|
||||||
start-stop-daemon -S -q -x "/usr/sbin/$DAEMON" -- $DAEMON_ARGS
|
start-stop-daemon -S -q -x "/usr/sbin/$DAEMON" -- $RNGD_ARGS
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo "Stopping $DAEMON..."
|
printf "Stopping $DAEMON: "
|
||||||
# This daemon does not exit properly with the default TERM signal unless
|
start-stop-daemon -K -q -n "$DAEMON"
|
||||||
# it's forced to work by something reading /dev/random. Killing it and
|
if [ $? = 0 ]; then
|
||||||
# removing its PID file is more straightforward.
|
echo "OK"
|
||||||
start-stop-daemon -K -q -s KILL -p "$PID_FILE" -n "$DAEMON"
|
else
|
||||||
rm -f "$PID_FILE"
|
echo "FAIL"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -25,11 +31,12 @@ case "$1" in
|
||||||
|
|
||||||
restart|reload)
|
restart|reload)
|
||||||
stop
|
stop
|
||||||
|
sleep 1
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|restart|reload}" >&2
|
echo "Usage: $0 {start|stop|restart|reload}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo "Loading kernel modules..."
|
echo "Loading modules..."
|
||||||
|
|
||||||
# load modules from /etc/modules
|
# load modules from /etc/modules
|
||||||
[ -r /etc/modules ] || exit 0
|
[ -r /etc/modules ] || exit 0
|
|
@ -46,5 +46,3 @@ case "$1" in
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
|
@ -4,35 +4,25 @@ DAEMON="ntpd"
|
||||||
PIDFILE="/var/run/$DAEMON.pid"
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
NTPD_ARGS="-n"
|
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() {
|
start() {
|
||||||
printf 'Starting %s: ' "$DAEMON"
|
printf "Starting $DAEMON: "
|
||||||
# shellcheck disable=SC2086 # we need the word splitting
|
|
||||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $NTPD_ARGS
|
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $NTPD_ARGS
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
printf 'Stopping %s: ' "$DAEMON"
|
printf "Stopping $DAEMON: "
|
||||||
start-stop-daemon -K -q -p "$PIDFILE"
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
rm -f "$PIDFILE"
|
rm -f "$PIDFILE"
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -40,7 +30,7 @@ case "$1" in
|
||||||
"$1"
|
"$1"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
reload)
|
restart|reload)
|
||||||
stop
|
stop
|
||||||
sleep 1
|
sleep 1
|
||||||
start
|
start
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
|
||||||
# Starts dropbear sshd.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Allow a few customizations from a config file
|
DAEMON="dropbear"
|
||||||
test -r /etc/default/dropbear && . /etc/default/dropbear
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
|
DROPBEAR_ARGS="-R -B -k -p 22 -K 300"
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
DROPBEAR_ARGS="$DROPBEAR_ARGS -R -B -k -p 22 -K 300"
|
|
||||||
|
|
||||||
# If /etc/dropbear is a symlink to /var/run/dropbear, and
|
# If /etc/dropbear is a symlink to /var/run/dropbear, and
|
||||||
# - the filesystem is RO (i.e. we can not rm the symlink),
|
# - the filesystem is RO (i.e. we can not rm the symlink),
|
||||||
# create the directory pointed to by the symlink.
|
# create the directory pointed to by the symlink.
|
||||||
|
@ -24,17 +20,25 @@ start() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Starting dropbear sshd: "
|
printf "Starting $DAEMON: "
|
||||||
umask 077
|
umask 077
|
||||||
|
|
||||||
start-stop-daemon -S -q -p /var/run/dropbear.pid --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
|
start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $DROPBEAR_ARGS
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
if [ $? = 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
printf "Stopping dropbear sshd: "
|
printf "Stopping $DAEMON: "
|
||||||
start-stop-daemon -K -q -p /var/run/dropbear.pid
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
if [ $? = 0 ]; then
|
||||||
|
echo "OK"
|
||||||
|
else
|
||||||
|
echo "FAIL"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -44,6 +48,7 @@ case "$1" in
|
||||||
|
|
||||||
restart|reload)
|
restart|reload)
|
||||||
stop
|
stop
|
||||||
|
sleep 1
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -52,5 +57,3 @@ case "$1" in
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit $?
|
|
||||||
|
|
|
@ -4,37 +4,25 @@ DAEMON="crond"
|
||||||
PIDFILE="/var/run/$DAEMON.pid"
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
CROND_ARGS="-f -c /etc/crontabs"
|
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() {
|
start() {
|
||||||
printf 'Starting %s: ' "$DAEMON"
|
printf "Starting $DAEMON: "
|
||||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
|
||||||
# shellcheck disable=SC2086 # we need the word splitting
|
|
||||||
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $CROND_ARGS
|
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" -- $CROND_ARGS
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
printf 'Stopping %s: ' "$DAEMON"
|
printf "Stopping $DAEMON: "
|
||||||
[ -f /usr/sbin/$DAEMON ] || echo -en "DISABLED, "
|
|
||||||
start-stop-daemon -K -q -p "$PIDFILE"
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
rm -f "$PIDFILE"
|
rm -f "$PIDFILE"
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
fi
|
fi
|
||||||
return "$status"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
|
@ -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
|
|
@ -7,8 +7,7 @@ export TZ=$(cat /etc/TZ)
|
||||||
# Set the firmware creation time as the base system time
|
# Set the firmware creation time as the base system time
|
||||||
/bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12)
|
/bin/date -s @$(stat -t /etc/os-release | cut -d" " -f12)
|
||||||
|
|
||||||
# Start all init scripts in /etc/init.d
|
# Start all init scripts in /etc/init.d executing them in numerical order.
|
||||||
# executing them in numerical order.
|
|
||||||
for i in /etc/init.d/S??*; do
|
for i in /etc/init.d/S??*; do
|
||||||
# Ignore dangling symlinks (if any).
|
# Ignore dangling symlinks (if any).
|
||||||
[ ! -f "$i" ] && continue
|
[ ! -f "$i" ] && continue
|
||||||
|
@ -19,7 +18,7 @@ for i in /etc/init.d/S??*; do
|
||||||
(
|
(
|
||||||
trap - INT QUIT TSTP
|
trap - INT QUIT TSTP
|
||||||
set start
|
set start
|
||||||
$i
|
. $i
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ free_resources() {
|
||||||
fi
|
fi
|
||||||
/etc/init.d/S60crond stop
|
/etc/init.d/S60crond stop
|
||||||
/etc/init.d/S49ntpd stop
|
/etc/init.d/S49ntpd stop
|
||||||
|
/etc/init.d/S21rngd stop
|
||||||
/etc/init.d/S02klogd stop
|
/etc/init.d/S02klogd stop
|
||||||
/etc/init.d/S01syslogd stop
|
/etc/init.d/S01syslogd stop
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
DAEMON="majestic"
|
DAEMON="majestic"
|
||||||
PIDFILE="/var/run/$DAEMON.pid"
|
PIDFILE="/var/run/$DAEMON.pid"
|
||||||
DAEMON_ARGS="-s"
|
MAJESTIC_ARGS="-s"
|
||||||
|
|
||||||
debug_majestic() {
|
debug_majestic() {
|
||||||
[ -f /etc/coredump.conf ] && . /etc/coredump.conf
|
[ -f /etc/coredump.conf ] && . /etc/coredump.conf
|
||||||
|
@ -13,9 +13,8 @@ debug_majestic() {
|
||||||
|
|
||||||
load_majestic() {
|
load_majestic() {
|
||||||
printf "Starting $DAEMON: "
|
printf "Starting $DAEMON: "
|
||||||
start-stop-daemon -b -S -m -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" -- $DAEMON_ARGS
|
start-stop-daemon -b -S -m -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" -- $MAJESTIC_ARGS
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
echo "FAIL"
|
echo "FAIL"
|
||||||
|
@ -23,7 +22,7 @@ load_majestic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
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)
|
export SENSOR=$(fw_printenv -n sensor)
|
||||||
debug_majestic
|
debug_majestic
|
||||||
load_majestic
|
load_majestic
|
||||||
|
@ -32,8 +31,7 @@ start() {
|
||||||
stop() {
|
stop() {
|
||||||
printf "Stopping $DAEMON: "
|
printf "Stopping $DAEMON: "
|
||||||
start-stop-daemon -K -q -p "$PIDFILE"
|
start-stop-daemon -K -q -p "$PIDFILE"
|
||||||
status=$?
|
if [ $? = 0 ]; then
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
rm -f "$PIDFILE"
|
rm -f "$PIDFILE"
|
||||||
echo "OK"
|
echo "OK"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue