rTorrent init脚本无法正常工作
我正在尝试用rTorrent和ruTorrent建立一个Ubuntu 14.04盒子。 我已经安装了rTorrent,它使用我自己的用户帐户启动。
我创建了一个名为rtorrent的新用户帐户来运行rTorrent。
sudo adduser --system --group rtorrent
接下来,我在/home/rtorrent
设置配置文件.rtorrent.rc
,并使rtorrent成为所述文件的所有者。
sudo chown rtorrent:rtorrent .rtorrent.rc
我非常希望rtorrent
自动启动。 我从本指南中借用了以下init脚本:
#!/bin/bash ### BEGIN INIT INFO # Provides: rtorrent # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop rtorrent daemon ### END INIT INFO ## Username to run rtorrent under, make sure you have a .rtorrent.rc in the ## home directory of this user! USER="rtorrent" ## Absolute path to the rtorrent binary. ## run "which rtorrent" RTORRENT="/usr/local/bin/rtorrent" ## Absolute path to the screen binary. SCREEN="/usr/bin/screen" ## Name of the screen session, you can then "screen -r rtorrent" to get it back ## to the foreground and work with it on your shell. SCREEN_NAME="rtorrent" ## Absolute path to rtorrent's PID file. PIDFILE="/var/run/rtorrent.pid" ## Absolute path to rtorrent's XMLRPC socket. SOCKET="/var/run/rtorrent/rpc.socket" ## Check if the socket exists and if it exists delete it. delete_socket() { if [[ -e $SOCKET ]]; then rm -f $SOCKET fi } case "$1" in ## Start rtorrent in the background. start) echo "Starting rtorrent." delete_socket start-stop-daemon --start --background --oknodo \ --pidfile "$PIDFILE" --make-pidfile \ --chuid $USER \ --exec $SCREEN -- -DmUS $SCREEN_NAME $RTORRENT if [[ $? -ne 0 ]]; then echo "Error: rtorrent failed to start." exit 1 fi echo "rtorrent started successfully." ;; ## Stop rtorrent. stop) echo "Stopping rtorrent." start-stop-daemon --stop --oknodo --pidfile "$PIDFILE" if [[ $? -ne 0 ]]; then echo "Error: failed to stop rtorrent process." exit 1 fi delete_socket echo "rtorrent stopped successfully." ;; ## Restart rtorrent. restart) "$0" stop sleep 1 "$0" start || exit 1 ;; ## Print usage information if the user gives an invalid option. *) echo "Usage: $0 [start|stop|restart]" exit 1 ;; esac
下一个:
sudo chmod +x /etc/init.d/rtorrent sudo update-rc.d rtorrent defaults 99
可悲的是,重启后做了
sudo top
rtorrent
无处可见。 当我做
sudo /etc/init.d/rtorrent start
我收到了rtorrent
已经启动的消息,但是在运行top
时我仍然找不到它。
我怎样才能让它发挥作用?
在发布这个问题后不久,我突然明白了。 我的.rtorrent.rc
文件对于两个用户都不一样。 修复用户的配置后,一切正常。