blob: 38675e3741eb101e456707ed386a05d58ae4a214 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#! /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
|