mythpc:t

Jäsenten HTPC laitteistoja

mythpc:t

ViestiKirjoittaja jms-linuxtv » 17.12.2009 17:18

Sain lopulta aikaiseksi toteuttaa pitkään kyteneen htpc-projektin.

Ongelmiakin vähän oli, kortinlukija ei toiminut oikein Asuksessa, mutta Zotacin kanssa toimii hyvin - joten (palvelin)toimintoja tältä osin on siis ympätty clientille. Lisäkonffausta tästä tuli ainakin sen verran että clientin resumen yhteydessä pitää pysäyttää huolehtia palvelimen backendin ja sasc:n sekä clientin newcs:n synkronoinnista.

Kaukosäätimenä multimedianäppis ja varalla PS3 BD-ohjain. TV on Sony 52W5500.

MythTV backend server

HW
    Emolevy: Asus M3N78-VM
    CPU: AMD Phenom(tm) II X4 920
    RAM: 4GB
    Kotelo: Antec P180
    Kovalevy: 500GB systeemilevy + 1TB tallennuksille ja videoille
    dvb-c: 2 x Terratec Cinergy 1200
SW
    OS: Ubuntu 12.04
    Kernel: 3.2.0
    mythtv-backend (0.25+fixes)
    Softcam: vdr-sasc-ng (release 570)

Mythfrontend/XBMC Client

HW
    Emolevy: zotac 330 ION mini-itx
    RAM: 4GB
    Kovalevy: usb-tikku 8GB
    muuta: langaton htpc-näppis: Deltaco TB-109
    kortinlukija: phoenix/smartmouse (usb)
    Bluetooth: Targus usb bluetooth 2.0
SW
    OS: Ubuntu 12.04
    Kernel: 3.2.0
    Cardserver: OScam 1.00-unstable_svn Rev. 5623
    mythfrontend (0.25+fixes) / xbmc pre-12.0 (pvr-git)

Scriptit
MythTV Backend:
/etc/init/mythtv-backend.conf
Koodi: Valitse kaikki
# MythTV Backend service

description     "MythTV Backend"
author          "Mario Limonciello <superm1>"

start on (local-filesystems and net-device-up IFACE=lo and started udev-finish)
stop on runlevel [016]

#expect fork
respawn
respawn limit 2 3600

pre-start script
    /etc/init.d/sascd start
    [ -x /usr/sbin/mysqld ] || exit 0
    for i in `seq 1 30` ; do
       /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping && exit 0
       sleep .5
    done
end script

script
   test -f /etc/default/locale && . /etc/default/locale || true
   LANG=$LANG /usr/bin/mythbackend --logfile /var/log/mythtv/mythbackend.log --user mythtv
end script

/etc/init.d/sascd
Koodi: Valitse kaikki
#! /bin/bash
#
# sasc start-stop script
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME="runsasc"
DESC="SASC-NG"
DAEMON="sasc-ng"
TMP_FILE=/tmp/SASC_COMPLETE
MODULE=dvbloopback

ENABLED=0
test -f /etc/default/sascc && . /etc/default/sascc
test "$ENABLED" != "0" || exit 0

rm -f $TMP_FILE

LOOP=0
case "$1" in
  start)
         if ! ps -C $DAEMON > /dev/null 2>&1; then
           echo -e "Starting $DESC: $NAME. \n"
           $NAME &
           until [ -e $TMP_FILE ] || [ $LOOP -eq $TIMEOUT ] ; do
             sleep 1
             LOOP=$((LOOP+1))
           done
           if [ $LOOP -eq $TIMEOUT ]; then
             echo -e "$DESC startup sequence has timed out in $TIMEOUT seconds. $DESC will not start. \n"
             exit 1
           fi
           echo -e "$DESC startup time was $LOOP second(s). \n"
           echo -e "$DESC startup sequence completed. \n"
           initctl emit sasc-ng-started
         else
           echo -e "$DESC is already running. \n"
         fi
         ;;
  stop)
         if ps -C $DAEMON > /dev/null 2>&1; then
           echo -e "Stopping $DESC: $NAME. \n"
           #sleep 3
           killall -q -TERM $NAME
           killall -q -TERM $DAEMON
           sleep 3
           rmmod $MODULE
         else
           echo -e "$DESC is not running. \n"
         fi
         ;;
  restart|force-reload)
         if ps -C $DAEMON > /dev/null 2>&1; then
           echo -e "Restarting $DESC: $NAME. \n"
           #sleep 3
           killall -q -TERM $NAME
           killall -q -TERM $DAEMON
           sleep 3
           rmmod $MODULE
           sleep 1
           $NAME &
           until [ -e $TMP_FILE ] || [ $LOOP -eq $TIMEOUT ] ; do
             sleep 1
             LOOP=$((LOOP+1))
           done
           if [ $LOOP -eq $TIMEOUT ]; then
             echo -e "$DESC startup sequence has timed out in $TIMEOUT seconds. $DESC will not start. \n"
             exit 1
           fi
         echo -e "$DESC startup time was $LOOP second(s). \n"
         echo -e "$DESC startup sequence completed. \n"
         else
           echo -e "$DESC is not running. \n"
         fi
         ;;
  *)
         N=/etc/init.d/$NAME
         echo "Use: $N {start|stop|restart|force-reload}" >&2
         exit 1
        ;;
