2

我希望 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

当我开始时,它说

[ 好的 ] 开始 aria2c:aria2c。

但是当我看的时候

/etc/init.d/aria2c 状态

它说

[失败] aria2c 没有运行……失败了!

感谢你的帮助!

4

2 回答 2

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
于 2015-07-25T23:43:02.463 回答
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

不幸的是,当我重新启动系统时,咏叹调不会自动启动。

于 2015-07-26T11:18:57.567 回答