Browse Source

- camd.init: wait for openvpn

master
vanhofen 4 years ago
parent
commit
c717c35b26
  1. 173
      skel-root/general/scripts/camd.init

173
skel-root/general/scripts/camd.init

@ -4,43 +4,18 @@
# Camd-Fileflags # Camd-Fileflags
FLAGDIR="/var/etc" FLAGDIR="/var/etc"
F_MGCAM=".mgcamd"
F_OPENVPN=".openvpn"
F_DOSCAM=".doscam" F_DOSCAM=".doscam"
F_OSCAM=".oscam" F_OSCAM=".oscam"
F_OSMOD=".osmod" F_OSMOD=".osmod"
F_NCAM=".ncam" F_NCAM=".ncam"
F_MGCAMD=".mgcamd"
F_CCCAM=".cccam" F_CCCAM=".cccam"
F_GBOX=".gbox" F_GBOX=".gbox"
MGCAM_Action() doscam_action()
{
case $1 in
"start" )
SHOWINFO "start mgcamd"
{ /var/bin/mgcamd; pzapit -rz; } &
;;
"stop" )
SHOWINFO "stop mgcamd"
kill $( cat /tmp/mgcamd.pid )
sleep 1
rm -rf /tmp/mgstat.info
rm -rf /tmp/mgshare.info
rm -rf /tmp/ecm.info
rm -rf /tmp/pid.info
rm -rf /tmp/ca_cache.list
rm -rf /tmp/cccam.info
rm -rf /tmp/ecm.info
rm -rf /tmp/mg.info
;;
* )
MGCAM_Action "stop"
sleep 1
MGCAM_Action "start"
;;
esac
}
DOSCAM_Action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -48,7 +23,7 @@ DOSCAM_Action()
/etc/init.d/camd_datefix start doscam /etc/init.d/camd_datefix start doscam
SHOWINFO "start doscam" SHOWINFO "start doscam"
/var/bin/doscam -b -w0 /var/bin/doscam -b -w0
if [ -e $FLAGDIR/$F_MGCAM ]; then if [ -e $FLAGDIR/$F_MGCAMD ]; then
sleep 15 sleep 15
fi fi
;; ;;
@ -62,14 +37,14 @@ DOSCAM_Action()
rm -rf /tmp/ecm.info rm -rf /tmp/ecm.info
;; ;;
* ) * )
DOSCAM_Action "stop" doscam_action "stop"
sleep 1 sleep 1
DOSCAM_Action "start" doscam_action "start"
;; ;;
esac esac
} }
OSCAM_Action() oscam_action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -77,7 +52,7 @@ OSCAM_Action()
/etc/init.d/camd_datefix start oscam /etc/init.d/camd_datefix start oscam
SHOWINFO "start oscam" SHOWINFO "start oscam"
/var/bin/oscam -b /var/bin/oscam -b
if [ -e $FLAGDIR/$F_MGCAM ]; then if [ -e $FLAGDIR/$F_MGCAMD ]; then
sleep 15 sleep 15
fi fi
;; ;;
@ -91,14 +66,14 @@ OSCAM_Action()
rm -rf /tmp/ecm.info rm -rf /tmp/ecm.info
;; ;;
* ) * )
OSCAM_Action "stop" oscam_action "stop"
sleep 1 sleep 1
OSCAM_Action "start" oscam_action "start"
;; ;;
esac esac
} }
OSMOD_Action() osmod_action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -106,7 +81,7 @@ OSMOD_Action()
/etc/init.d/camd_datefix start osmod /etc/init.d/camd_datefix start osmod
SHOWINFO "start osmod" SHOWINFO "start osmod"
/var/bin/osmod -b /var/bin/osmod -b
if [ -e $FLAGDIR/$F_MGCAM ]; then if [ -e $FLAGDIR/$F_MGCAMD ]; then
sleep 15 sleep 15
fi fi
;; ;;
@ -120,14 +95,14 @@ OSMOD_Action()
rm -rf /tmp/ecm.info rm -rf /tmp/ecm.info
;; ;;
* ) * )
OSMOD_Action "stop" osmod_action "stop"
sleep 1 sleep 1
OSMOD_Action "start" osmod_action "start"
;; ;;
esac esac
} }
NCAM_Action() ncam_action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -135,7 +110,7 @@ NCAM_Action()
/etc/init.d/camd_datefix start ncam /etc/init.d/camd_datefix start ncam
SHOWINFO "start ncam" SHOWINFO "start ncam"
/var/bin/ncam -b /var/bin/ncam -b
if [ -e $FLAGDIR/$F_MGCAM ]; then if [ -e $FLAGDIR/$F_MGCAMD ]; then
sleep 15 sleep 15
fi fi
;; ;;
@ -149,14 +124,42 @@ NCAM_Action()
rm -rf /tmp/ecm.info rm -rf /tmp/ecm.info
;; ;;
* ) * )
NCAM_Action "stop" ncam_action "stop"
sleep 1 sleep 1
NCAM_Action "start" ncam_action "start"
;; ;;
esac esac
} }
CCCAM_Action() mgcamd_action()
{
case $1 in
"start" )
SHOWINFO "start mgcamd"
{ /var/bin/mgcamd; pzapit -rz; } &
;;
"stop" )
SHOWINFO "stop mgcamd"
kill $( cat /tmp/mgcamd.pid )
sleep 1
rm -rf /tmp/mgstat.info
rm -rf /tmp/mgshare.info
rm -rf /tmp/ecm.info
rm -rf /tmp/pid.info
rm -rf /tmp/ca_cache.list
rm -rf /tmp/cccam.info
rm -rf /tmp/ecm.info
rm -rf /tmp/mg.info
;;
* )
mgcamd_action "stop"
sleep 1
mgcamd_action "start"
;;
esac
}
cccam_action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -169,14 +172,14 @@ CCCAM_Action()
killall cccam killall cccam
;; ;;
* ) * )
CCCAM_Action "stop" cccam_action "stop"
sleep 1 sleep 1
CCCAM_Action "start" cccam_action "start"
;; ;;
esac esac
} }
GBOX_Action() gbox_action()
{ {
case $1 in case $1 in
"start" ) "start" )
@ -195,64 +198,85 @@ GBOX_Action()
rm -rf /tmp/gbox.kill rm -rf /tmp/gbox.kill
;; ;;
* ) * )
GBOX_Action "stop" gbox_action "stop"
sleep 1 sleep 1
GBOX_Action "start" gbox_action "start"
;; ;;
esac esac
} }
CAMD_Action() check_openvpn()
{
if [ -e $FLAGDIR/$F_OPENVPN ]; then
# wait i seconds for openvpn
i=10
while [ $i -gt 0 ]; do
if pidof openvpn > /dev/null; then
SHOWINFO "openvpn is started"
i=-1 # leave loop
else
SHOWINFO "wait for openvpn ... $i"
sleep 1
fi
i=$(($i-1))
if [ $i = 0 ]; then
SHOWINFO "continue without openvpn"
fi
done
fi
}
camd_action()
{ {
case $1 in case $1 in
"mgcamd")
MGCAM_Action $ACTION
;;
"doscam") "doscam")
DOSCAM_Action $ACTION doscam_action $ACTION
;; ;;
"oscam") "oscam")
OSCAM_Action $ACTION oscam_action $ACTION
;; ;;
"osmod") "osmod")
OSMOD_Action $ACTION osmod_action $ACTION
;; ;;
"ncam") "ncam")
NCAM_Action $ACTION ncam_action $ACTION
;;
"mgcamd")
mgcamd_action $ACTION
;; ;;
"cccam") "cccam")
CCCAM_Action $ACTION cccam_action $ACTION
;; ;;
"gbox") "gbox")
GBOX_Action $ACTION gbox_action $ACTION
;; ;;
*) *)
if [ -e $FLAGDIR/$F_MGCAM ]; then
MGCAM_Action $ACTION
fi
if [ -e $FLAGDIR/$F_DOSCAM ]; then if [ -e $FLAGDIR/$F_DOSCAM ]; then
DOSCAM_Action $ACTION doscam_action $ACTION
fi fi
if [ -e $FLAGDIR/$F_OSCAM ]; then if [ -e $FLAGDIR/$F_OSCAM ]; then
OSCAM_Action $ACTION oscam_action $ACTION
fi fi
if [ -e $FLAGDIR/$F_OSMOD ]; then if [ -e $FLAGDIR/$F_OSMOD ]; then
OSMOD_Action $ACTION osmod_action $ACTION
fi fi
if [ -e $FLAGDIR/$F_NCAM ]; then if [ -e $FLAGDIR/$F_NCAM ]; then
NCAM_Action $ACTION ncam_action $ACTION
fi
if [ -e $FLAGDIR/$F_MGCAMD ]; then
mgcamd_action $ACTION
fi fi
if [ -e $FLAGDIR/$F_CCCAM ]; then if [ -e $FLAGDIR/$F_CCCAM ]; then
CCCAM_Action $ACTION cccam_action $ACTION
fi fi
if [ -e $FLAGDIR/$F_GBOX ]; then if [ -e $FLAGDIR/$F_GBOX ]; then
GBOX_Action $ACTION gbox_action $ACTION
fi fi
;; ;;
esac esac
@ -261,14 +285,15 @@ CAMD_Action()
case $1 in case $1 in
"start") "start")
ACTION="start" ACTION="start"
CAMD_Action $2 check_openvpn
camd_action $2
;; ;;
"stop") "stop")
ACTION="stop" ACTION="stop"
CAMD_Action $2 camd_action $2
;; ;;
*) *)
ACTION="restart" ACTION="restart"
CAMD_Action $2 camd_action $2
;; ;;
esac esac

Loading…
Cancel
Save