Startup script for Oscam on OpenSuSE 13.2?

I can start manually by /usr/local/bin/oscam, but when I try with a startup script, I blagged doff the internet, as per below. It does not work. I no not even get anything in the log. I do not even know where to start looking…

#!/bin/sh

### BEGIN INIT INFO
# Provides:             oscam
# Required-Start:       $local_fs $remote_fs $syslog pcscd
# Required-Stop:        $local_fs $remote_fs $syslog pcscd
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    OSCam Card Server
### END INIT INFO

DAEMON=/usr/local/bin/oscam
DAEMON_OPTS="-b -u"
PIDFILE=/var/run/oscam.pid

test -x ${DAEMON} || exit 0

. /lib/lsb/init-functions

case "$1" in
    start)
        log_daemon_msg "Starting OScam"
        start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} -- ${DAEMON_OPTS}
        log_end_msg $?
    ;;
  stop)
        log_daemon_msg "Stopping OScam"
        start-stop-daemon --stop --exec ${DAEMON}
        log_end_msg $?
    ;;
  force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/oscam {start|stop|restart|force-reload}"
    exit 1
    ;;
esac

exit 0

The script you show is a sysvinit start/stop script. It should go in /etc/init.d and have appropriate links in the correct places in the /etc/rc.d tree.

Putting it in /etc/init.d you might be able to find it in YaST> ? System > Services Manager. There you could configure in what run levels it should run and then start it and see that it is started when that runlevel is reached.

BUT, openSUSE 13.2 does not use sysvinit any more, it uses systemd. Nevertheless installing it the old way might work because systemd is compatible to some degree with sysvinit.

In any case it would be better to create systemd files for this.

Hi
The init script does not conform to openSUSE requirements… :wink:

I would grab a copy of /etc/init.d/skeleton and redo or maybe try this one with mods for your binary location;
https://build.opensuse.org/package/show?project=home%3AiSipi&package=oscam-1.10

Also create a softlink;


ln -s /usr/sbin/service /usr/sbin/rcoscam

Assuming the init file is called oscam, this will help it with systemd… (man service)

Great! Thanks Malcolm! Why did I not think of that? That script will serve as a learning experience also. The trouble with oscam is the same as with tvheadend. The pre-built binaries rarely work for your config.

Anyway. Running now:
tvburk:/home/dalton/Downloads # /etc/init.d/oscam status
Checking for service OSCAM running
oscam.service - LSB: OSCAM server
Loaded: loaded (/etc/init.d/oscam)
Active: active (running) since Tue 2015-12-15 20:49:34 EET; 3s ago
Process: 30310 ExecStop=/etc/init.d/oscam stop (code=exited, status=0/SUCCESS)
Process: 30330 ExecStart=/etc/init.d/oscam start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/oscam.service
├─30337 /usr/local/bin/oscam
└─30338 /usr/local/bin/oscam

And happily decrypting content. All I had to do was to change the path to /usr/local/bin.

Guess I will do the same with tvheadend now. Grab the script from:
https://build.opensuse.org/package/view_file/home:iSipi/tvheadend/tvheadend?expand=1

And change paths if needed.

Hi Anders
Or just use the tvheadend systemd service file?


cat /usr/lib/systemd/system/tvheadend.service
[Unit]
Description=Tvheadend - a TV streaming server and DVR
After=syslog.target network.target auditd.service

[Service]
EnvironmentFile=/etc/sysconfig/tvheadend
ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid $OPTIONS
PIDFile=/var/run/tvheadend.pid
Type=forking
Restart=on-failure
RestartSec=54s

[Install]
WantedBy=multi-user.target

Is this your self build version or the one from packman?

If self build, just dump the above file in /etc/systemd/system as tvheadend.service and should be good to go?


systemctl status tvheadend
systemctl enable tvheadend
systemctl start tvheadend
systemctl status tvheadend

...

 systemctl status tvheadend
tvheadend.service - Tvheadend - a TV streaming server and DVR
   Loaded: loaded (/usr/lib/systemd/system/tvheadend.service; enabled)
   Active: active (running) since Thu 2015-12-10 18:57:01 CST; 4 days ago
  Process: 1194 ExecStart=/usr/bin/tvheadend -f -p /var/run/tvheadend.pid $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1230 (tvheadend)
   CGroup: /system.slice/tvheadend.service
           └─1230 /usr/bin/tvheadend -f -p /var/run/tvheadend.pid -c /home/tvheadend/config -u hts -g video -6 --http_port 9981 --ht...


Self-build yes. So that is what the service file is for? Will try that later.