Friday, November 14, 2014

Install aria2 to Raspberry Pi

Install via apt-get
#apt-get install aria2

Create init script
#! /bin/sh
# /etc/init.d/aria2

### BEGIN INIT INFO
# Provides: aria2cRPC
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: aria2c RPC init script.
# Description: Starts and stops aria2 RPC services.
### END INIT INFO

#VAR
RUN="/usr/bin/aria2c"
ARIA_PID=$(ps ux | awk '/aria2c --enable-rpc/ && !/awk/ {print $2}')

# Some things that run always
touch /var/lock/aria2cRPC

# Carry out specific functions when asked to by the system
case "$1" in

start)
echo "Starting script aria2cRPC "
if [ -z "$ARIA_PID" ]; then
nohup $RUN --enable-rpc --rpc-user=admin --rpc-passwd=rfujcfdh --rpc-listen-port=8000 --rpc-listen-all --daemon -D --conf-path=/root/.aria2/aria2.conf
/bin/mount -t cifs -o user=,password=,rw,file_mode=0777,dir_mode=0777 //192.168.1.3/DuneHDD_90eab4c2_0dd9_4cac_84fa_d551745cd532 /mnt
echo "Started"
else
echo "aria2cRPC already started"
fi
;;

stop)
echo "Stopping script aria2cRPC"
if [ ! -z "$ARIA_PID" ]; then
kill $ARIA_PID
fi
echo "OK"
;;

status)
if [ ! -z "$ARIA_PID" ]; then
echo "The aria2cRPC is running with PID = "$ARIA_PID
else
echo "No process found for aria2c RPC"
fi
;;
*)
echo "Usage: /etc/init.d/aria2cRPC {start|stop|status}"
exit 1
;;
esac

exit 0

No comments:

Post a Comment