3
# Provides: amule-adunanza-daemon
4
# Required-Start: $local_fs $remote_fs
5
# Required-Stop: $local_fs $remote_fs
6
# Should-Start: $network
7
# Should-Stop: $network
8
# Default-Start: 2 3 4 5
10
# Short-Description: Daemonized version of aMule.
11
# Description: Starts the aMule daemon with the user specified in
12
# /etc/default/amule-adunanza-daemon.
15
PATH=/sbin:/usr/sbin:/bin:/usr/bin
18
DESC="aMule AdunanzA daemon"
19
PKGNAME="amule-adunanza-daemon"
20
DAEMON=/usr/bin/amuled
21
SCRIPTNAME=/etc/init.d/$PKGNAME
22
WRAPPER=/usr/share/amule/amuled_home_wrapper.sh
24
[ -x "$DAEMON" ] || exit 0
25
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
27
. /lib/init/vars.sh # has VERBOSE
28
. /lib/lsb/init-functions
30
if [ -z "$AMULED_USER" ]; then
32
"Not starting $DESC, AMULED_USER not set in /etc/default/$PKGNAME."
39
# 0 if daemon has been started
40
# 1 if daemon was already running
41
# 2 if daemon could not be started
42
start-stop-daemon --start --quiet --exec $DAEMON --user "$AMULED_USER" --chuid "$AMULED_USER" --test >/dev/null || return 1
43
start-stop-daemon --start --quiet --exec $WRAPPER --user "$AMULED_USER" --chuid "$AMULED_USER" >/dev/null || return 2
49
# 0 if daemon has been stopped
50
# 1 if daemon was already stopped
51
# 2 if daemon could not be stopped
52
start-stop-daemon --stop --quiet --retry="TERM/30/KILL/5" --exec $DAEMON --user "$AMULED_USER" --chuid "$AMULED_USER"
59
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$PROGNAME"
62
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
63
1) [ "$VERBOSE" != no ] && \
64
log_progress_msg "(already running)" && log_end_msg 0 ;;
65
2) [ "$VERBOSE" != no ] && log_end_msg 1; exit 1 ;;
69
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$PROGNAME"
72
0 | 1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
73
2) [ "$VERBOSE" != no ] && log_end_msg 1; exit 1 ;;
77
log_daemon_msg "Restarting $DESC" "$PROGNAME"
84
1) log_end_msg 1; exit 1 ;; # Old process is still running
85
*) log_end_msg 1; exit 1 ;; # Failed to start
96
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2