slackbuilds_ponce/network/anydesk/rc.anydesk
Ryan S. Northrup e640f01fba
network/anydesk: Added (Remote Desktop Software).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2019-09-28 10:08:58 +07:00

80 lines
1.2 KiB
Bash

#! /bin/sh
### BEGIN INIT INFO
# Short-Description: AnyDesk global service
### END INIT INFO
DESC="AnyDesk global service"
PRGNAM=anydesk
DAEMON=/usr/bin/$PRGNAM
OPTS="--service"
PID=/var/run/$PRGNAM.pid
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
#
# Function that starts the daemon/service.
#
anydesk_start(){
if [ -s $PID ]; then
echo "$DESC is already running: $(cat $PID)"
exit 1
fi
if [ -x $DAEMON ]; then
echo "Starting $DESC"
$DAEMON -- $OPTS &
pidof $DAEMON > $PID
fi
}
#
# Function that stops the daemon/service.
#
anydesk_stop()
{
if [ -e $PID ]; then
kill $(cat $PID)
killall $PRGNAM
rm -rf $PID
echo "$DESC has been stopped."
else
echo "$DESC is not running."
fi
}
#
# Function that shows the current status of the daemon/service.
#
anydesk_status()
{
if [ -s $PID ]; then
echo "$DESC is running: $(cat $PID)"
else
echo "$DESC is not running."
fi
}
case "$1" in
start)
anydesk_start
;;
stop)
anydesk_stop
;;
restart|force-reload)
anydesk_stop
sleep 2
anydesk_start
;;
status)
anydesk_status
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0