脚本内容如下:
#!/bin/sh
#!/bin/bash
### BEGIN INIT INFO
# Provides: aria2
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Aria2 Downloader
### END INIT INFO
USER=sh_user
CONF=/etc/aria2/aria2.conf
BIN=/usr/local/bin/aria2c
case "$1" in
start)
echo "Start aria2c"
su - $USER -c "$BIN --conf-path=$CONF"
;;
stop)
echo "Stopping aria2c, please wait..."
killall -w aria2c
;;
restart)
echo "Stopping aria2c, please wait..."
$0 stop
echo "Start aria2c"
$0 start
;;
*)
echo "$0 {start|stop|restart|status}"
;;
esac
exit
增加脚本运行权限
chmod +x /etc/init.d/aria2
设置aria2服务开机自动运行
update-rc.d aria2 defaults