#!/bin/sh
CS="oscam"
CAM="camd3"
OSD="OScam + Camd3"
PID=`pidof $CAM`
CSPID=`pidof $CS`
Action=$1
cam_clean () {
rm -rf /tmp/*.info* /tmp/.oscam /tmp/*.pid
}
cam_handle () {
if test -z "${PID}" || test -z "${CSPID}" ; then
cam_up;
else
cam_down;
fi;
}
cam_down () {
killall -9 $CS
sleep 3
killall $CAM
cam_clean
}
cam_up () {
/usr/bin/cam/$CS -c /etc
sleep 4
/usr/bin/cam/$CAM &
}
if test "$Action" = "cam_startup" ; then
if test -z "${PID}" || test -z "${CSPID}" ; then
cam_down
cam_up
else
echo "$CS + $CAM already running, exiting..."
fi
elif test "$Action" = "cam_res" ; then
cam_down
cam_up
elif test "$Action" = "cam_down" ; then
cam_down
elif test "$Action" = "cam_up" ; then
cam_up
else
cam_handle
fi
exit 0