diff --git a/debian/kamailio-lb.default b/debian/kamailio-lb.default deleted file mode 100644 index 89508675f..000000000 --- a/debian/kamailio-lb.default +++ /dev/null @@ -1,4 +0,0 @@ -# do not use upstream script, we have our own -# /etc/default/kamailio.* configuration, generated -# via /etc/ngcp-config/templates/etc/default/kamailio.* -RUN_KAMAILIO=no diff --git a/debian/kamailio-lb.init b/debian/kamailio-lb.init deleted file mode 100644 index d8708167d..000000000 --- a/debian/kamailio-lb.init +++ /dev/null @@ -1,280 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: kamailio-lb -# Required-Start: $syslog $network $local_fs $remote_fs $time -# 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 - -umask 0022 - -TYPE=lb -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/sbin/kamailio -NAME=kamailio -DESC=kamailio-$TYPE -HOMEDIR=/var/run/kamailio -PIDFILE=$HOMEDIR/$NAME.$TYPE.pid -DEFAULTS=/etc/default/kamailio-$TYPE -CFGFILE=/etc/kamailio/$TYPE/kamailio.cfg -RUN_KAMAILIO=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 - echo "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" - exit 1 - fi -} - -check_kamailio_config () -{ - # Check if kamailio configuration is valid before starting the server - out=$($DAEMON "${OPTIONS[@]}" -c > /dev/null 2>&1) - retcode=$? - if [ "$retcode" != '0' ]; then - echo "Not executing command for $DESC: invalid configuration file!" - echo -e "\n$out\n" - exit 1 - fi -} - -check_homedir () -{ - # Create HOMEDIR directory in case it doesn't exist - if [ ! -d $HOMEDIR ]; then - mkdir -m 0755 $HOMEDIR - fi - - # Set the appropiate owner and group - chown "${USER}:${GROUP}" "$HOMEDIR" -} - - -create_radius_seqfile () -{ - # Create a radius sequence file to be used by the radius client if - # radius accounting is enabled. This is needed to avoid any issue - # with the file not being writable if kamailio first starts as user - # root because DUMP_CORE is enabled and creates this file as user - # root and then later it switches back to user kamailio and cannot - # write to the file. If the file exists before kamailio starts, it - # won't change it's ownership and will be writable for both root - # and kamailio, no matter what options are chosen at install time - RADIUS_SEQ_FILE=$HOMEDIR/kamailio_radius.seq - - if [ ! -f $RADIUS_SEQ_FILE ]; then - touch $RADIUS_SEQ_FILE - fi - - chown "${USER}:${GROUP}" "$RADIUS_SEQ_FILE" - chmod 660 $RADIUS_SEQ_FILE -} - - -if [ ! -f $DAEMON ]; then - echo "No $DESC daemon at $DAEMON." - case "$1" in - status) - # LSB - 4: program or service status is unknown. - exit 4 - ;; - *) - # LSB - 5: program is not installed. - exit 5 - ;; - esac -fi - - -# Load startup options if available -if [ -f $DEFAULTS ]; then - . $DEFAULTS || true -fi - - -if [ "$RUN_KAMAILIO" != "yes" ]; then - echo "$DESC not yet configured. Edit /etc/default/kamailio-$TYPE first." - exit 0 -fi - - -[ -z "$SHM_MEMORY" ] && SHM_MEMORY=64 -[ -z "$PKG_MEMORY" ] && PKG_MEMORY=4 -SHM_MEMORY=${SHM_MEMORY//[^[:digit:]]/} -PKG_MEMORY=${PKG_MEMORY//[^[:digit:]]/} -[ "$SHM_MEMORY" -le 0 ] && SHM_MEMORY=64 -[ "$PKG_MEMORY" -le 0 ] && PKG_MEMORY=4 -[ -z "$USER" ] && USER=kamailio -[ -z "$GROUP" ] && GROUP=kamailio - - -if /usr/sbin/ngcp-virt-identify --type container; then - echo "container environment detected. Skip ulimit commands" -else - if [ "$DUMP_CORE" = "yes" ] ; then - # set proper ulimit - ulimit -c unlimited - fi - - # raise memlock limit, otherwise mysql client fails to initialize - ulimit -l unlimited - # raise file descriptors limit, otherwise we get "Can't send - # command to RTP proxy" on massive number of calls with RTP - ulimit -n 16384 -fi - -if [ "$SSD_SUID" != "yes" ]; then - OPTIONS=(-f "$CFGFILE" -P "$PIDFILE" -m "$SHM_MEMORY" -M "$PKG_MEMORY" -u "$USER" -g "$GROUP") - SSDOPTS=() -else - OPTIONS=(-f "$CFGFILE" -P "$PIDFILE" -m "$SHM_MEMORY" -M "$PKG_MEMORY") - SSDOPTS=(--chuid "$USER:$GROUP") -fi - - -start_kamailio_daemon () -{ - start-stop-daemon --start --quiet --pidfile $PIDFILE "${SSDOPTS[@]}" \ - --exec $DAEMON -- "${OPTIONS[@]}" - res=$? - - echo -n "$NAME " - if [ $res -eq 0 ] ; then - echo "started." - exit 0 - else - if [ ! -r "$PIDFILE" ] ; then - echo "error, failed to start." - exit 1 - elif read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then - echo "already running." - exit 0 - else - echo "error, failed to start ($PIDFILE exists)." - exit 1 - fi - fi -} - - -case "$1" in - start|debug) - if [ -x "/usr/sbin/ngcp-check-active" ] ; then - /usr/sbin/ngcp-check-active -q - status=$? - case "${status}" in - 0|3) - echo "Active node or transition." - ;; - *) - echo "Ignored start action in inactive node ($status)" - exit 0 - ;; - esac - fi - check_homedir - create_radius_seqfile - - if [ "$1" != "debug" ]; then - check_fork - fi - - echo "Starting $DESC using $CFGFILE: " - start_kamailio_daemon - ;; - - safe-stop) - check_kamailio_config - echo "Stopping $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry 5 \ - --exec $DAEMON - echo -n "$NAME " - if [ $? -eq 0 ] ; then - echo "stopped." - exit 0 - else - echo "failed to stop." - exit 1 - fi - ;; - - stop) - echo "Stopping $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry 5 \ - --exec $DAEMON - echo -n "$NAME " - if [ $? -eq 0 ] ; then - echo "stopped." - exit 0 - else - echo "failed to stop." - exit 1 - fi - ;; - - restart|force-reload) - check_kamailio_config - check_homedir - create_radius_seqfile - - echo "Restarting $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry=5 \ - --exec $DAEMON - if [ $? -ne 0 ] ; then - echo "$NAME failed to stop." - exit 1 - fi - - if [ -x "/usr/sbin/ngcp-check-active" ] ; then - /usr/sbin/ngcp-check-active -q - status=$? - case "${status}" in - 0|3) - echo "Active node or transition." - ;; - *) - echo "Ignored start action in inactive node ($status)" - exit 0 - ;; - esac - fi - - start_kamailio_daemon - ;; - - status) - echo -n "Status of $DESC: $NAME " - if [ ! -r "$PIDFILE" ] ; then - echo "is not running." - exit 3 - fi - if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then - echo "is running." - exit 0 - else - echo "is not running but $PIDFILE exists." - exit 1 - fi - ;; - - check-config) - echo -n "Checking config for $DESC: " - check_kamailio_config - echo "config is OK" - exit 0 - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|safe-stop|restart|force-reload|debug|check-config|status}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/kamailio-lb.service b/debian/kamailio-lb.service new file mode 100644 index 000000000..7723f025b --- /dev/null +++ b/debian/kamailio-lb.service @@ -0,0 +1,30 @@ +[Unit] +Description=Kamailio (OpenSER) - the Open Source SIP Server, LB +After=network-online.target +After=remote-fs.target +After=time-sync.target +Requires=network-online.target +Requires=remote-fs.target +Requires=time-sync.target + +[Service] +Type=simple +User=kamailio +Group=kamailio +PIDFile=/run/kamailio/kamailio.lb.pid +Environment='CFGFILE=/etc/kamailio/lb/kamailio.cfg' +# Values of SHM_MEMORY=64 and PKG_MEMORY=16 taken from old sysvinit file +# Amount of shared memory to allocate for the running Kamailio server (in MiB) +Environment='SHM_MEMORY=64' +# Amount of private memory for each Kamailio process (in MiB) +Environment='PKG_MEMORY=16' +# Check if config OK before starting +ExecStartPre=/usr/sbin/kamailio -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -c +# -DD means to not daemonise +ExecStart=/usr/sbin/kamailio -P /run/kamailio/kamailio.lb.pid -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -DD +Restart=on-abort +LimitMEMLOCK=infinity +LimitNOFILE=16384 + +[Install] +WantedBy=multi-user.target diff --git a/debian/kamailio-proxy.default b/debian/kamailio-proxy.default deleted file mode 100644 index 89508675f..000000000 --- a/debian/kamailio-proxy.default +++ /dev/null @@ -1,4 +0,0 @@ -# do not use upstream script, we have our own -# /etc/default/kamailio.* configuration, generated -# via /etc/ngcp-config/templates/etc/default/kamailio.* -RUN_KAMAILIO=no diff --git a/debian/kamailio-proxy.init b/debian/kamailio-proxy.init deleted file mode 100644 index 761d3b662..000000000 --- a/debian/kamailio-proxy.init +++ /dev/null @@ -1,282 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: kamailio-proxy -# Required-Start: $syslog $network $local_fs $time $remote_fs -# Required-Stop: $syslog $network $local_fs $remote_fs -# Should-Start: mysql -# Should-Stop: mysql -# 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 - -umask 0022 - -TYPE=proxy -PATH=/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/sbin/kamailio -NAME=kamailio -DESC=kamailio-$TYPE -HOMEDIR=/var/run/kamailio -PIDFILE=$HOMEDIR/$NAME.$TYPE.pid -DEFAULTS=/etc/default/kamailio-$TYPE -CFGFILE=/etc/kamailio/$TYPE/kamailio.cfg -RUN_KAMAILIO=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 - echo "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" - exit 1 - fi -} - -check_kamailio_config () -{ - # Check if kamailio configuration is valid before starting the server - out=$($DAEMON "${OPTIONS[@]}" -c > /dev/null 2>&1) - retcode=$? - if [ "$retcode" != '0' ]; then - echo "Not executing command for $DESC: invalid configuration file!" - echo -e "\n$out\n" - exit 1 - fi -} - -check_homedir () -{ - # Create HOMEDIR directory in case it doesn't exist - if [ ! -d $HOMEDIR ]; then - mkdir -m 0755 $HOMEDIR - fi - - # Set the appropiate owner and group - chown "${USER}:${GROUP}" "$HOMEDIR" -} - - -create_radius_seqfile () -{ - # Create a radius sequence file to be used by the radius client if - # radius accounting is enabled. This is needed to avoid any issue - # with the file not being writable if kamailio first starts as user - # root because DUMP_CORE is enabled and creates this file as user - # root and then later it switches back to user kamailio and cannot - # write to the file. If the file exists before kamailio starts, it - # won't change it's ownership and will be writable for both root - # and kamailio, no matter what options are chosen at install time - RADIUS_SEQ_FILE=$HOMEDIR/kamailio_radius.seq - - if [ ! -f $RADIUS_SEQ_FILE ]; then - touch $RADIUS_SEQ_FILE - fi - - chown "${USER}:${GROUP}" "$RADIUS_SEQ_FILE" - chmod 660 $RADIUS_SEQ_FILE -} - - -if [ ! -f $DAEMON ]; then - echo "No $DESC daemon at $DAEMON." - case "$1" in - status) - # LSB - 4: program or service status is unknown. - exit 4 - ;; - *) - # LSB - 5: program is not installed. - exit 5 - ;; - esac -fi - - -# Load startup options if available -if [ -f $DEFAULTS ]; then - . $DEFAULTS || true -fi - - -if [ "$RUN_KAMAILIO" != "yes" ]; then - echo "$DESC not yet configured. Edit /etc/default/kamailio-$TYPE first." - exit 0 -fi - - -[ -z "$SHM_MEMORY" ] && SHM_MEMORY=64 -[ -z "$PKG_MEMORY" ] && PKG_MEMORY=4 -SHM_MEMORY=${SHM_MEMORY//[^[:digit:]]/} -PKG_MEMORY=${PKG_MEMORY//[^[:digit:]]/} -[ "$SHM_MEMORY" -le 0 ] && SHM_MEMORY=64 -[ "$PKG_MEMORY" -le 0 ] && PKG_MEMORY=4 -[ -z "$USER" ] && USER=kamailio -[ -z "$GROUP" ] && GROUP=kamailio - - -if /usr/sbin/ngcp-virt-identify --type container; then - echo "container environment detected. Skip ulimit commands" -else - if [ "$DUMP_CORE" = "yes" ] ; then - # set proper ulimit - ulimit -c unlimited - fi - - # raise memlock limit, otherwise mysql client fails to initialize - ulimit -l unlimited - # raise file descriptors limit, otherwise we get "Can't send - # command to RTP proxy" on massive number of calls with RTP - ulimit -n 16384 -fi - -if [ "$SSD_SUID" != "yes" ]; then - OPTIONS=(-f "$CFGFILE" -P "$PIDFILE" -m "$SHM_MEMORY" -M "$PKG_MEMORY" -u "$USER" -g "$GROUP") - SSDOPTS=() -else - OPTIONS=(-f "$CFGFILE" -P "$PIDFILE" -m "$SHM_MEMORY" -M "$PKG_MEMORY") - SSDOPTS=(--chuid "$USER:$GROUP") -fi - - -start_kamailio_daemon () -{ - start-stop-daemon --start --quiet --pidfile $PIDFILE "${SSDOPTS[@]}" \ - --exec $DAEMON -- "${OPTIONS[@]}" - res=$? - - echo -n "$NAME " - if [ $res -eq 0 ] ; then - echo "started." - exit 0 - else - if [ ! -r "$PIDFILE" ] ; then - echo "error, failed to start." - exit 1 - elif read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then - echo "already running." - exit 0 - else - echo "error, failed to start ($PIDFILE exists)." - exit 1 - fi - fi -} - - -case "$1" in - start|debug) - if [ -x "/usr/sbin/ngcp-check-active" ] ; then - /usr/sbin/ngcp-check-active -q - status=$? - case "${status}" in - 0|3) - echo "Active node or transition." - ;; - *) - echo "Ignored start action in inactive node ($status)" - exit 0 - ;; - esac - fi - check_homedir - create_radius_seqfile - - if [ "$1" != "debug" ]; then - check_fork - fi - - echo "Starting $DESC using $CFGFILE: " - start_kamailio_daemon - ;; - - safe-stop) - check_kamailio_config - echo "Stopping $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry 5 \ - --exec $DAEMON - echo -n "$NAME " - if [ $? -eq 0 ] ; then - echo "stopped." - exit 0 - else - echo "failed to stop." - exit 1 - fi - ;; - - stop) - echo "Stopping $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry 5 \ - --exec $DAEMON - echo -n "$NAME " - if [ $? -eq 0 ] ; then - echo "stopped." - exit 0 - else - echo "failed to stop." - exit 1 - fi - ;; - - restart|force-reload) - check_kamailio_config - check_homedir - create_radius_seqfile - - echo "Restarting $DESC:" - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE --retry=5 \ - --exec $DAEMON - if [ $? -ne 0 ] ; then - echo "$NAME failed to stop." - exit 1 - fi - - if [ -x "/usr/sbin/ngcp-check-active" ] ; then - /usr/sbin/ngcp-check-active -q - status=$? - case "${status}" in - 0|3) - echo "Active node or transition." - ;; - *) - echo "Ignored start action in inactive node ($status)" - exit 0 - ;; - esac - fi - - start_kamailio_daemon - ;; - - status) - echo -n "Status of $DESC: $NAME " - if [ ! -r "$PIDFILE" ] ; then - echo "is not running." - exit 3 - fi - if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then - echo "is running." - exit 0 - else - echo "is not running but $PIDFILE exists." - exit 1 - fi - ;; - - check-config) - echo -n "Checking config for $DESC: " - check_kamailio_config - echo "config is OK" - exit 0 - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|safe-stop|restart|force-reload|debug|check-config|status}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/kamailio-proxy.service b/debian/kamailio-proxy.service new file mode 100644 index 000000000..2cada1b71 --- /dev/null +++ b/debian/kamailio-proxy.service @@ -0,0 +1,30 @@ +[Unit] +Description=Kamailio (OpenSER) - the Open Source SIP Server, Proxy +After=mariadb.service +After=network-online.target +After=remote-fs.target +Requires=mariadb.service +Requires=network-online.target +Requires=remote-fs.target + +[Service] +Type=simple +User=kamailio +Group=kamailio +PIDFile=/run/kamailio/kamailio.proxy.pid +Environment='CFGFILE=/etc/kamailio/proxy/kamailio.cfg' +# Values of SHM_MEMORY=125 and PKG_MEMORY=32 taken from old sysvinit file +# Amount of shared memory to allocate for the running Kamailio server (in MiB) +Environment='SHM_MEMORY=125' +# Amount of private memory for each Kamailio process (in MiB) +Environment='PKG_MEMORY=32' +# Check if config OK before starting +ExecStartPre=/usr/sbin/kamailio -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -c +# -DD means to not daemonise +ExecStart=/usr/sbin/kamailio -P /run/kamailio/kamailio.proxy.pid -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -DD +Restart=on-abort +LimitMEMLOCK=infinity +LimitNOFILE=16384 + +[Install] +WantedBy=multi-user.target diff --git a/debian/ngcp-kamailio-radius-modules.tmpfile b/debian/ngcp-kamailio-radius-modules.tmpfile new file mode 100644 index 000000000..89ab094f9 --- /dev/null +++ b/debian/ngcp-kamailio-radius-modules.tmpfile @@ -0,0 +1,2 @@ +# /run/kamailio created as tmpfile in "ngcp-kamailio" package +f /run/kamailio/kamailio_radius.seq 0660 kamailio kamailio diff --git a/debian/ngcp-kamailio.lintian-overrides b/debian/ngcp-kamailio.lintian-overrides index 427d83fc7..96e24ae88 100644 --- a/debian/ngcp-kamailio.lintian-overrides +++ b/debian/ngcp-kamailio.lintian-overrides @@ -1,2 +1,4 @@ ngcp-kamailio: postrm-contains-additional-updaterc.d-calls etc/init.d/kamailio-proxy ngcp-kamailio: postrm-contains-additional-updaterc.d-calls etc/init.d/kamailio-lb +ngcp-kamailio: init.d-script-not-included-in-package etc/init.d/kamailio-proxy +ngcp-kamailio: init.d-script-not-included-in-package etc/init.d/kamailio-lb diff --git a/debian/ngcp-kamailio.maintscript b/debian/ngcp-kamailio.maintscript new file mode 100644 index 000000000..d1805c074 --- /dev/null +++ b/debian/ngcp-kamailio.maintscript @@ -0,0 +1,4 @@ +rm_conffile /etc/default/kamailio-lb 5.1.2-1+0~mr6.3~ ngcp-kamailio +rm_conffile /etc/default/kamailio-proxy 5.1.2-1+0~mr6.3~ ngcp-kamailio +rm_conffile /etc/init.d/kamailio-lb 5.1.2-1+0~mr6.3~ ngcp-kamailio +rm_conffile /etc/init.d/kamailio-proxy 5.1.2-1+0~mr6.3~ ngcp-kamailio diff --git a/debian/ngcp-kamailio.tmpfile b/debian/ngcp-kamailio.tmpfile new file mode 100644 index 000000000..e66fa3d40 --- /dev/null +++ b/debian/ngcp-kamailio.tmpfile @@ -0,0 +1 @@ +d /run/kamailio 0755 kamailio kamailio