1#!/bin/sh 2 3. ${STREAMBOOST_CFGDIR:-/etc/appflow}/rc.appflow 4 5# standard settings - accept overrides from the calling environment 6[ -z "$KROUTER_DEBUG_FILE" ] && KROUTER_DEBUG_FILE="/etc/krouter_debug" 7BINARY="ozker" 8export RUNDIR BINDIR BINARY 9 10# OzKer configuration items 11DAEMON_BIN="${BINDIR}/${BINARY}" 12DISPLAY_NAME="ozKer" 13PIDFILE="${RUNDIR}/${BINARY}.pid" 14DAEMON_PORT=9000 15DAEMON_HOST=127.0.0.1 16REDIS_PORT=6379 17REDIS_HOST=127.0.0.1 18REDIS_UNIXSOCK=/var/run/appflow/redis.sock 19REDIS_TIMEOUT=3000 20EXTRA_COMMANDS=status 21OZKER_LOG_LEVEL=6 22 23# Format the command line parameters 24OPTIONS_RUN="--daemon --port=$DAEMON_PORT --host=$DAEMON_HOST --run-dir=$RUNDIR --pid-file=$PIDFILE --log-level=$OZKER_LOG_LEVEL" 25OPTIONS_REDIS="--redis-unixsocket=$REDIS_UNIXSOCK --redis-timeout=$REDIS_TIMEOUT" 26OPTIONS_CGI="--uri-prefix=$URL_PREFIX" 27OPTIONS_ALL="$OPTIONS_RUN $OPTIONS_REDIS $OPTIONS_CGI" 28OPTIONS_DEBUG="--no-daemon --log-level=7" 29OPTIONS_DEBUG_INTERACTIVE="--debug-fastcgi" 30 31start() { 32 echo -n "Starting ${DISPLAY_NAME}: " 33 34 [ "$OZKER_BASIC_AUTH" = "yes" ] && { 35 if [ ! -e '/etc/httpd.conf' ] || [ $(grep -c ozker /etc/httpd.conf &>/dev/null) -eq 0 ]; then 36 echo '/cgi-bin/ozker:root:$p$root' >>/etc/httpd.conf 37 fi 38 39 40 if [ ! -e 'httpd.conf' ] || [ $(grep -c ozker httpd.conf &>/dev/null) -eq 0 ]; then 41 echo '/cgi-bin/ozker:root:$p$root' >>httpd.conf 42 fi 43 44 45 sed -i -e 's/^[ \t]*#[ \t]\+option[ \t]\+realm[ \t]\+/\toption realm /;s/^[ \t]*#[ \t]\+option[ \t]\+config[ \t]\+/\toption config /' /etc/config/uhttpd 46 /etc/init.d/uhttpd restart 47 } 48 start-stop-daemon -S -q -p $PIDFILE -x $DAEMON_BIN -- \ 49 $OPTIONS_ALL "$@" 50 51 retval=$? 52 echo 53 return ${retval} 54} 55 56start_devel() { 57 [ ! -d "$RUNDIR" ] && { 58 mkdir -p $RUNDIR 59 } 60 61 DAEMON_BIN="$1" 62 shift 63 64 start-stop-daemon -S -q -p $PIDFILE -x $DAEMON_BIN -- \ 65 $OPTIONS_ALL "$@" 66} 67 68boot() { 69 [ ! -d "$RUNDIR" ] && { 70 mkdir -p $RUNDIR 71 } 72 73 if [ -n "$KROUTER_DEBUG_FILE" ] && [ -e "$KROUTER_DEBUG_FILE" ]; then 74 # debug file is present 75 echo "$DISPLAY_NAME: booting in debug mode" 76 start $OPTIONS_DEBUG "$@" 77 else 78 start "$@" 79 fi 80} 81 82stop() { 83 default_stop && { 84 sed -i -e '/^\/cgi-bin\/ozker:root:.*/d' /etc/httpd.conf 85 sed -i -e 's/^[ \t]\+option[ \t]\+realm[ \t]\+/#\toption realm /;s/^[ \t]\+option[ \t]\+config[ \t]\+/#\toption config /' /etc/config/uhttpd 86 /etc/init.d/uhttpd restart 87 true 88 } 89} 90 91restart() { 92 stop 93 start 94} 95 96action() { 97 action=${1:-boot} 98 shift 99 100 case "${action}" in 101 boot|init) 102 boot "$@" 103 ;; 104 start|stop|restart|status|start_devel) 105 ${action} "$@" 106 ;; 107 *) 108 echo "Usage: $0 start|boot|stop|restart|status|start_devel" 109 exit 1 110 esac 111} 112 113action "$@" 114exit $? 115