diff --git a/service/a2tm-service.sh b/service/a2tm-service.sh new file mode 100755 index 0000000..3a337c5 --- /dev/null +++ b/service/a2tm-service.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# a2tm +# +# chkconfig: - 88 88 +# description: Script for start, stop and check status of a2tm +# +# processname: a2tm +# + +# Function for start +function start_service() { + echo "# Running at2m process" + /usr/bin/a2tm start & + echo "# Finished a2tm process" +} + +# Function for stop +function stop_service() { + echo "# Stopping the aria2c process" + killall aria2c 2> /dev/null + echo "# Stopping the a2tm process" + killall a2tm 2> /dev/null +} + +# Function for restart +function restart_service() { + stop_service + sleep 3 + start_service +} + +# Function for check status +function status_service() { + aria2c_p=$(ps -e | grep aria2c) + if [ -z "${aria2c_p}" ] ; then + echo "# The aria2c process is not running" + else + echo "# The aria2c process is running" + fi +} + +# Show help +function show_help() { + echo "# Use: $0 {start|stop|restart|status}" +} + +case ${1} in + start) + start_service + ;; + stop) + stop_service + ;; + restart) + restart_service + ;; + status) + status_service + ;; + *) + show_help +esac diff --git a/service/a2tm.service b/service/a2tm.service new file mode 100644 index 0000000..31b1756 --- /dev/null +++ b/service/a2tm.service @@ -0,0 +1,12 @@ +[Unit] +Description=Run a2tm Service +After=network.target + +[Install] +WantedBy=multi-user.target + +[Service] +User= +Type=simple +ExecStart=/usr/bin/a2tm start +ExecStop=/usr/bin/killall aria2c