Part two - fix session initialization leading to nil pointer error in session manager, refactored tutorial init scripts, use /tmp as run_dir

This commit is contained in:
DanB
2015-03-04 18:29:47 +01:00
parent 13de051fd1
commit db4a146924
3 changed files with 32 additions and 24 deletions

View File

@@ -21,23 +21,20 @@ DAEMON=/usr/bin/cgr-engine
USER=cgrates
GROUP=cgrates
DAEMON_OPTS=""
RUNDIR=/tmp/$NAME/run
TUTFOLDER=/usr/share/cgrates/tutorials/fs_json/cgrates
TMP_DIR=/tmp/cgr_fsjson/cgrates
SCRIPTNAME=$TUTFOLDER/etc/init.d/$NAME
RUNDIR=$TMP_DIR/run
PIDFILE=$RUNDIR/cgr-engine.pid
STACKTRACE=$RUNDIR/$NAME.strace
SCRIPTNAME=$TUTFOLDER/etc/init.d/$NAME
DEFAULTS=$TUTFOLDER/etc/default/$NAME
ENABLE=true
TUTFOLDER=/usr/share/cgrates/tutorials/fs_json/cgrates
ENGINE_OPTS="-config=$TUTFOLDER/etc/cgrates/cgrates.cfg"
HISTDIR=/tmp/$NAME/history
CDREDIR=/tmp/$NAME/cdre
DAEMON_OPTS="-config_dir=/usr/share/cgrates/tutorials/fs_json/cgrates/etc/cgrates"
HISTDIR=$TMP_DIR/history
CDREDIR=$TMP_DIR/cdre
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r $DEFAULTS ] && . $DEFAULTS
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
@@ -78,6 +75,7 @@ do_start()
# 1 if daemon was already running
# 2 if daemon could not be started
echo "\n### Started at:" `date`>>$STACKTRACE
echo $DAEMON $DAEMON_OPTS $PIDFILE
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test\
|| return 1
start-stop-daemon --start --quiet --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --background\

View File

@@ -19,22 +19,37 @@ DAEMON=/usr/bin/freeswitch
USER=freeswitch
GROUP=freeswitch
TUTDIR=/usr/share/cgrates/tutorials/fs_json/freeswitch
SCRIPTNAME=$TUTDIR/etc/init.d/$NAME
TMP_DIR=/tmp/cgr_fsjson/freeswitch
CONFDIR=$TUTDIR/etc/$NAME
DEFAULTS=$TUTDIR/etc/default/freeswitch
RUNDIR=/var/run/$NAME
LOGDIR=/var/log/freeswitch
RUNDIR=$TMP_DIR//run
LOGDIR=$TMP_DIR/log
PIDFILE=$RUNDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
WORKDIR=/var/lib/$NAME
WORKDIR=$TMP_DIR/lib
DBDIR=$WORKDIR/db/
DAEMON_ARGS="-rp -conf $CONFDIR -db $DBDIR -log $LOGDIR -u $USER -g $GROUP -nonat -nc"
[ -x $DAEMON ] || exit 0
[ -r DEFAULTS ] && . DEFAULTS
. /lib/init/vars.sh
. /lib/lsb/init-functions
if [ ! -d $RUNDIR ]; then
mkdir -p $RUNDIR
chown -R $USER:$GROUP $RUNDIR
chmod -R ug=rwX,o= $RUNDIR
fi
if [ ! -d $LOGDIR ]; then
mkdir -p $LOGDIR
chown -R $USER:$GROUP $LOGDIR
fi
if [ ! -d $DBDIR ]; then
mkdir -p $DBDIR
chown -R $USER:$GROUP $DBDIR
fi
do_start() {
if ! [ -f $CONFDIR/freeswitch.xml ]; then
echo "$NAME is not configured so not starting.">&2
@@ -42,11 +57,6 @@ do_start() {
return 3
fi
# Directory in /var/run may disappear on reboot (e.g. when tmpfs used for /var/run).
mkdir -p $RUNDIR
chown -R $USER:$GROUP $RUNDIR
chmod -R ug=rwX,o= $RUNDIR
start-stop-daemon --start --quiet \
--pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
--test > /dev/null \