7 .
/etc
/conf.d
/${SVCNAME}
9 NCD_PIDFILE
="/var/run/${SVCNAME}.pid"
10 NCD_NAME
=${NCD_NAME:-"Network Configuration Daemon"}
11 NCD_SYSLOG_IDENT
=${NCD_SYSLOG_IDENT:-"ncd"}
12 NCD_EXEC
="/usr/bin/badvpn-ncd"
15 if [[ -e ${NCD_PIDFILE} ]]; then
16 PID
=$
(cat "${NCD_PIDFILE}" 2>/dev
/null
)
17 if ! [[ $
( readlink
/proc
/$PID/exe
2>/dev
/null
) =~ ^
${NCD_EXEC}(" (deleted)")?$
]]; then
19 rm "${NCD_PIDFILE}" 2>/dev
/null
25 if ! [[ -e ${NCD_CONFIG} ]]; then
26 echo "Error: configuration file (${NCD_CONFIG}) missing"
30 stat_busy
"Starting ${NCD_NAME}"
32 args
=( "${NCD_ARGS[@]}" --config-file "${NCD_CONFIG}" )
33 if [[ -n ${NCD_SYSLOG_IDENT} ]]; then
34 args
=( "${args[@]}" --logger syslog
--syslog-ident "${NCD_SYSLOG_IDENT}" )
38 if [[ -z ${PID} ]]; then
41 exec "${NCD_EXEC}" "${args[@]}"
44 [[ ${res} -eq 0 ]] && echo "$!" > "${NCD_PIDFILE}"
46 if [[ ${res} -eq 0 ]]; then
56 stat_busy
"Stopping ${NCD_NAME}"
57 if [[ ! -z $PID ]] && kill "${PID}" &>/dev
/null
; then
58 while kill -0 "${PID}" &>/dev
/null
; do sleep 0.01; done
74 echo "Usage: $0 {start|stop|restart}" >&2