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


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

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


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

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


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

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
if [ -f /etc/default/kamailio ]; then if [ -f /etc/default/kamailio ]; then
. /etc/default/kamailio
. /etc/default/kamailio
fi fi
if [ -f /etc/sysconfig/kamailio ]; then if [ -f /etc/sysconfig/kamailio ]; then
. /etc/sysconfig/kamailio
. /etc/sysconfig/kamailio
fi fi
RETVAL=0 RETVAL=0
@ -23,80 +23,83 @@ PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=8 [ $PKG_MEMORY -le 0 ] && PKG_MEMORY=8
if test "$DUMP_CORE" = "yes" ; then if test "$DUMP_CORE" = "yes" ; then
ulimit -c unlimited
ulimit -c unlimited
fi fi
# Do not start kamailio if fork=no is set in the config file # Do not start kamailio if fork=no is set in the config file
# otherwise the boot process will just stop # otherwise the boot process will just stop
check_fork () 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 () 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() { 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() { stop() {
killproc ${BIN_FILE}
RETVAL=$?
killproc ${BIN_FILE}
RETVAL=$?
} }
status() { status() {
kamctl fifo ds_list
RETVAL=$?
kamctl fifo ds_list
RETVAL=$?
} }
case "$1" in 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 esac
exit ${RETVAL} exit ${RETVAL}

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

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


Loading…
Cancel
Save