File: rtpengine-recording-daemon.init

package info (click to toggle)
rtpengine 13.5.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,676 kB
  • sloc: ansic: 86,764; perl: 59,422; python: 3,193; sh: 1,030; makefile: 693; asm: 211
file content (112 lines) | stat: -rwxr-xr-x 2,584 bytes parent folder | download | duplicates (2)
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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          rtpengine-recording-daemon
# Required-Start:    $network $local_fs $remote_fs $syslog
# Required-Stop:     $network $local_fs $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Rtpengine Recording Daemon
# Description:       Recording daemon for RTP and other media streams
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=rtpengine-recording-daemon
DESC="RTP/media recording daemon"

DAEMON=$(which rtpengine-recording)
DEFAULTS=/etc/default/${NAME}

test -f "$DAEMON" || exit 0

. /lib/lsb/init-functions

# Load startup options if available
if [ -f "$DEFAULTS" ]; then
	. "$DEFAULTS" || true
fi

[ -z "$PIDFILE" ] && PIDFILE="/run/rtpengine-recording.pid"

OPTIONS=""
START_OPTIONS=""


[ -z "$CONFIG_FILE" ] || OPTIONS="$OPTIONS --config-file=$CONFIG_FILE"
[ -z "$PIDFILE" ] || OPTIONS="$OPTIONS --pidfile=$PIDFILE"


# check if directory for pid file needs to be created

PIDDIR=$(dirname "$PIDFILE")
DO_DIR_CHOWN=0
if ! test -z "$PIDDIR" && ! test -d "$PIDDIR"; then
	mkdir -p "$PIDDIR"
	DO_DIR_CHOWN=1
fi

# handle requested setuid/setgid

if ! test -z "$SET_USER"; then
	START_OPTIONS="$START_OPTIONS --chuid $SET_USER"
	test "$DO_DIR_CHOWN" = 1 && chown "$SET_USER": "$PIDDIR"
fi

if ! test -z "$SET_GROUP"; then
	START_OPTIONS="$START_OPTIONS --group $SET_GROUP"
	test "$DO_DIR_CHOWN" = 1 && chgrp "$SET_GROUP" "$PIDDIR"
fi

###

case "$1" in
  start)
	if [ -x "$(which ngcp-check-active)" ]; then
	  case "$(ngcp-check-active -v)" in
	    active|transition)
	      log_action_msg "Active node or transition."
	      ;;
	    *)
	      log_action_msg "Ignored start action in inactive node"
	      exit 0
	      ;;
	  esac
	fi

	RC=0
	rtpengine-recording-nfs-setup start || RC=$?
	if [ "$RC" -ne 0 ] ; then
	  log_action_msg "Failed to start rtpengine-recording-nfs-setup"
	  log_end_msg "$RC"
	  exit "$RC"
	fi

	log_daemon_msg "Starting $DESC" "$NAME"

	# shellcheck disable=SC2086
	start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
		--exec "$DAEMON" $START_OPTIONS -- $OPTIONS || log_progress_msg " already running"
	log_end_msg $?
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	RC=0
	start-stop-daemon --oknodo --stop --quiet --pidfile "$PIDFILE" \
		--retry 5 --exec "$DAEMON" || RC=$?
	rm -f "$PIDFILE"
	log_end_msg "$RC"
	exit "$RC"
	;;
  force-reload|restart)
	$0 stop
	$0 start
	;;
  status)
	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
	;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0