updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / amule-git / amuled
blobd77be6aef9cf9ea95e7634802178c6210d92ea5c
1 #!/bin/bash
3 if [ "$(id -u)" != 0 ]
4 then
5 echo "You must be root to start aMule as daemon."
6 exit 2
7 fi
9 # general config
10 USECOLOR="YES"
11 . /etc/conf.d/amule.conf
12 . /etc/rc.d/functions
14 if [ -z $AMULEUSER ]
15 then
16 echo "Unable to run aMule. You must set the user in /etc/conf.d/amule.conf."
17 exit 2
18 elif [[ $AMULEUSER == "root" ]]
19 then
20 echo "Unable to run aMule. You must not run aMule as root."
21 exit 2
24 confdir=$(su -l $AMULEUSER -c "echo ~")/.aMule
25 logfile=$(su -l $AMULEUSER -c "echo ~")/.aMule/amuled.log
26 lockfile=$(su -l $AMULEUSER -c "echo ~")/.aMule/muleLock
28 PID=`pidof -o %PPID /usr/bin/amuled`
30 [ -f $logfile ] && rm -f $logfile
32 case "$1" in
33 start)
34 stat_busy "Starting aMule"
36 if [ -f $lockfile ]
37 then
38 stat_fail
39 echo "Unable to run aMule, it is already running. If you're sure aMule is not already running, you can remove ${lockfile}."
40 exit 2
43 [ ! -d $confdir ] && su -l $AMULEUSER -c "mkdir -p $confdir"
45 [ -z "$PID" ] && su -l $AMULEUSER -c "/usr/bin/amuled -f" &> /dev/null
47 if [ $? -gt 0 ]; then
48 stat_fail
49 else
50 add_daemon amuled
51 stat_done
54 stop)
55 stat_busy "Stopping aMule"
56 if [ -f $lockfile ]
57 then
58 [ ! -z "$PID" ] && kill $PID &> /dev/null
59 else
60 stat_fail
61 echo "Unable to stop aMule. It is not running."
62 exit 2
64 if [ $? -gt 0 ]; then
65 stat_fail
66 else
67 rm_daemon amuled
68 rm -f $lockfile
69 stat_done
72 restart)
73 $0 stop
74 sleep 1
75 $0 start
78 echo "usage: $0 {start|stop|restart}"
80 esac
81 exit 0