esac

rm -f $TMP_FILE

exit 0

/etc/default/sascc
Koodi: Valitse kaikki
# /etc/default/sascc
# Default SASC-NG startup config

# Change to 1 to enable sasc-ng's init-script
ENABLED=1

# DVBLoopback Device creation timeout (in seconds)
TIMEOUT=60

/etc/camfiles/cardclient.conf
Koodi: Valitse kaikki
newcamd:192.168.1.98:15050:1/0b00/ffff:newcamd:newcamd:0102030405060708091011121314



XBMC/Mythfrontend Client
/etc/init.d/oscam (muokattu newcs:n vastaavasta)
Koodi: Valitse kaikki
#! /bin/bash
# Author: eldon <eldon>
# based on a basic debian skeleton startup script

# START EDIT HERE #
NCSNAME=oscam      # your newcs bin version
NCSDIR="/usr/local/bin"   # your newcs binary directory full path (without trailing /).
NCSUSER=root         # existing user that will run newcs daemon (you should NOT use root !).
NCSNICE=10         # set the newcs daemon priority -20 (most favorable scheduling) to 19 (least favorable).
# END EDIT HERE #

PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin   # some unecessary default paths
DESC="OScam daemon"      # dummy description
NAME=oscam         # dummy name
DAEMON="$NCSDIR/$NCSNAME"   # Daemon bin location
DAEMON_ARGS=""   # Keep -nd in place, ssd will fork to background itself (required to get a proper pid file)
PIDFILE=/var/run/$NAME-init.pid   # pid path
LOG=/var/log/$NAME.log      # log path
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
if [ ! -x "$DAEMON" ]
then
   echo "$DAEMON does not exist"
   exit 0
fi   

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started
   start-stop-daemon --start --quiet --chuid $NCSUSER --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
      || return 1
   
   start-stop-daemon --start --verbose --nicelevel $NCSNICE --make-pidfile --background --chuid $NCSUSER --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS 2>&1 >> $LOG \
      || return 2

   # Add code here, if necessary, that waits for the process to be ready
   # to handle requests from services started subsequently which depend
   # on this one.  As a last resort, sleep for some time.

   return $?
}

#
# Function that stops the daemon/service
#
do_stop()
{
   # Return
   #   0 if daemon has been stopped
   #   1 if daemon was already stopped
   #   2 if daemon could not be stopped
   #   other if a failure occurred
   start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NCSNAME
   RETVAL="$?"
   [ "$RETVAL" = 2 ] && return 2
   # Wait for children to finish too if this is a daemon that forks
   # and if the daemon is only ever run from this initscript.
   # If the above conditions are not satisfied then add some other code
   # that waits for the process to drop all resources that could be
   # needed by services started subsequently.  A last resort is to
   # sleep for some time.
   start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
   [ "$?" = 2 ] && return 2
   # Many daemons don't delete their pidfiles when they exit.
   rm -f $PIDFILE
   # oma
   rmmod ftdi_sio
   rmmod usbserial
   sleep 2
   modprobe ftdi_sio
   #
   return "$RETVAL"
}


