Bash:
#!/usr/bin/env bash
# Dependance : screen, killall et rtorrent
### BEGIN INIT INFO
# Provides: <username>-rtorrent
# Required-Start: $syslog $network
# Required-Stop: $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Start-Stop rtorrent user session
### END INIT INFO
## Debut configuration ##
user="flood"
## Fin configuration ##
rt_start() {
su flood -m -c 'screen -S flood-rtorrent -dm rtorrent'
}
rt_stop() {
su flood -m -c 'screen -S flood-rtorrent -X quit'
}
case "$1" in
start)
echo "Demarrage de rtorrent..."
rt_start
;;
stop)
echo "Arret de rtorrent..."
rt_stop
;;
restart)
echo "Redemarrage de rtorrent..."
rt_stop
sleep 1
rt_start
;;
*)
rt_start
;;
stop)
echo "Arret de rtorrent..."
rt_stop
;;
restart)
echo "Redemarrage de rtorrent..."
rt_stop
sleep 1
rt_start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
This the script I try to run but it doesn't seem to work for now. I've tried several variations. It works on debian.
Doesn't work very well on FreeBSD for mysterious ways.
the '$user' env doesn't work because I can see that it's root which is used if I replace flood by $user in the script*.
At first in place of the -c there was --command= and that doesn't work either so I change it.
What I could state also, it's not the same version of manual between FreeBSD and debian/ubuntu . In FreeBSD there is no command line. So maybe I'm not doing something which is compatible with the FREEBSD way?