-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaprsdigi.init
executable file
·138 lines (121 loc) · 2.53 KB
/
aprsdigi.init
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
# aprsdigi - This is the init script for starting up the APRS digipeater
# Also starts beacon.
#
# chkconfig: 345 52 48
# description: starts and stops the aprsdigi APRS digipeater
# processname: aprsdigi
# pidfile: /var/run/aprsdigi.pid
#
# Source function library.
. /etc/init.d/functions
# Find the name of the script
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
APRSDIGI="/usr/sbin/aprsdigi"
BEACON="/usr/sbin/beacon"
APRSDIGI_CONF="/etc/ax25/aprsdigi.conf"
APRSDIGI_PIDFILE="/var/run/aprsdigi.pid"
BEACON_PIDFILE="/var/run/beacon.pid"
APRSDIGI_LOCKFILE="/var/lock/subsys/aprsdigi"
BEACON_LOCKFILE="/var/lock/subsys/beacon"
. ${APRSDIGI_CONF}
script_result=0
# start - runs beacon and aprsdigi if conf files are found.
start_beacon(){
BEACON_START="Starting ${NAME} beacon: "
if [ -x "${BEACON}" -a -f "${APRSDIGI_CONF}" ]
then
echo -n "${BEACON_START}"
${BEACON} -d "${BEACON_DEST}" ${BEACON_PORT} "${BEACON_TEXT}" && success || failure
retval=$?
echo
[ $retval -eq 0 ] && {
touch ${BEACON_LOCKFILE}
success
} || failure
fi
return $retval
}
start_aprsdigi(){
APRSDIGI_START="Starting ${NAME} digipeater: "
if [ -x "${APRSDIGI}" -a -f "${APRSDIGI_CONF}" ]
then
echo -n "${APRSDIGI_START}"
${APRSDIGI} ${APRSDIGI_OPTS} >/dev/null &
retval=$?
echo
[ $retval -eq 0 ] && {
touch ${APRSDIGI_LOCKFILE}
success
} || failure
fi
return $retval
}
start(){
start_beacon
start_aprsdigi # don't care if beacon failed; aprsdigi should still start
}
stop_beacon(){
echo -n $"Stopping ${NAME} beacon: "
killproc ${BEACON}
retval=$?
echo
[ $retval -eq 0 ] && rm -f ${BEACON_LOCKFILE}
return $retval
}
stop_aprsdigi(){
echo -n $"Stopping ${NAME} digipeater: "
killproc ${APRSDIGI}
retval=$?
echo
[ $retval -eq 0 ] && rm -f ${APRSDIGI_LOCKFILE}
return $retval
}
stop(){
stop_beacon
stop_aprsdigi
}
check_status_aprsdigi(){
status ${APRSDIGI}
}
check_status_beacon(){
status ${BEACON}
}
check_status(){
check_status_beacon
check_status_aprsdigi
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop|condstop)
stop
;;
status)
check_status
script_result=$?
;;
restart|condrestart|reload|force-reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|condstop|reload|force-reload}"
exit 1
esac
exit $script_result