Skip to content

Instantly share code, notes, and snippets.

@meoso
Last active March 23, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meoso/5fcbe1787dd50c2b39c21b1ef3cf58e8 to your computer and use it in GitHub Desktop.
Save meoso/5fcbe1787dd50c2b39c21b1ef3cf58e8 to your computer and use it in GitHub Desktop.
synology service script template
#!/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