67 lines
1.1 KiB
Bash
67 lines
1.1 KiB
Bash
#!/bin/bash
|
|
#Slackware startup deamon script
|
|
|
|
# Name of Service
|
|
NAME="Syncthing Daemon"
|
|
|
|
# Command to run
|
|
CMD="/usr/bin/syncthing"
|
|
|
|
# Process name of daemon, for killing it.
|
|
PROCESSNAME=$CMD
|
|
|
|
# The name of the user that should run Transmission.
|
|
# It's RECOMENDED to run Transmission in it's own user,
|
|
# by default, this is set to 'transmission'.
|
|
# For the sake of security you shouldn't set a password
|
|
# on this user
|
|
USERNAME="gwh"
|
|
|
|
# Option to run with deamon
|
|
OPTIONS=" -home=/home/gwh/ "
|
|
|
|
func_stop() {
|
|
if [ "$(ps aux | grep $PROCESSNAME | grep -v grep)" ]; then
|
|
echo -n "Stopping $NAME ... "
|
|
killall $PROCESSNAME
|
|
sleep 2
|
|
fi
|
|
|
|
if [ ! "$(ps aux | grep $PROCESSNAME | grep -v grep)" ]; then
|
|
echo "Done!"
|
|
else
|
|
echo "Error!"
|
|
fi
|
|
}
|
|
|
|
func_start() {
|
|
echo -n "Starting $NAME ... "
|
|
su - $USERNAME -c "$CMD $OPTIONS" &
|
|
sleep 2
|
|
|
|
if [ "$(ps aux | grep $PROCESSNAME | grep -v grep)" ]; then
|
|
echo "Done!"
|
|
else
|
|
echo "Error!"
|
|
fi
|
|
}
|
|
|
|
|
|
case $1 in
|
|
"start")
|
|
func_start
|
|
;;
|
|
|
|
"stop")
|
|
func_stop
|
|
;;
|
|
|
|
"restart")
|
|
func_stop
|
|
sleep 2
|
|
func_start
|
|
;;
|
|
*)
|
|
echo "Usage; start|stop|restart"
|
|
;;
|
|
esac
|