Am modificat un script gasit aici (postat de miloo) cu intentia de a-l face sa verifice conexiunea wireless si sa fie usor de adaptat pentru alt emu sau combinatie de emu. Practic, e suficienta editarea primei parti a scriptului pentru a-l adapta la conditiile particulare ale fiecaruia. Nu ma pricep la script-uri si probabil va provoca zambete celor care sunt familiarizati cu limbajele de programare. Doar am modifiat scriptul mentionat mai sus folosind logica (habar n-am sa scriu o sentinta if else). Scriptul merge si doar asta conteaza (pentru mine).
Ideea scriptului e cea de a interoga router-ul/emu si daca primeste un raspuns e ok. Daca nu, ia masuri.
Cateva explicatii legate de editarea lui:
1.CHECK_NET puneti-l pe 1 daca folositi un adaptor wireless si daca aveti un router cu care se poate comunica prin telnet sau ssh. Daca router-ul nu raspunde se reporneste dreambox-ul. Repornirea adaptorului nu merge mereu si nici nu stiu cum sa pun sa se faca asta prin script. Pentru celelalte rotere, nu stiu cum se pot interoga prin script. Cine stie si vrea, sa modifice scriptul.
2. daca ENIGMA e setat pe enigma1, ar trebui sa mearga si pe enigma 2 (invers nu e valabil). am pus, totusi, aceasta optiune pentru ca nu -mi place sa vad in telnet o emu cu path in /var/bin in enigma2 (un pitic pe creier de-al meu).
3. TWO_CAM pe zero daca folositi o singura emu si pe 1 daca folositi o combinatie de 2 emu (de ex. newcs + cccam).
4. La port-uri, puneti un port valid de server pe care-l foloseste emuatorul (de ex. portul pe care-l dati cu linia F la CCcam, D la gbox...)
Bineinteles, acest script trebui pus in var/script (e1) sau /usr/script (e2), chmod 755 si adaugata executia lui in crond la intervalul dorit.
Bafta!
Code:
#!/bin/sh
#########################################################################################
#       Here you can change values according to your box
CHECK_NET="1"         # 0 to desable router connection check and 1 to enable
ENIGMA="enigma2"      # set it to "enigma1" or "enigma2"
TWO_CAM="1"           # 0 for one emu and 1 for two emu (card reader and emu) 
CAM="sbox"            # card reader
CAM2="CCcam_2.1.3"    # card server
IPLAN="192.168.1.1"   # router's ip
PORT="34000"          # port used by card reader's name
PORT2="12000"         # port used by card server's name
PORT3="22"            # ssh or telnet port used by router
##########################################################################################
#                    There's nothing to change here
CHECKNAME="test.txt"
CHECKNAME2="test2.txt"
CHECKNAME3="test3.txt"
IP="127.0.0.1"
  if [ $CHECK_NET = "1" ]
  then
echo info|nc $IPLAN $PORT3 >>/tmp/$CHECKNAME3
set $(ls -s /tmp/$CHECKNAME3)
    if [ "$1" = "0" ];
    then
echo "Connection to router NOT working. Restarting..."
sleep 5
reboot
    else
echo "Connection to router OK"
    fi
  else
  echo "No net check"
     fi
     if [ $TWO_CAM = "1" ]
     then
      if [ $ENIGMA = "enigma1" ]
      then
echo info|nc $IP $PORT2 >>/tmp/$CHECKNAME2
set $(ls -s /tmp/$CHECKNAME2)
          if [ "$1" = "0" ];
          then
echo "$CAM is not running, Restarting..."
killall $CAM &CAM2
sleep 5
/var/bin/$CAM &
sleep 10
/var/bin/CAM2 &
sleep 15
          else
echo "$CAM is running"
          fi
echo info|nc $IP $PORT >>/tmp/$CHECKNAME
set $(ls -s /tmp/$CHECKNAME)
          if [ "$1" = "0" ];
          then
echo "&CAM2 is not running, Restarting..."
killall $CAM2
sleep 5
/var/bin/$CAM2 &
          else
echo "$CAM2 is running"
          fi
      else
echo info|nc $IP $PORT2 >>/tmp/$CHECKNAME2
set $(ls -s /tmp/$CHECKNAME2)
                 if [ "$1" = "0" ];
                 then
echo "&CAM is not running, Restarting..."
killall $CAM &CAM2
sleep 5
/usr/bin/$CAM &
sleep 10
/usr/bin/CAM2 &
sleep 15
                else
echo "$CAM is running"
                fi
echo info|nc $IP $PORT >>/tmp/$CHECKNAME
set $(ls -s /tmp/$CHECKNAME)
           if [ "$1" = "0" ];
           then
echo "$CAM2 is not running, Restarting..."
killall $CAM2
sleep 5
/usr/bin/$CAM2 &
           else
echo "$CAM2 is running"
           fi
  fi
  else
  if [ $ENIGMA = "enigma1" ]
  then
  echo info|nc $IP $PORT >>/tmp/$CHECKNAME
set $(ls -s /tmp/$CHECKNAME)
          if [ "$1" = "0" ];
          then
echo "&CAM2 is not running, Restarting..."
killall $CAM2
sleep 5
/var/bin/$CAM2 &
          else
echo "$CAM2 is running"
          fi
          else
          echo info|nc $IP $PORT >>/tmp/$CHECKNAME
set $(ls -s /tmp/$CHECKNAME)
          if [ "$1" = "0" ];
          then
echo "&CAM2 is not running, Restarting..."
killall $CAM2
sleep 5
/usr/bin/$CAM2 &
          else
echo "$CAM2 is running"
          fi
          fi
         fi
rm /tmp/$CHECKNAME /tmp/$CHECKNAME2 /tmp/$CHECKNAME3
exit