#!/bin/sh # # run vdr-sxfe . /etc/init.d/rc.functions rm -f /tmp/vompclient_* case "$1" in -k) touch /tmp/vompclient_stop killproc "/usr/bin/runvompclient" 1 killproc "/usr/bin/vompclient" 10 rm -f /tmp/vompclient_stop exit $? ;; -r) touch /tmp/vompclient_restart killproc "/usr/bin/vompclient" 10 exit $? ;; -f) force=1 ;; -s) shift echo "$@" > /tmp/vompclient_run killproc "/usr/bin/vompclient" 10 exit $? ;; -n) norestart=1 ;; -*) echo "Usage $0 [-k | -r | -f | -n | -s PROG]" echo " -k kill vompclient" echo " -r restart vompclient" echo " -f force vompclient (re)start" echo " -s switch to PROG until PROG exited" echo " -n no restart if an error occur" exit 1 ;; esac # accept only one instance ps=$(ps); echo "$ps" | grep "{${0##*/}}" | grep -q -v $$ && { if [ -z "$force" ]; then echo "${0##*/} is already running" exit 1 else $0 -k fi } while (true) do . /etc/rc.config ip=$NETWORK_SERVER_IP if ps ww | grep -v "grep" | grep "vdr" | grep -q "vompserver"; then ip=127.0.0.1 fi if [ -n "$ip" ]; then while ! { echo quit | nc $ip 3024 2>/dev/null; } do test -e /tmp/vompclient_stop && break; usleep 100000 "#waiting for vompserver"; done fi test -e /tmp/vompclient_stop && break # schnelle wiederholte Neustarts verzögern if [ 0$starttime -gt $(( `date +%s` - 15 )) ]; then sleep 10 "#delaying vompclient restart" fi starttime=`date +%s` args="" if ps ww | grep -v "grep" | grep "vdr" | grep -q "vompserver"; then args="-s $ip" ifconfig lo mtu 1500 fi # starte vompclient { eval /usr/bin/vompclient -n $VOMPCLIENT_ARGS $args 2>&1 && touch /tmp/vompclient_shutdown; } | grep -v "Too many open files" >>/var/log/vompclient echo -n "vompclient exits at "; date if [ -e /tmp/vompclient_run ]; then run="$(cat /tmp/vompclient_run)" echo -n "switch to $run" eval $run -n rm /tmp/vompclient_run elif [ -e /tmp/vompclient_stop ]; then test "$norestart" = "1" && break elif [ -e /tmp/vompclient_shutdown -a ! -e /tmp/vompclient_restart ]; then shutdown break fi rm -f /tmp/vompclient_* done rm -f /tmp/vompclient_*