#!/bin/bash USERID=`id -u` if [ $USERID != 0 ]; then echo "You must be root to start aMule as daemon." exit 0 fi . /etc/rc.conf . /etc/rc.d/functions . /etc/conf.d/amule if [ -z $RUN_AMULE_AS_USER ]; then echo "Unable to run aMule. You must set the user in /etc/conf.d/amule" exit 0 fi PID=`pidof -o %PPID /usr/bin/amuled` case "$1" in start) stat_busy "Starting aMule" if [ -z "$PID" ]; then su $RUN_AMULE_AS_USER -c "/usr/bin/amuled -f > /dev/null 2>&1" fi if [ ! -z "$PID" -o $? -gt 0 ]; then stat_fail else add_daemon amuled stat_done fi ;; stop) stat_busy "Stopping aMule" [ ! -z "$PID" ] && kill $PID > /dev/null 2>&1 if [ $? -gt 0 ]; then stat_fail else rm_daemon amuled stat_done fi ;; restart) $0 stop sleep 1 $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac