From 6c13edd9defe79efec22770674cb180b6f1b416a Mon Sep 17 00:00:00 2001 From: q3aql Date: Sat, 2 Jul 2022 17:53:02 +0200 Subject: [PATCH] Scripts for running service (sysv & systemd) --- service/a2tm-service.sh | 63 +++++++++++++++++++++++++++++++++++++++++ service/a2tm.service | 12 ++++++++ 2 files changed, 75 insertions(+) create mode 100755 service/a2tm-service.sh create mode 100644 service/a2tm.service 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