This file is indexed.

/etc/init.d/kamailio is in kamailio 4.4.4-2+deb9u3.

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
#! /bin/sh
#
### BEGIN INIT INFO
# Provides:          kamailio
# Required-Start:    $syslog $network $local_fs $remote_fs $time
# Should-Start:      $named slapd mysql postgresql snmpd radiusd
# Should-Stop:       $named slapd mysql postgresql snmpd radiusd
# Required-Stop:     $syslog $network $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the Kamailio SIP proxy server
# Description:       Start the Kamailio SIP proxy server
### END INIT INFO

. /lib/lsb/init-functions

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/kamailio
NAME=`basename "$0"`
DESC="Kamailio SIP Server"
HOMEDIR=/var/run/$NAME
PIDFILE=$HOMEDIR/$NAME.pid
DEFAULTS=/etc/default/$NAME
CFGFILE=/etc/$NAME/kamailio.cfg
RUN_KAMAILIO=no
USER=kamailio
GROUP=kamailio
# Amount of shared and private memory to allocate
# for the running Kamailio server (in Mb)
SHM_MEMORY=64
PKG_MEMORY=8
DUMP_CORE=no

# Do not start kamailio if fork=no is set in the config file
# otherwise the boot process will just stop
check_fork ()
{
    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
	exit 0
    fi
}

check_kamailio_config ()
{
	# Check if kamailio configuration is valid before starting the server
	set +e
	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
	retcode=$?
	set -e
	if [ "$retcode" != '0' ]; then
	    log_failure_msg "Not starting $DESC: invalid configuration file!"
	    log_failure_msg
	    log_failure_msg "$out"
	    log_failure_msg
	    exit 1
	fi
}

test -f $DAEMON || exit 0

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

if [ "$RUN_KAMAILIO" != "yes" ]; then
    log_failure_msg "Kamailio not yet configured. Edit /etc/default/$NAME first."
    exit 0
fi

set -e

SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
[ -z "$USER" ]  && USER=kamailio
[ -z "$GROUP" ] && GROUP=kamailio
[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4

if test "$DUMP_CORE" = "yes" ; then
    # set proper ulimit
    ulimit -c unlimited

    # directory for the core dump files
    # COREDIR=/home/corefiles
    # [ -d $COREDIR ] || mkdir $COREDIR
    # chmod 777 $COREDIR
    # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
fi

# /var/run can be a tmpfs
if [ ! -d $HOMEDIR ]; then
    mkdir -p $HOMEDIR
    chown ${USER}:${GROUP} $HOMEDIR
fi

OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"

case "$1" in
  start|debug)
	check_kamailio_config

	if [ "$1" != "debug" ]; then
	    check_fork
	fi

	log_daemon_msg "Starting $DESC: $NAME"
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--exec $DAEMON -- $OPTIONS || log_failure_msg " already running"
	log_end_msg 0
	;;
  stop)
	log_daemon_msg "Stopping $DESC: $NAME"
	start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
		--exec $DAEMON
	log_end_msg 0
	;;
  restart|force-reload)
	check_kamailio_config

	$0 stop
	sleep 1
	$0 start
	;;
  status)
	log_daemon_msg "Status of $DESC: "

	status_of_proc -p"$PIDFILE" $NAME $NAME
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload|status|debug}" >&2
	exit 1
	;;
esac

exit 0