Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # freeswitch
- description "freeswitch sip daemon"
- # runlevel / dependencies
- start on (filesystem and net-device-up IFACE=lo)
- stop on runlevel [!2345]
- # set daemon path
- env DAEMON="/usr/local/freeswitch-1.4/bin/freeswitch"
- # set run flags
- env FLAGS="-nc -nonatmap"
- # set pid path
- env PID="/var/run/freeswitch.pid"
- # run as user
- env USER=root
- # run as group
- env GROUP=root
- # set configuration directory
- env CONFIG_DIR="/home/user/resources/freeswitch/conf"
- # set log directory
- env LOG_DIR="/home/user/resources/freeswitch/logs"
- # set temporary filedirectory
- env TEMP_DIR="/home/user/resources/freeswitch/tmp"
- # set cache directory
- env CACHE_DIR="/home/user/ramdisk"
- # set cache directory size
- env CACHE_DIR_SIZE="1024m"
- # set sqlite database directory
- env DB_DIR="/home/user/resources/freeswitch/db"
- # set run directory
- env RUN_DIR="/home/user/resources/freeswitch/run"
- # expect daemon
- expect daemon
- # automatically respond on crash / core dump
- respawn
- # limit respawn threshold
- respawn limit 10 5
- # set stack size - do not uncomment below line as it causes some weird "argument list too long" error, no idea why atm...
- #limit stack 240 240
- # set open file limit
- limit nofile 250000 250000
- # set umask
- umask 022
- pre-start script
- # create configuration directory
- [ -d $CONFIG_DIR ] || mkdir $CONFIG_DIR
- # create log directory
- [ -d $LOG_DIR ] || mkdir $LOG_DIR
- # create temp file directory
- [ -d $TEMP_DIR ] || mkdir $TEMP_DIR
- # create cache file directory
- [ -d $CACHE_DIR ] || mkdir $CACHE_DIR
- # check for mountpoint / mounted ramdisk on $CACHE_DIR, otherwise create one
- mountpoint -q $CACHE_DIR || mount -t tmpfs -o size=$CACHE_DIR_SIZE tmpfs $CACHE_DIR
- # create flatfile / SQLite database directory
- [ -d $DB_DIR ] || mkdir $DB_DIR
- # create freeswitch run directory
- [ -d $RUN_DIR ] || mkdir $RUN_DIR
- # chown and reset directory permissions
- # i've tried a million different combo's of things here.... to try and get it working but these lines below cause it to fail.
- #for FSDIR in "$CONFIG_DIR" "$LOG_DIR" "$TEMP_DIR" "$CACHE_DIR" "$CACHE_DIR_SIZE" "$DB_DIR" "$RUN_DIR"
- #for FSDIR in "$CONFIG_DIR" "$LOG_DIR" "$TEMP_DIR" "$CACHE_DIR" "$CACHE_DIR_SIZE" "$DB_DIR" "$RUN_DIR"
- # chown -R ${USER}:${GROUP} $FSDIR
- #done
- end script
- script
- exec $DAEMON -u $USER -g $GROUP -conf $CONFIG_DIR -log $LOG_DIR -temp $TEMP_DIR -cache $CACHE_DIR -db $DB_DIR -run $RUN_DIR $FLAGS
- end script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement