Browse Source

- Improved Debian init script:
- Added a function 'check_homedir()' to check if HOMEDIR (/var/run/kamailio/) exists and creates it if not (closes bug #2663516 reported by thomasmangin)
- Improved 'create_radius_seqfile()' by using HOMEDIR variable


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5669 689a6050-402a-0410-94f2-e92a70836424

Inaki Baz Castillo 16 years ago
parent
commit
9b38fc4b3b

+ 20 - 9
pkg/kamailio/debian-etch/kamailio.init

@@ -48,6 +48,18 @@ check_kamailio_config ()
 	fi
 }
 
+check_homedir ()
+{
+    # Create HOMEDIR directory in case it doesn't exist
+    if [ ! -d $HOMEDIR ]; then
+        mkdir $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
@@ -58,17 +70,14 @@ create_radius_seqfile ()
     # 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=/var/run/kamailio/kamailio_radius.seq
-    if [ -d /var/run/kamailio ]; then
-	chown ${USER}:${GROUP} /var/run/kamailio
-
-	if [ ! -f $RADIUS_SEQ_FILE ]; then
-	    touch $RADIUS_SEQ_FILE
-	fi
+    RADIUS_SEQ_FILE=$HOMEDIR/kamailio_radius.seq
 
-	chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
-	chmod 660 $RADIUS_SEQ_FILE
+    if [ ! -f $RADIUS_SEQ_FILE ]; then
+        touch $RADIUS_SEQ_FILE
     fi
+
+    chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
+    chmod 660 $RADIUS_SEQ_FILE
 }
 
 test -f $DAEMON || exit 0
@@ -106,6 +115,7 @@ OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
 case "$1" in
   start|debug)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	if [ "$1" != "debug" ]; then
@@ -125,6 +135,7 @@ case "$1" in
 	;;
   restart|force-reload)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	echo -n "Restarting $DESC: $NAME"

+ 20 - 9
pkg/kamailio/debian-lenny/kamailio.init

@@ -48,6 +48,18 @@ check_kamailio_config ()
 	fi
 }
 
+check_homedir ()
+{
+    # Create HOMEDIR directory in case it doesn't exist
+    if [ ! -d $HOMEDIR ]; then
+        mkdir $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
@@ -58,17 +70,14 @@ create_radius_seqfile ()
     # 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=/var/run/kamailio/kamailio_radius.seq
-    if [ -d /var/run/kamailio ]; then
-	chown ${USER}:${GROUP} /var/run/kamailio
-
-	if [ ! -f $RADIUS_SEQ_FILE ]; then
-	    touch $RADIUS_SEQ_FILE
-	fi
+    RADIUS_SEQ_FILE=$HOMEDIR/kamailio_radius.seq
 
-	chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
-	chmod 660 $RADIUS_SEQ_FILE
+    if [ ! -f $RADIUS_SEQ_FILE ]; then
+        touch $RADIUS_SEQ_FILE
     fi
+
+    chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
+    chmod 660 $RADIUS_SEQ_FILE
 }
 
 test -f $DAEMON || exit 0
@@ -106,6 +115,7 @@ OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
 case "$1" in
   start|debug)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	if [ "$1" != "debug" ]; then
@@ -125,6 +135,7 @@ case "$1" in
 	;;
   restart|force-reload)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	echo -n "Restarting $DESC: $NAME"

+ 20 - 9
pkg/kamailio/debian/kamailio.init

@@ -48,6 +48,18 @@ check_kamailio_config ()
 	fi
 }
 
+check_homedir ()
+{
+    # Create HOMEDIR directory in case it doesn't exist
+    if [ ! -d $HOMEDIR ]; then
+        mkdir $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
@@ -58,17 +70,14 @@ create_radius_seqfile ()
     # 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=/var/run/kamailio/kamailio_radius.seq
-    if [ -d /var/run/kamailio ]; then
-	chown ${USER}:${GROUP} /var/run/kamailio
-
-	if [ ! -f $RADIUS_SEQ_FILE ]; then
-	    touch $RADIUS_SEQ_FILE
-	fi
+    RADIUS_SEQ_FILE=$HOMEDIR/kamailio_radius.seq
 
-	chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
-	chmod 660 $RADIUS_SEQ_FILE
+    if [ ! -f $RADIUS_SEQ_FILE ]; then
+        touch $RADIUS_SEQ_FILE
     fi
+
+    chown ${USER}:${GROUP} $RADIUS_SEQ_FILE
+    chmod 660 $RADIUS_SEQ_FILE
 }
 
 test -f $DAEMON || exit 0
@@ -106,6 +115,7 @@ OPTIONS="-P $PIDFILE -m $MEMORY -u $USER -g $GROUP"
 case "$1" in
   start|debug)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	if [ "$1" != "debug" ]; then
@@ -125,6 +135,7 @@ case "$1" in
 	;;
   restart|force-reload)
 	check_kamailio_config
+	check_homedir
 	create_radius_seqfile
 
 	echo -n "Restarting $DESC: $NAME"