Browse Source

tweaking sbin scripts

4.0
k anderson 10 years ago
parent
commit
895d3fa897
5 changed files with 81 additions and 62 deletions
  1. +5
    -1
      system/sbin/kazoo-bigcouch
  2. +7
    -3
      system/sbin/kazoo-freeswitch
  3. +7
    -3
      system/sbin/kazoo-haproxy
  4. +55
    -52
      system/sbin/kazoo-kamailio
  5. +7
    -3
      system/sbin/kazoo-rabbitmq

+ 5
- 1
system/sbin/kazoo-bigcouch View File

@ -1,5 +1,9 @@
#!/bin/bash
if [ -f /etc/default/bigcouch ]; then
. /etc/default/bigcouch
fi
if [ -f /etc/sysconfig/bigcouch ]; then
. /etc/sysconfig/bigcouch
fi
@ -29,7 +33,7 @@ start() {
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE}
else
exec su ${USER} -s /bin/bash -c "${BIN_FILE}"
exec su -s /bin/bash -c "${BIN_FILE}" ${USER}
fi
RETVAL=$?
}


+ 7
- 3
system/sbin/kazoo-freeswitch View File

@ -1,5 +1,9 @@
#!/bin/bash
if [ -f /etc/default/freeswitch ]; then
. /etc/default/freeswitch
fi
if [ -f /etc/sysconfig/freeswitch ]; then
. /etc/sysconfig/freeswitch
fi
@ -26,7 +30,7 @@ start() {
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE} ${FREESWITCH_ARGS} ${FREESWITCH_PARAMS} $@
else
su ${USER} -s /bin/bash -c "exec ${BIN_FILE} ${FREESWITCH_ARGS} ${FREESWITCH_PARAMS} $@"
exec su -s /bin/bash -c "exec ${BIN_FILE} ${FREESWITCH_ARGS} ${FREESWITCH_PARAMS} $@" ${USER}
fi
RETVAL=$?
}
@ -47,11 +51,11 @@ status() {
case "$1" in
start)
shift
start -ncwait $@
start "-ncwait $@"
;;
foreground)
shift
start $@
start "$@"
;;
stop)
stop


+ 7
- 3
system/sbin/kazoo-haproxy View File

@ -1,5 +1,9 @@
#!/bin/sh
if [ -f /etc/default/haproxy ]; then
. /etc/default/haproxy
fi
if [ -f /etc/sysconfig/haproxy ]; then
. /etc/sysconfig/haproxy
fi
@ -32,7 +36,7 @@ start() {
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE} -f ${CFG_FILE} -p ${PID_FILE} ${OPTIONS} $@
else
exec su ${USER} -s /bin/bash -c "${BIN_FILE} -f ${CFG_FILE} -p ${PID_FILE} ${OPTIONS} $@"
exec su -s /bin/bash -c "${BIN_FILE} -f ${CFG_FILE} -p ${PID_FILE} ${OPTIONS} $@" ${USER}
fi
RETVAL=$?
}
@ -123,11 +127,11 @@ status() {
case "$1" in
start|stop|restart|reload)
shift
$1 -D $@
$1 "-D $@"
;;
foreground)
shift
start $@
start "$@"
;;
check)
check


+ 55
- 52
system/sbin/kazoo-kamailio View File

@ -1,11 +1,11 @@
#!/bin/bash
if [ -f /etc/default/kamailio ]; then
. /etc/default/kamailio
. /etc/default/kamailio
fi
if [ -f /etc/sysconfig/kamailio ]; then
. /etc/sysconfig/kamailio
. /etc/sysconfig/kamailio
fi
RETVAL=0
@ -23,80 +23,83 @@ PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=8
if test "$DUMP_CORE" = "yes" ; then
ulimit -c unlimited
ulimit -c unlimited
fi
# Do not start kamailio if fork=no is set in the config file
# otherwise the boot process will just stop
check_fork ()
{
if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFG_FILE; then
echo "Not starting Kamailio: fork=no specified in config file"
exit 1
fi
if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFG_FILE; then
echo "Not starting Kamailio: fork=no specified in config file"
exit 1
fi
}
check_kamailio_config ()
{
local ERRORS=$($BIN_FILE -c 2>&1 > /dev/null)
RETVAL=$?
if [ "${RETVAL}" != '0' ]; then
echo "Not starting Kamailio: invalid configuration file!"
echo -e "\n${ERRORS}\n"
RETVAL=1
fi
local ERRORS=$($BIN_FILE -c 2>&1 > /dev/null)
RETVAL=$?
if [ "${RETVAL}" != '0' ]; then
echo "Not starting Kamailio: invalid configuration file!"
echo -e "\n${ERRORS}\n"
RETVAL=1
fi
}
start() {
check_kamailio_config
check_fork
check_kamailio_config
check_fork
mkdir -p /var/run/kazoo-kamailio
chown -R ${USER} /var/run/kazoo-kamailio
mkdir -p /var/run/kamailio
chown -R ${USER} /var/run/kamailio
mkdir -p /var/run/kazoo-kamailio
chown -R ${USER} /var/run/kazoo-kamailio
mkdir -p /var/run/kamailio
chown -R ${USER} /var/run/kamailio
cd ${HOME}
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE} -f ${CFG_FILE} -P ${PID_FILE} -m ${SHM_MEMORY} -M ${PKG_MEMORY} -u ${USER} -g ${GROUP} ${EXTRA_OPTIONS} $@
else
exec su -s /bin/bash -c "${BIN_FILE} -f ${CFG_FILE} -P ${PID_FILE} -m ${SHM_MEMORY} -M ${PKG_MEMORY} -u ${USER} -g ${GROUP} ${EXTRA_OPTIONS} $@" ${USER}
fi
RETVAL=$?
cd ${HOME}
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE} -f ${CFG_FILE} -P ${PID_FILE} -m ${SHM_MEMORY} -M ${PKG_MEMORY} -u ${USER} -g ${GROUP} ${EXTRA_OPTIONS} $@
else
exec su -s /bin/bash -c "${BIN_FILE} -f ${CFG_FILE} -P ${PID_FILE} -m ${SHM_MEMORY} -M ${PKG_MEMORY} -u ${USER} -g ${GROUP} ${EXTRA_OPTIONS} $@" ${USER}
fi
RETVAL=$?
}
stop() {
killproc ${BIN_FILE}
RETVAL=$?
killproc ${BIN_FILE}
RETVAL=$?
}
status() {
kamctl fifo ds_list
RETVAL=$?
kamctl fifo ds_list
RETVAL=$?
}
case "$1" in
start)
shift
start $@
;;
foreground)
shift
start "-DD -E"
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
start)
shift
start $@
;;
foreground)
shift
start "-DD -E"
;;
stop)
stop
;;
check)
check_kamailio_config
;;
status)
status
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit ${RETVAL}

+ 7
- 3
system/sbin/kazoo-rabbitmq View File

@ -1,5 +1,9 @@
#!/bin/bash -e
if [ -f /etc/default/rabbitmq ]; then
. /etc/default/rabbitmq
fi
RETVAL=0
USER=${RABBITMQ_USER-rabbitmq}
CFG_FILE=${RABBITMQ_ENV:-/etc/kazoo/rabbitmq/rabbitmq-env.conf}
@ -28,7 +32,7 @@ start() {
if [ "$(whoami)" == "${USER}" ]; then
exec ${BIN_FILE} $@
else
exec su ${USER} -s /bin/bash -c "${BIN_FILE} $@"
exec su -s /bin/bash -c "${BIN_FILE} $@" ${USER}
fi
RETVAL=$?
}
@ -36,11 +40,11 @@ start() {
case "$1" in
start)
shift
start -detached $@
start "-detached $@"
;;
foreground)
shift
start $@
start "$@"
;;
*)
exec /usr/lib/rabbitmq/bin/rabbitmqctl $@


Loading…
Cancel
Save