Skip to content

Instantly share code, notes, and snippets.

/Aria2c Secret

Created January 15, 2013 10:12
Show Gist options
  • Save anonymous/a4f419c2dca8e95f71bb to your computer and use it in GitHub Desktop.
Save anonymous/a4f419c2dca8e95f71bb to your computer and use it in GitHub Desktop.
#! /bin/sh
# /etc/init.d/aria2cRPC
### 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 --daemon=true --enable-rpc=true -D --conf-path=/home/pi/.aria2/aria2.conf
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment