Scripts for running service (sysv & systemd)
This commit is contained in:
parent
4bae2e67f8
commit
6c13edd9de
63
service/a2tm-service.sh
Executable file
63
service/a2tm-service.sh
Executable file
|
@ -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
|
12
service/a2tm.service
Normal file
12
service/a2tm.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Run a2tm Service
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
User=<USER>
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/a2tm start
|
||||
ExecStop=/usr/bin/killall aria2c
|
Loading…
Reference in New Issue
Block a user