Last active
March 23, 2017 15:22
-
-
Save meoso/5fcbe1787dd50c2b39c21b1ef3cf58e8 to your computer and use it in GitHub Desktop.
synology service script template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
path="/path/to" | |
binary="executable" | |
parameters="--some-params" | |
background=1 | |
logpath="/opt/var/log" | |
case "$1" in | |
start) | |
if ( pidof ${binary} ) | |
then echo "${binary} is already running." | |
else | |
echo "Starting ${binary}" ; | |
if [ ${background} -eq 1 ] | |
then (exec ${path}/${binary} ${parameters}) & disown | |
else (exec ${path}/${binary} ${parameters}) | |
fi | |
echo "$(date) Started ${binary}" >> ${logpath}/${binary}.log ; | |
fi | |
;; | |
stop) | |
if ( pidof ${binary} ) | |
then | |
echo "Stopping ${binary}"; | |
killall ${binary} | |
echo "$(date) Stopped ${binary}" >> ${logpath}/${binary}.log | |
else | |
echo "${binary} was not running" ; | |
fi | |
;; | |
status) | |
if ( pidof ${binary} ) | |
then echo "${binary} is running." | |
else echo "${binary} is NOT running" | |
fi | |
;; | |
*) | |
echo "Usage: $0 {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