You are not logged in.
Hello, community!
I run a headless server and, as of now, it boots with rtorrent as a daemon, using screen, like so:
#!/bin/bash
# file: /etc/rc.d/rtorrentd
USER=myusername
. /etc/rc.conf
. /etc/rc.d/functions
case "$1" in
start)
stat_busy "Starting rtorrent Service"
su $USER -c 'screen -d -m -S rtorrent $USER' &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon rtorrentd
stat_done
fi
;;
stop)
stat_busy "Stopping rtorrent Service"
killall -w -s 2 /usr/bin/rtorrent &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon rtorrentd
stat_done
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
The usual, as per our wiki and rtorrent documentation.
I would like to do the same with irssi, but maybe I can't due to not completely understanding this statement:
screen -d -m -S rtorrent $USER
I know the "-d -m" part initializes screen and does not attach to it. "-S rtorrent" names that screen as "rtorrent" (I can check that doing
C-a "
when inside a screen)
But that is as far as I know... I tried using the same script and replacing rtorrent -> irssi, but to no avail, it doesn't start by doing sudo /etc/rc.d/irssid start
I don't need irssi to start at boot, but it would be nice just to
sudo /etc/rc.d/irssid start
and have my IRC setup ready. Any hints? Common mistakes?
Thank you for your time
edit: I also tried to follow irssi's guide but I can't create another screen session. (as in: only rtorrent has its own screen)
Last edited by fhtagn (2011-01-26 05:25:57)
Offline
in your .screenrc, cant you just put a
screen -t irssi irssi
and once screen is launched, it will read the config file, and launch irssi.
Offline
Thank you.
That does solve the problem. However, it is not as automated as I would like ( start/stop/restart at my will into another screen session ) nor as 'tidy' as using a separate script like rtorrent.
And somehow I have no ~/.screenrc, but other users do. Weird.
Will post feedback later.
Offline
Well, after messing with .screenrc I ended up doing it with a little help from the wiki.
Now, my /etc/rc.d/irssi has:
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
DAEMON=irssi
USER=<username>
PID=$(pidof -o %PPID $DAEMON)
[ -r /etc/conf.d/irssi ] && . /etc/conf.d/irssi
case "$1" in
start)
stat_busy "Starting $DAEMON Service"
[ -z "$PID" ] && su $USER -c 'screen -dm -S '$DAEMON' -c ~/.irssi/.screenrc_irssi' &> /dev/null
if [ $? != 0 ]; then
stat_fail
else
add_daemon $DAEMON
stat_done
fi
;;
stop)
stat_busy "Stopping $DAEMON Service"
[ -n "$PID" ] && kill $PID &>/dev/null
if [ $? != 0 ]; then
stat_fail
else
rm_daemon $DAEMON
stat_done
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
and in ~/.irssi/.screenrc_irssi I have
screen -t irssi irssi
And it works!
Is it overkill? Why do I need to have
[ -z "$PID" ] && su $USER -c 'screen -dm -S '$DAEMON' -c ~/.irssi/.screenrc_irssi' &> /dev/null
with '$DAEMON' instead of $DAEMON ? Otherwise it does not work... Probably something to do with bash
Offline