updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / amule-remote / amuled
blob2f085c61913a6d077f1d6cdadb1b337daab825c4
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 stat_done
71 restart)
72 $0 stop
73 sleep 1
74 $0 start
77 echo "usage: $0 {start|stop|restart}"
79 esac
80 exit 0