case "$1" in
  start)
   echo "Starting $DESC"
   do_start
   case "$?" in
      0)   log_daemon_msg "Success"
         log_end_msg 0;;
      1)   log_daemon_msg "Already running"
         log_end_msg 1;;
      2)    log_daemon_msg "Failed"
         log_end_msg 2;;
   esac
   ;;
  stop)
   echo "Stopping $DESC"
   do_stop
   case "$?" in
      0|1) echo "Success" ;;
      2) echo "Failed !" ;;
   esac
   ;;
  restart)
   log_daemon_msg "Restarting $DESC"
   do_stop
   case "$?" in
     0|1)
      do_start
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
      esac
      ;;
     *)
        # Failed to stop
      log_end_msg 1
      ;;
   esac
   ;;
  *)
   echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
   exit 3
   ;;
esac

exit 0


/etc/pm/sleep.d/15_cardserver_restart
Koodi: Valitse kaikki
#!/bin/bash

# Action script to restart cardserver
#
# Copyright: Copyright (c) 2009 Michael Vogt
# License:   GPL-2
#

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
LOG=/home/mythtv/tmp/sleep.log

# pm-action(8) - <action> <suspend>
#
# On suspend|hibernate, disconnect any wpa-roam managed interfaces,
# reconnect it on resume.

case "${1}" in
        resume|thaw)
      /usr/local/bin/softcam-refresh.sh &
      rfkill unblock bluetooth
                ;;
        suspend|hibernate)
      /etc/init.d/oscam stop
      rfkill block bluetooth
                ;;
esac


/usr/local/bin/softcam-refresh.sh
Koodi: Valitse kaikki
#!/bin/bash

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
LOG=/var/log/softcam/suspend.log
SASC_SERVER=192.168.1.10
PING=fping

echo "##############################" >>$LOG
date >> $LOG

function waitForHost
{
    reachable=0;
    while [ $reachable -eq 0 ];
    do
    echo "Pinging backend at `date`..." >>$LOG
    $PING $SASC_SERVER >>$LOG
    if [ "$?" -eq 0 ];
    then
        reachable=1
    fi
    done
}
waitForHost

#stop sasc & mythbackend @ server
echo "stopping mythtv backend & sasc..." >>$LOG
killall -q mythfrontend
killall -q mythfrontend.real
sudo -H -u mythtv ssh mythtv@$SASC_SERVER "sudo service mythtv-backend stop" 2>&1 >>$LOG
sudo -H -u mythtv ssh mythtv@$SASC_SERVER "sudo /etc/init.d/sascd stop" 2>&1 >>$LOG

# restart oscam at localhost
echo "reloading oscam & modules..." >>$LOG
sudo /etc/init.d/oscam stop >>$LOG
sleep 2
sudo /etc/init.d/oscam start >>$LOG

#start sasc & mythbackend @ server
echo "loki starting mythtv backend & sasc..." >>$LOG
sudo -H -u mythtv ssh mythtv@$SASC_SERVER "sudo service mythtv-backend start" >>$LOG


Edit: 22.12.09 lisätty toinen dvb-c kortti
Edit: 09.01.10 lisätty PS3:n BD-kaukosäädin ja bluetooth adapteri frontendiin
Edit: 23.01.10 päivitetty versiot & muokattu kokoonpanoa
Edit: 05.03.10 päivitetty versiot
Edit: 23.03.10 päivitetty versiot & lisätty scriptejä
Edit: 03.06.10 päivitetty versiot
Edit: 25.06.10 päivitetty versiot, vaihdettu newcs->oscam
Edit: 06.08.10 päivitetty versiot
Edit: 17.09.10 päivitetty versiot
Edit: 16.10.10 päivitetty versiot, frontend muisti 2->4GB, näppis
Edit: 21.11.10 päivitetty versiot
Edit: 31.01.11 päivitetty scriptit ja versiot
Edit: 30.12.11 päivitetty scriptit ja versiot
Edit: 29.04.12 päivitetty versiot (oneiric -> precision)
jms-linuxtv
Harrastaja
 
Viestit: 43
Liittynyt: 15.12.2009 14:52
Paikkakunta: Tampere

Paluu HTPC kokoonpanot

Paikallaolijat

Käyttäjiä lukemassa tätä aluetta: Ei rekisteröityneitä käyttäjiä ja 3 vierailijaa

cron