Script Pornire OSCam pentru Ubuntu si alte versiuni de linux

Creeaza un fisier pe care sa il numesti oscam respectand calea aceasta: /etc/init.d/oscam . Dupa ce l-ai creat introdu urmatorul script in el:

#!/bin/sh
DAEMON=/usr/local/bin/oscam
PIDFILE=/var/run/oscam.pid
DAEMON_OPTS=„-p 1024 -w 5 -r 2 -B ${PIDFILE}”
test x ${DAEMON} || exit 0
. /lib/lsb/initfunctions
case „$1” in
    start)
   log_daemon_msg „Starting OScam…”
   /sbin/startstopdaemon start quiet background  exec ${DAEMON} ${DAEMON_OPTS}
   log_end_msg $?
    ;;
  stop)
   log_daemon_msg „Stopping OScam…”
   /sbin/startstopdaemon stop exec ${DAEMON}
   log_end_msg $?
    ;;
  restart)
   $0 stop
   $0 start
    ;;
  forcereload)
   $0 stop
   /bin/kill 9 `pidof oscam`
   /usr/bin/killall 9 oscam
   $0 start
    ;;
  *)
    echo „Usage: /etc/init.d/oscam {start|stop|restart|force-reload}”
    exit 1
    ;;
esac

This assumes that you have the oscam binary located in /usr/local/bin/oscam. Remember you have to create this file as the root user.oscam logo

To “enable” the script and the starting up of oscam on reboot, use the following commands on Ubuntu/Debian:

sudo chmod +x /etc/init.d/oscam
sudo updaterc.d oscam defaults
Furthermore, for a simple crontab script to check if oscam has crashed and didn’t restart by itself, let’s create a file and call it /usr/local/bin/oscamchk:
#!/bin/bash
PIDFILE=/var/run/oscam.pid
if (kill 0 `cat $PIDFILE`)
   then
      echo „it’s alive!” > /dev/null
   else
      rm $PIDFILE
      /etc/init.d/oscam start > /dev/null
      echo „OSCAM restarted at `date`” >> /var/log/oscamcrash.log
fi
And let’s make this run every minute:
sudo chmod +x /usr/local/bin/oscamchk
sudo crontab e
Once the crontab editor has started, add the following line:
* * * * * /usr/local/bin/oscamchk >/dev/null 2>&1

Lasă un răspuns

Acest site folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.