Browse code

pkg/kamailio/deb: init script. Get back SHM_MEMORY PKG_MEMORY and CFGFILE

Victor Seva authored on 21/02/2014 10:42:27
Showing 10 changed files
... ...
@@ -11,8 +11,13 @@
11 11
 # Group to run as
12 12
 #GROUP=kamailio
13 13
 
14
-# Amount of memory to allocate for the running Kamailio server (in Mb)
15
-#MEMORY=64
14
+# Amount of shared and private memory to allocate
15
+# for the running Kamailio server (in Mb)
16
+#SHM_MEMORY=64
17
+#PKG_MEMORY=4
18
+
19
+# Config file
20
+#CFGFILE=/etc/kamailio/kamailio.cfg
16 21
 
17 22
 # Enable the server to leave a core file when it crashes.
18 23
 # Set this to 'yes' to enable Kamailio to leave a core file when it crashes
... ...
@@ -21,18 +21,21 @@ DESC="Kamailio SIP server"
21 21
 HOMEDIR=/var/run/kamailio
22 22
 PIDFILE=$HOMEDIR/$NAME.pid
23 23
 DEFAULTS=/etc/default/kamailio
24
+CFGFILE=/etc/kamailio/kamailio.cfg
24 25
 RUN_KAMAILIO=no
25 26
 USER=kamailio
26 27
 GROUP=kamailio
27
-# Amount of memory to allocate for the running Kamailio server (in Mb)
28
-MEMORY=64
28
+# Amount of shared and private memory to allocate
29
+# for the running Kamailio server (in Mb)
30
+SHM_MEMORY=64
31
+PKG_MEMORY=4
29 32
 DUMP_CORE=no
30 33
 
31 34
 # Do not start kamailio if fork=no is set in the config file
32 35
 # otherwise the boot process will just stop
33 36
 check_fork ()
