我希望aria2在系统启动时启动。我找到了不同的init.d脚本,但没有它们对我有用......
你能告诉我init.d脚本有什么问题吗?
#!/bin/sh
### BEGIN INIT INFO
# Provides: Aria2
# Required-Start: $network $local_fs $remote_fs
# Required-Stop:: $network $local_fs $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Aria2 - Download Manager
### END INIT INFO
NAME=aria2c
ARIA2C=/usr/local/bin/$NAME
PIDFILE=/var/run/$NAME.pid
CONF=/etc/aria2/aria2.conf
ARGS="--conf-path=${CONF} --enable-rpc --rpc-listen-all --daemon"
USER="aria2"
test -f $ARIA2C || exit 0
. /lib/lsb/init-functions
case "$1" in
start) log_daemon_msg "Starting aria2c" "aria2c"
start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chuid $USER --startas $ARIA2C -- $ARGS
log_end_msg $?
;;
stop) log_daemon_msg "Stopping aria2c" "aria2c"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
log_end_msg $?
;;
restart|reload|force-reload)
log_daemon_msg "Restarting aria2c" "aria2c"
start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE
start-stop-daemon --start --quiet -b -m --pidfile $PIDFILE --chuid $USER --startas $ARIA2C -- $ARGS
log_end_msg $?
;;
status)
status_of_proc -p $PIDFILE $ARIA2C aria2c && exit 0 || exit $?
;;
*) log_action_msg "Usage: /etc/init.d/aria2c {start|stop|restart|reload|force-reload|status}"
exit 2
;;
esac
exit 0
当我开始时,它说
[ok]启动aria2c:aria2c。
但是当我看一下
/etc/init.d/aria2c status
它说
[FAIL] aria2c没有运行......失败了!
感谢您的帮助!
答案 0 :(得分:2)
试试这个:
#!/bin/sh
### BEGIN INIT INFO
# Provides: aria2
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c init script.
# Description: Starts and stops aria2 daemon.
### END INIT INFO
USER="root"
DAEMON=/usr/bin/aria2c
CONF=/etc/aria2/aria2.conf
start() {
if [ -f $CONF ]; then
logger -st ARIA2C "Starting aria2c daemon..."
nohup start-stop-daemon -S -c $USER -x $DAEMON -- -D --enable-rpc --conf-path=$CONF
else
logger -st ARIA2C "Couldn't start aria2 daemon (no $CONF found)"
fi
}
stop() {
logger -st ARIA2C "Stoping aria2c daemon..."
start-stop-daemon -o -c $USER -K -u $USER -x $DAEMON
}
status() {
dbpid=`pgrep -fu $USER $DAEMON`
if [ -z "$dbpid" ]; then
logger -st ARIA2C "aria2c daemon not running."
else
logger -st ARIA2C "aria2c daemon running..."
fi
}
case "$1" in
start)
start
sleep 1
;;
stop)
stop
sleep 1
;;
restart)
stop
sleep 2
start
;;
status)
status
;;
*)
echo "Usage: {start|stop|restart|status}"
exit 1
esac
exit 0
答案 1 :(得分:1)
您必须在/etc/aria2/aria2.conf
中编辑配置文件在此文件中粘贴:
daemon=true
enable-rpc=true
rpc-listen-port=6800
rpc-listen-all=true
####### your download folder, ensure that this folder exist! ##########
dir=/tmp
where is your logfile located
log=/var/log/aria2.log
log-level=warn
dht-listen-port=6801
auto-save-interval=30
#seed ratio and seed time in minutes
seed-ratio=1.0
seed-time=1460
max-upload-limit=20K
event-poll=select
使用这些文件(/etc/init.d/aria2d
和/etc/aria2/aria2.conf
)aria工作,当我手动运行时 - > sudo /etc/init.d/aria2d start
不幸的是,当我重启系统时,咏叹调不会自动启动。