blob: 1f92ba233bb2b8d787282a39799155209a7c9b6d (
plain) (
tree)
|
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: user-startup
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Mechanism for starting/stopping user daemons
### END INIT INFO
set -e
PATH='/bin:/sbin:/usr/bin:/usr/sbin'
. '/lib/lsb/init-functions'
NAME='user-startup'
BACKGROUND_STARTUP='Yes'
CONFIG='/etc/user-startup.conf'
test -r "${CONFIG}" || exit 0
if [ -r "/etc/default/$NAME" ]
then
. "/etc/default/$NAME"
fi
case $BACKGROUND_STARTUP in
N*|n*)
BACKGROUND='0'
STARTUP_MSG='Starting user daemons'
;;
*)
BACKGROUND='1'
STARTUP_MSG='Starting user daemons in the background'
;;
esac
case "$1" in
start)
log_daemon_msg "$STARTUP_MSG" "$NAME"
grep -v '^\s*\(#\|$\)' "${CONFIG}" | while read user ; do
USER_HOME=$(getent passwd "${user}" | cut -d: -f6)
if [ -n "${USER_HOME}" -a -d "${USER_HOME}/etc/rc.d/" ]; then
if [ "${BACKGROUND}" = "1" ]; then
( su - "${user}" -c "run-parts \
--arg=start \
--verbose \
-- '${USER_HOME}/etc/rc.d/'" 2>&1 | logger -t user-startup ) &
else
su - "${user}" -c "run-parts \
--arg=start \
--verbose \
-- '${USER_HOME}/etc/rc.d/'" 2>&1 | logger -t user-startup
fi
fi
done
log_end_msg $?
;;
stop)
log_daemon_msg 'Stopping user daemons' "$NAME"
grep -v '^\s*\(#\|$\)' "${CONFIG}" | while read user ; do
USER_HOME=$(getent passwd $user | cut -d: -f6)
if [ -n "${USER_HOME}" -a -d "${USER_HOME}/etc/rc.d/" ]; then
su - ${user} -c "run-parts \
--arg=stop \
--verbose \
-- '${USER_HOME}/etc/rc.d/'" 2>&1 | logger -t user-startup
fi
done
log_end_msg $?
;;
restart|force-reload)
"$0" 'stop' && sleep 1 && "$0" 'start'
;;
*)
echo >&2 "Usage: $0 {start|stop|restart|force-reload}"
exit 3
;;
esac
exit 0
|