You are not logged in.
Hi there, i am running btgd (bittorrent daemon) from the aur, and i have to start it manually after i logged in, because if i start it with my little daemon script (via rc.conf, copied from the mpd one), it gets startet as root, and i have problems with controling it as usual user, which quite sucks...
case "$1" in
start)
stat_busy "Starting Bittorrent Daemon"
/usr/bin/btpd --bw-in 88 --bw-out 9 -d /home/jan/.btpd -p 6885 &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
stop)
stat_busy "Stopping Bittorrent Daemon"
/usr/bin/btcli -d /home/jan/.btpd kill &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
is it possible to run it as the user "jan" at boot, before i logged in?
Last edited by mienensuchkind (2007-09-30 10:45:13)
Offline
Run it from ~/.bashrc? It will then be run when you log in, and you can put a test in there to see if it's already running so you don't run it twice.
EDIT: also possible: sudo -u jan -S your_passwd command
Last edited by Ramses de Norre (2007-09-30 10:28:28)
Offline
You know, i like your second one more because it was my intension to run it *without* me being logged in actually. i will instantly test it!
Thank you very much!
EDIT: Works! (you can forget the "-S password" thing, doesnt work with it, but does without!)
Thanks again!!
Last edited by mienensuchkind (2007-09-30 10:44:48)
Offline
It works without given the password? Root is mighty it seems...
And I wrongly interpreted the man page, it should be echo your_passwd|sudo -u jan -S command but never mind if it works without
Offline
i was surprised myself aswell... but as you said, i dont mind as long as it works
Offline
Try with this script:
#!/bin/bash
# general config
. /etc/rc.conf
. /etc/rc.d/functions
BTPD_BW_IN=600 # limit of incoming BitTorrent traffic [kB/s]
BTPD_BW_OUT=60 # limit of outgoing BitTorrent traffic [kB/s]
BTPD_USER=user # user to run btpd
BTPD_DIR=/home/$BTPD_USER/.btpd # directory to run btpd (default is $HOME/.btpd)
BTPD_PORT=6881 # port number to listen on
case "$1" in
start)
stat_busy "Starting BitTorrent Daemon"
sudo -u $BTPD_USER /usr/bin/btpd --bw-in $BTPD_BW_IN --bw-out $BTPD_BW_OUT -d $BTPD_DIR -p $BTPD_PORT &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
stop)
stat_busy "Stopping BitTorrent Daemon"
sudo -u $BTPD_USER /usr/bin/btcli -d $BTPD_DIR kill &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
You have to create a new user and modify the script but it's safer and it behaves better with btcli.
Offline