A mi juicio, es mejor meter el inicio de aMule en un cron cada 15 minutos, que usar el bucle "while" en el shell. ¿Por qué? Porque el cron se ejecuta siempre, aunque no haya una sesión de usuario iniciada en el sistema, mientras que ese bucle "while" del shell generalmente requerirá tener un terminal abierto. Tras un reinicio del equipo, aMule arrancaría automáticamente con el cron, pero no con el bucle "while" en el shell. Además, la solución del cron, si aMule estaba ya arrancado, no hace nada y lo deja en paz.
Yo crearía un cron tal que así: crearía un fichero "/etc/cron.d/amule" con este contenido:
Suponiendo, claro está, que tengamos previamente creado un script como éste: "/etc/init.d/amule" :
Código: Seleccionar todo
#! /bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/amuled
WEB=/usr/bin/amuleweb
NAME=amuled
DESC="aMule Daemon process"
OPTS="-f"
RUNAMULE=no
AMULEUSER=mulita
AMULEGROUP=mulita
AMULEHOME="/home/mulita"
RUNDNOTIFY=/usr/bin/dnotify
test -x $DAEMON || exit 0
# Include amule defaults if available
if [ -f /etc/default/amule ] ; then
. /etc/default/amule
fi
if [ "$RUNAMULE" != "yes" ];then
echo "Amule not to be started. Edit /etc/default/amule first."
exit 1
fi
kill_dnotify() {
if pgrep -u $AMULEUSER dnotify > /dev/null; then
pkill -u mulita dnotify
fi
}
start_amule() {
export HOME="${AMULEHOME}"
start-stop-daemon --start --quiet -c $AMULEUSER:$AMULEGROUP \
--exec $DAEMON -- "${OPTS}" > /dev/null
sleep 2
start-stop-daemon --start --quiet -c $AMULEUSER:$AMULEGROUP \
--exec $RUNDNOTIFY -- -C /home/mulita/.aMule/Incoming -b -e \
/home/mulita/Scripts/email_dnotify_amule.sh
if ! pgrep -u $AMULEUSER amuled > /dev/null; then
echo "aMule daemon can't be started! Check logfile."
kill_dnotify
fi
}
stop_amule() {
start-stop-daemon --oknodo --stop --quiet --exec $WEB > /dev/null
sleep 1
start-stop-daemon --oknodo --stop --quiet --exec $DAEMON > /dev/null
kill_dnotify
}
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start_amule
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
stop_amule
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
stop_amule
sleep 1
start_amule
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Mi script "/etc/init.d/amule" a su vez lee el fichero de configuración "/etc/default/amule", que en mi caso tiene este contenido:
Nota: este script "/etc/init.d/amule" está pensado para arrancar la versión "daemon" de aMule, es decir, sin interfaz gráfica, y usando el usuario "mulita", y usa el comando "dnotify" para avisar por email cuando se concluye una descarga. Esto último lo hace con esta configuración: "/home/mulita/Scripts/email_dnotify_amule.sh":
Código: Seleccionar todo
#!/bin/sh
# This script is called by dnotify, to inform by email of
# new files downloaded in the aMule Incoming directory.
MYDIR="/home/mulita/.aMule/Incoming"
cd $MYDIR
SUBJECT=`ls -tr|tail -n1`
BODY=`ls -1shtr|tail -n1`
echo $BODY|mail -s "[aMule] $SUBJECT" mulita