34 37
 {
35
-    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
38
+    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
36 39
 	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
37 40
 	exit 0
38 41
     fi
... ...
@@ -42,7 +45,7 @@ check_kamailio_config ()
42 45
 {
43 46
 	# Check if kamailio configuration is valid before starting the server
44 47
 	set +e
45
-	out=$($DAEMON -c 2>&1 > /dev/null)
48
+	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
46 49
 	retcode=$?
47 50
 	set -e
48 51
 	if [ "$retcode" != '0' ]; then
... ...
@@ -91,10 +94,12 @@ fi
91 94
 
92 95
 set -e
93 96
 
94
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
97
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
98
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
95 99
 [ -z "$USER" ]  && USER=kamailio
96 100
 [ -z "$GROUP" ] && GROUP=kamailio
97
-[ $MEMORY -le 0 ] && MEMORY=32
101
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
102
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
98 103
 
99 104
 if test "$DUMP_CORE" = "yes" ; then
100 105
     # set proper ulimit
... ...
@@ -112,7 +117,7 @@ if [ ! -d $HOMEDIR ]; then
112 117
     mkdir -p $HOMEDIR
113 118
 fi
114 119
 
115
-OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
120
+OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
116 121
 
117 122
 case "$1" in
118 123
   start|debug)
... ...
@@ -11,8 +11,13 @@
11 11
 # Group to run as
12 12
 #GROUP=kamailio
13 13
 
14
-# Amount of memory to allocate for the running Kamailio server (in Mb)
15
-#MEMORY=64
14
+# Amount of shared and private memory to allocate
15
+# for the running Kamailio server (in Mb)
16
+#SHM_MEMORY=64
17
+#PKG_MEMORY=4
18
+
19
+# Config file
20
+#CFGFILE=/etc/kamailio/kamailio.cfg
16 21
 
17 22
 # Enable the server to leave a core file when it crashes.
18 23
 # Set this to 'yes' to enable Kamailio to leave a core file when it crashes
... ...
@@ -21,18 +21,21 @@ DESC="Kamailio SIP server"
21 21
 HOMEDIR=/var/run/kamailio
22 22
 PIDFILE=$HOMEDIR/$NAME.pid
23 23
 DEFAULTS=/etc/default/kamailio
24
+CFGFILE=/etc/kamailio/kamailio.cfg
24 25
 RUN_KAMAILIO=no
25 26
 USER=kamailio
26 27
 GROUP=kamailio
27
-# Amount of memory to allocate for the running Kamailio server (in Mb)
28
-MEMORY=64
28
+# Amount of shared and private memory to allocate
29
+# for the running Kamailio server (in Mb)
30
+SHM_MEMORY=64
31
+PKG_MEMORY=4
29 32
 DUMP_CORE=no
30 33
 
31 34
 # Do not start kamailio if fork=no is set in the config file
32 35
 # otherwise the boot process will just stop
33 36
 check_fork ()
34 37
 {
35
-    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
38
+    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
36 39
 	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
37 40
 	exit 0
38 41
     fi
... ...
@@ -42,7 +45,7 @@ check_kamailio_config ()
42 45
 {
43 46
 	# Check if kamailio configuration is valid before starting the server
44 47
 	set +e
45
-	out=$($DAEMON -c 2>&1 > /dev/null)
48
+	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
46 49
 	retcode=$?
47 50
 	set -e
48 51
 	if [ "$retcode" != '0' ]; then
... ...
@@ -91,10 +94,12 @@ fi
91 94
 
92 95
 set -e
93 96
 
94
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
97
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
98
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
95 99
 [ -z "$USER" ]  && USER=kamailio
96 100
 [ -z "$GROUP" ] && GROUP=kamailio
97
-[ $MEMORY -le 0 ] && MEMORY=32
101
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
102
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
98 103
 
99 104
 if test "$DUMP_CORE" = "yes" ; then
100 105
     # set proper ulimit
... ...
@@ -112,7 +117,7 @@ if [ ! -d $HOMEDIR ]; then
112 117
     mkdir -p $HOMEDIR
113 118
 fi
114 119
 
115
-OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
120
+OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
116 121
 
117 122
 case "$1" in
118 123
   start|debug)
... ...
@@ -11,8 +11,13 @@
11 11
 # Group to run as
12 12
 #GROUP=kamailio
13 13
 
14
-# Amount of memory to allocate for the running Kamailio server (in Mb)
15
-#MEMORY=64
14
+# Amount of shared and private memory to allocate
15
+# for the running Kamailio server (in Mb)
16
+#SHM_MEMORY=64
17
+#PKG_MEMORY=4
18
+
19
+# Config file
20
+#CFGFILE=/etc/kamailio/kamailio.cfg
16 21
 
17 22
 # Enable the server to leave a core file when it crashes.
18 23
 # Set this to 'yes' to enable Kamailio to leave a core file when it crashes
... ...
@@ -21,18 +21,21 @@ DESC="Kamailio SIP server"
21 21
 HOMEDIR=/var/run/kamailio
22 22
 PIDFILE=$HOMEDIR/$NAME.pid
23 23
 DEFAULTS=/etc/default/kamailio
24
+CFGFILE=/etc/kamailio/kamailio.cfg
24 25
 RUN_KAMAILIO=no
25 26
 USER=kamailio
26 27
 GROUP=kamailio
27
-# Amount of memory to allocate for the running Kamailio server (in Mb)
28
-MEMORY=64
28
+# Amount of shared and private memory to allocate
29
+# for the running Kamailio server (in Mb)
30
+SHM_MEMORY=64
31
+PKG_MEMORY=4
29 32
 DUMP_CORE=no
30 33
 
31 34
 # Do not start kamailio if fork=no is set in the config file
32 35
 # otherwise the boot process will just stop
33 36
 check_fork ()
34 37
 {
35
-    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
38
+    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
36 39
 	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
37 40
 	exit 0
38 41
     fi
... ...
@@ -42,7 +45,7 @@ check_kamailio_config ()
42 45
 {
43 46
 	# Check if kamailio configuration is valid before starting the server
44 47
 	set +e
45
-	out=$($DAEMON -c 2>&1 > /dev/null)
48
+	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
46 49
 	retcode=$?
47 50
 	set -e
48 51
 	if [ "$retcode" != '0' ]; then
... ...
@@ -91,10 +94,12 @@ fi
91 94
 
92 95
 set -e
93 96
 
94
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
97
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
98
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
95 99
 [ -z "$USER" ]  && USER=kamailio
96 100
 [ -z "$GROUP" ] && GROUP=kamailio
97
-[ $MEMORY -le 0 ] && MEMORY=32
101
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
102
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
98 103
 
99 104
 if test "$DUMP_CORE" = "yes" ; then
100 105
     # set proper ulimit
... ...
@@ -112,7 +117,7 @@ if [ ! -d $HOMEDIR ]; then
112 117
     mkdir -p $HOMEDIR
113 118
 fi
114 119
 
115
-OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
120
+OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
116 121
 
117 122
 case "$1" in
118 123
   start|debug)
... ...
@@ -11,8 +11,13 @@
11 11
 # Group to run as
12 12
 #GROUP=kamailio
13 13
 
14
-# Amount of memory to allocate for the running Kamailio server (in Mb)
15
-#MEMORY=64
14
+# Amount of shared and private memory to allocate
15
+# for the running Kamailio server (in Mb)
16
+#SHM_MEMORY=64
17
+#PKG_MEMORY=4
18
+
19
+# Config file
20
+#CFGFILE=/etc/kamailio/kamailio.cfg
16 21
 
17 22
 # Enable the server to leave a core file when it crashes.
18 23
 # Set this to 'yes' to enable Kamailio to leave a core file when it crashes
... ...
@@ -21,18 +21,21 @@ DESC="Kamailio SIP server"
21 21
 HOMEDIR=/var/run/kamailio
22 22
 PIDFILE=$HOMEDIR/$NAME.pid
23 23
 DEFAULTS=/etc/default/kamailio
24
+CFGFILE=/etc/kamailio/kamailio.cfg
24 25
 RUN_KAMAILIO=no
25 26
 USER=kamailio
26 27
 GROUP=kamailio
27
-# Amount of memory to allocate for the running Kamailio server (in Mb)
28
-MEMORY=64
28
+# Amount of shared and private memory to allocate
29
+# for the running Kamailio server (in Mb)
30
+SHM_MEMORY=64
31
+PKG_MEMORY=4
29 32
 DUMP_CORE=no
30 33
 
31 34
 # Do not start kamailio if fork=no is set in the config file
32 35
 # otherwise the boot process will just stop
33 36
 check_fork ()
34 37
 {
35
-    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
38
+    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
36 39
 	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
37 40
 	exit 0
38 41
     fi
... ...
@@ -42,7 +45,7 @@ check_kamailio_config ()
42 45
 {
43 46
 	# Check if kamailio configuration is valid before starting the server
44 47
 	set +e
45
-	out=$($DAEMON -c 2>&1 > /dev/null)
48
+	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
46 49
 	retcode=$?
47 50
 	set -e
48 51
 	if [ "$retcode" != '0' ]; then
... ...
@@ -91,10 +94,12 @@ fi
91 94
 
92 95
 set -e
93 96
 
94
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
97
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
98
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
95 99
 [ -z "$USER" ]  && USER=kamailio
96 100
 [ -z "$GROUP" ] && GROUP=kamailio
97
-[ $MEMORY -le 0 ] && MEMORY=32
101
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
102
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
98 103
 
99 104
 if test "$DUMP_CORE" = "yes" ; then
100 105
     # set proper ulimit
... ...
@@ -112,7 +117,7 @@ if [ ! -d $HOMEDIR ]; then
112 117
     mkdir -p $HOMEDIR
113 118
 fi
114 119
 
115
-OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
120
+OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
116 121
 
117 122
 case "$1" in
118 123
   start|debug)
... ...
@@ -11,8 +11,13 @@
11 11
 # Group to run as
12 12
 #GROUP=kamailio
13 13
 
14
-# Amount of memory to allocate for the running Kamailio server (in Mb)
15
-#MEMORY=64
14
+# Amount of shared and private memory to allocate
15
+# for the running Kamailio server (in Mb)
16
+#SHM_MEMORY=64
17
+#PKG_MEMORY=4
18
+
19
+# Config file
20
+#CFGFILE=/etc/kamailio/kamailio.cfg
16 21
 
17 22
 # Enable the server to leave a core file when it crashes.
18 23
 # Set this to 'yes' to enable Kamailio to leave a core file when it crashes
... ...
@@ -21,18 +21,21 @@ DESC="Kamailio SIP server"
21 21
 HOMEDIR=/var/run/kamailio
22 22
 PIDFILE=$HOMEDIR/$NAME.pid
23 23
 DEFAULTS=/etc/default/kamailio
24
+CFGFILE=/etc/kamailio/kamailio.cfg
24 25
 RUN_KAMAILIO=no
25 26
 USER=kamailio
26 27
 GROUP=kamailio
27
-# Amount of memory to allocate for the running Kamailio server (in Mb)
28
-MEMORY=64
28
+# Amount of shared and private memory to allocate
29
+# for the running Kamailio server (in Mb)
30
+SHM_MEMORY=64
31
+PKG_MEMORY=4
29 32
 DUMP_CORE=no
30 33
 
31 34
 # Do not start kamailio if fork=no is set in the config file
32 35
 # otherwise the boot process will just stop
33 36
 check_fork ()
34 37
 {
35
-    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
38
+    if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFGFILE; then
36 39
 	log_failure_msg "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
37 40
 	exit 0
38 41
     fi
... ...
@@ -42,7 +45,7 @@ check_kamailio_config ()
42 45
 {
43 46
 	# Check if kamailio configuration is valid before starting the server
44 47
 	set +e
45
-	out=$($DAEMON -c 2>&1 > /dev/null)
48
+	out=$($DAEMON -f $CFGFILE -M $PKG_MEMORY -c 2>&1 > /dev/null)
46 49
 	retcode=$?
47 50
 	set -e
48 51
 	if [ "$retcode" != '0' ]; then
... ...
@@ -91,10 +94,12 @@ fi
91 94
 
92 95
 set -e
93 96
 
94
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
97
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
98
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
95 99
 [ -z "$USER" ]  && USER=kamailio
96 100
 [ -z "$GROUP" ] && GROUP=kamailio
97
-[ $MEMORY -le 0 ] && MEMORY=32
101
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64
102
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
98 103
 
99 104
 if test "$DUMP_CORE" = "yes" ; then
100 105
     # set proper ulimit
... ...
@@ -112,7 +117,7 @@ if [ ! -d $HOMEDIR ]; then
112 117
     mkdir -p $HOMEDIR
113 118
 fi
114 119
 
115
-OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
120
+OPTIONS="-f $CFGFILE -P $PIDFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
116 121
 
117 122
 case "$1" in
118 123
   start|debug)