Aria2正在运行初始化脚本



我希望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]开始咏叹调2c:咏叹调2C。

但当我看时

/etc/init.d/aria2c状态

上面写着

[失败]aria2c未运行。。。失败!

感谢你的帮助!

试试这个:

#!/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

您必须在/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),当我手动运行->sudo /etc/init.d/aria2d start 时,aria就可以工作了

不幸的是,当我重新启动系统时,aria并没有自动启动。

相关内容

  • 没有找到相关文章

最新更新