This file is indexed.

/etc/init.d/asterisk is in asterisk 1:13.14.1~dfsg-2+deb9u4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/sh
#
# asterisk	start the asterisk PBX
# (c) Mark Purcell <msp@debian.org>
# (c) Tzafrir Cohen <tzafrir.cohen@xorcom.com>
# (c) Faidon Liambotis <paravoid@debian.org>
#
#   This package is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
### BEGIN INIT INFO
# Provides:          asterisk
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      $syslog $network $named mysql postgresql dahdi
# Should-Stop:       $syslog $network $named mysql postgresql
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Asterisk PBX
# Description:       Controls the Asterisk PBX
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=asterisk
USER=$NAME
GROUP=$USER
DAEMON=/usr/sbin/$NAME
CANARY=/usr/sbin/astcanary
DESC="Asterisk PBX"
PIDFILE="/var/run/asterisk/asterisk.pid"
ASTSAFE_PIDFILE="/var/run/asterisk/asterisk_safe.pid"
UMASK=007 # by default
#MAXFILES=1024 # (the system default)

. /lib/lsb/init-functions

# by default: use real-time priority
PARAMS=""
CHDIR_PARM=""
AST_REALTIME="yes"
RUNASTERISK="yes"
AST_DUMPCORE="no"
AST_DUMPCORE_DIR="/var/spool/asterisk" # only used if AST_DUMPCORE != no
# core_pattern. See: http://lxr.linux.no/source/Documentation/sysctl/kernel.txt
#CORE_PATTERN=
if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME; fi

if [ "$RUNASTERISK" != "yes" ];then
	echo "Asterisk not yet configured. Edit /etc/default/asterisk first."
	exit 0
fi

if [ "$AST_REALTIME" != "no" ]
then
  PARAMS="$PARAMS -p"
fi

if [ "$AST_DUMPCORE" != "no" ]
then
	PARAMS="$PARAMS -g"
	if [ "$CORE_PATTERN" != '' ]
	then
		echo "$CORE_PATTERN" >/proc/sys/kernel/core_pattern
	fi
	if [ -d "$AST_DUMPCORE_DIR" ]
	then
		CHDIR_PARM="--chdir $AST_DUMPCORE_DIR"
	fi
fi

if [ "x$USER" = "x" ]
then
  echo "Error: empty USER name"
  exit 1
fi
if [ `id -u "$USER"` = 0 ]
then
  echo "Starting as root not supported."
  exit 1
fi
PARAMS="$PARAMS -U $USER"

if [ "x$AST_DEBUG_PARAMS" = x ] 
then
  AST_DEBUG_PARAMS=-cvvvvvddddd
fi
if [ "$RUNASTSAFE" = "yes" ];then
	# The value of WRAPPER_DAEMON in can be set in /etc/default/asterisk
	WRAPPER_DAEMON=${WRAPPER_DAEMON:-/usr/sbin/safe_asterisk}
	REALDAEMON="$WRAPPER_DAEMON"
else
	REALDAEMON="$DAEMON"
fi

test -x $DAEMON || exit 0

for dir in /var/run/asterisk /var/log/asterisk /var/log/asterisk/cdr-csv /var/log/asterisk/cdr-custom; do
	[ -d $dir ] || install -d -o $USER -g $GROUP $dir
	[ -x /sbin/restorecon ] && /sbin/restorecon $dir
done

set -e

if [ "$UMASK" != '' ]
then
	umask $UMASK
fi

# allow changing the per-process open files limit:
if [ "$MAXFILES" != '' ]
then
	ulimit -n $MAXFILES
fi

status() {
	status_of_proc -p "$PIDFILE" "$NAME" "$DESC" && return 0 || return $?
}

asterisk_rx() {
	if ! status >/dev/null; then return 0; fi

	# if $HOME is set, asterisk -rx writes a .asterisk_history there
	(
		unset HOME
		$DAEMON -rx "$1"
	)
}

case "$1" in
  debug)
	# we add too many special parameters that I don't want to skip
	# accidentally. I'm afraid that skipping -U once may cause
	# confusing results. I also want to maintain the user's choice
	# of -p
	echo "Debugging $DESC: "
	$DAEMON $PARAMS $AST_DEBUG_PARAMS
	exit 0
	;;
  start)
	if status > /dev/null; then
		echo "$DESC is already running. Use restart."
		exit 0
	fi
	echo -n "Starting $DESC: "
	if [ "$RUNASTSAFE" != "yes" ];then
		# TODO: what if we cought the wrapper just as its asterisk
		# was killed? status should check for the wrapper if we're in
		# "safe mode"
		if status > /dev/null; then
			echo "$DESC is already running. Use restart."
			exit 0
		fi
		start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
			$CHDIR_PARM \
			--exec $REALDAEMON -- $PARAMS > /dev/null
	else
		export ASTSAFE_FOREGROUND=1
		start-stop-daemon --start --group $GROUP \
			--background --make-pidfile \
			$CHDIR_PARM --pidfile "$ASTSAFE_PIDFILE" \
			--exec $REALDAEMON -- $PARAMS
	fi
		
	
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: $NAME"
	# Try gracefully.
	# this may hang in some cases. Specifically, when the asterisk
	# processes is stopped. No bother to worry about cleanup: 
	# it will either fail or die when asterisk dies.
	( asterisk_rx 'core stop now' > /dev/null 2>&1 & ) &
	if [ "$RUNASTSAFE" = "yes" ];then
		start-stop-daemon --stop --quiet --oknodo \
				  --pidfile $ASTSAFE_PIDFILE
		rm -f $ASTSAFE_PIDFILE
	fi
	start-stop-daemon --stop --quiet --oknodo --exec $DAEMON --pidfile=$PIDFILE
	echo "."
	;;
  reload)
	echo "Reloading $DESC configuration files."
	asterisk_rx 'module reload'
	;;
  logger-reload)
	asterisk_rx 'logger reload'
	;;
  extensions-reload|dialplan-reload)
	echo "Reloading $DESC configuration files."
	asterisk_rx 'dialplan reload'
	;;
  restart-convenient)
	asterisk_rx 'core restart when convenient'
	;;
  restart|force-reload)
	$0 stop
	$0 start
	;;
  status)
	status
	exit $?
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|status|debug|logger-reload|extensions-reload|restart-convenient|force-reload}" >&2
	exit 1
	;;
esac

exit 0