kamailio-5.x: convert init to procd
This commit - updates init script to use procd - adds a default user 'kamailio' (kamailio will switch to this user) - introduces uci init config (instead of /etc/default/kamailio) Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
parent
72cb5b8350
commit
ebaa99518a
4 changed files with 73 additions and 48 deletions
|
@ -241,11 +241,13 @@ endef
|
||||||
define Package/kamailio5
|
define Package/kamailio5
|
||||||
$(call Package/kamailio5/Default)
|
$(call Package/kamailio5/Default)
|
||||||
TITLE:=Mature and flexible open source SIP server, v$(PKG_VERSION)
|
TITLE:=Mature and flexible open source SIP server, v$(PKG_VERSION)
|
||||||
|
USERID:=kamailio=380:kamailio=380
|
||||||
MENU:=1
|
MENU:=1
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/kamailio5/conffiles
|
define Package/kamailio5/conffiles
|
||||||
/etc/default/kamailio
|
/etc/config/kamailio
|
||||||
|
/etc/init.d/kamailio
|
||||||
/etc/kamailio/kamailio.cfg
|
/etc/kamailio/kamailio.cfg
|
||||||
/etc/kamailio/kamctlrc
|
/etc/kamailio/kamctlrc
|
||||||
endef
|
endef
|
||||||
|
@ -260,10 +262,10 @@ $(foreach c,kamailio.cfg kamctlrc,$(call Package/kamailio5/install/conffile,$(1)
|
||||||
$(CP) \
|
$(CP) \
|
||||||
$(PKG_INSTALL_DIR)/usr/lib/kamailio/lib{srdb1,srdb2,srutils}.so* \
|
$(PKG_INSTALL_DIR)/usr/lib/kamailio/lib{srdb1,srdb2,srutils}.so* \
|
||||||
$(1)/usr/lib/kamailio/
|
$(1)/usr/lib/kamailio/
|
||||||
$(INSTALL_DIR) $(1)/etc/default
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
$(INSTALL_CONF) \
|
$(INSTALL_CONF) \
|
||||||
./files/kamailio.default \
|
./files/kamailio.config \
|
||||||
$(1)/etc/default/kamailio
|
$(1)/etc/config/kamailio
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
$(INSTALL_BIN) \
|
$(INSTALL_BIN) \
|
||||||
./files/kamailio.init \
|
./files/kamailio.init \
|
||||||
|
|
12
net/kamailio-5.x/files/kamailio.config
Normal file
12
net/kamailio-5.x/files/kamailio.config
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
config kamailio 'general'
|
||||||
|
option enabled 0
|
||||||
|
option user kamailio
|
||||||
|
option group kamailio
|
||||||
|
# Amount of shared and private memory to allocate in MByte:
|
||||||
|
option shm_memory 8
|
||||||
|
option pkg_memory 2
|
||||||
|
option cfg_file /etc/kamailio/kamailio.cfg
|
||||||
|
# Any other option can be put between the quotes below:
|
||||||
|
#option options ""
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#
|
|
||||||
# Kamailio startup options
|
|
||||||
#
|
|
||||||
|
|
||||||
# Set to yes to enable kamailio, once configured properly.
|
|
||||||
#RUN_KAMAILIO=yes
|
|
||||||
|
|
||||||
# Amount of shared and private memory to allocate
|
|
||||||
# for the running Kamailio server (in Mb)
|
|
||||||
#SHM_MEMORY=64
|
|
||||||
#PKG_MEMORY=4
|
|
||||||
|
|
||||||
# Config file
|
|
||||||
#CFGFILE=/etc/kamailio/kamailio.cfg
|
|
|
@ -1,38 +1,63 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2014 OpenWrt.org
|
# Copyright (C) 2014 - 2018 OpenWrt.org
|
||||||
|
|
||||||
START=99
|
START=99
|
||||||
|
|
||||||
BINFILE=/usr/sbin/kamailio
|
NAME=kamailio
|
||||||
PIDFILE=/var/run/kamailio.pid
|
COMMAND=/usr/sbin/$NAME
|
||||||
DEFAULTS=/etc/default/kamailio
|
|
||||||
CFGFILE=/etc/kamailio/kamailio.cfg
|
|
||||||
SHM_MEMORY=8
|
|
||||||
PKG_MEMORY=2
|
|
||||||
RUN_KAMAILIO=no
|
|
||||||
|
|
||||||
start() {
|
RUNDIR=/var/run/$NAME
|
||||||
# Load startup options if available
|
PIDFILE=$RUNDIR/$NAME.pid
|
||||||
if [ -f $DEFAULTS ]; then
|
|
||||||
. $DEFAULTS
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$RUN_KAMAILIO" != "yes" ]; then
|
LOG_ERR="/usr/bin/logger -p user.err -s -t $NAME"
|
||||||
echo "[WARNING] Kamailio not yet configured. Edit /etc/default/kamailio first."
|
|
||||||
else
|
USE_PROCD=1
|
||||||
start-stop-daemon -S -x $BINFILE -b -- -P $PIDFILE -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY
|
|
||||||
echo "[INFO] Kamailio has succesfully started."
|
#PROCD_DEBUG=1
|
||||||
fi
|
|
||||||
|
start_service() {
|
||||||
|
local enabled
|
||||||
|
local user
|
||||||
|
local group
|
||||||
|
local shm_memory
|
||||||
|
local pkg_memory
|
||||||
|
local cfg_file
|
||||||
|
local options
|
||||||
|
|
||||||
|
config_load $NAME
|
||||||
|
|
||||||
|
config_get_bool enabled general enabled 0
|
||||||
|
|
||||||
|
if [ $enabled -eq 0 ]; then
|
||||||
|
$LOG_ERR service not enabled in /etc/config/$NAME
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_get user general user $NAME
|
||||||
|
config_get group general group $NAME
|
||||||
|
config_get shm_memory general shm_memory 8
|
||||||
|
config_get pkg_memory general pkg_memory 2
|
||||||
|
config_get cfg_file general cfg_file /etc/$NAME/$NAME.cfg
|
||||||
|
config_get options general options
|
||||||
|
|
||||||
|
if [ ! -d $RUNDIR ]; then
|
||||||
|
mkdir -p $RUNDIR
|
||||||
|
chown "$user":"$group" $RUNDIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command $COMMAND
|
||||||
|
procd_append_param command \
|
||||||
|
-P $PIDFILE \
|
||||||
|
-f "$cfg_file" \
|
||||||
|
-m "$shm_memory" \
|
||||||
|
-M "$pkg_memory" \
|
||||||
|
$options \
|
||||||
|
-u "$user" \
|
||||||
|
-g "$group" \
|
||||||
|
-DD -E
|
||||||
|
# forward stderr to logd
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
|
||||||
start-stop-daemon -K -x $BINFILE -p $PIDFILE -q
|
|
||||||
rm -rf $PID_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
restart(){
|
|
||||||
echo "[INFO] Restarting kamailio. Waiting 5 seconds before start."
|
|
||||||
stop
|
|
||||||
sleep 5
|
|
||||||
start
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue