-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwolapi_linux_service_template
More file actions
47 lines (43 loc) · 944 Bytes
/
wolapi_linux_service_template
File metadata and controls
47 lines (43 loc) · 944 Bytes
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: wolapi
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Minimalist Wake-On-LAN API service
### END INIT INFO
SCRIPT="java -jar /home/odroid/wol.jar"
PIDFILE=/var/run/wolapi.pid
start() {
echo "Starting wolapi..."
nohup $SCRIPT >/dev/null 2>&1 &
echo $! > $PIDFILE
echo "wolapi started with PID $(cat $PIDFILE)"
}
stop() {
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
echo "Stopping wolapi (PID $PID)..."
kill $PID && rm -f $PIDFILE
echo "wolapi stopped."
else
echo "wolapi is not running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac