oscam: add option to restart on suspend / resume

This commit is contained in:
Stefan Saraev 2012-08-25 22:32:06 +03:00
parent 8ce340a2df
commit 88e4dbeeb4
6 changed files with 76 additions and 0 deletions

View File

@ -23,6 +23,9 @@
. config/options $1
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID
cp -PR $PKG_DIR/config/settings.xml $ADDON_BUILD/$PKG_ADDON_ID/settings-default.xml
mkdir -p $ADDON_BUILD/$PKG_ADDON_ID/bin
cp -P $PKG_BUILD/build/oscam $ADDON_BUILD/$PKG_ADDON_ID/bin
cp -PR $PKG_DIR/config/oscam.conf $ADDON_BUILD/$PKG_ADDON_ID/oscam-default.conf

View File

@ -0,0 +1,4 @@
<settings>
<setting id="RESTART_ON_RESUME" value="false" />
</settings>

View File

@ -35,6 +35,7 @@ if [ ! "$(pidof oscam)" ]; then
ADDON_HOME="$HOME/.xbmc/userdata/addon_data/service.softcam.oscam"
ADDON_LOG_DIR="$ADDON_HOME/log"
ADDON_SETTINGS="$ADDON_HOME/settings.xml"
ADDON_CONF_DIR="$ADDON_HOME/config"
ADDON_CONF="$ADDON_CONF_DIR/oscam.conf"
ADDON_CONF_AC="$ADDON_CONF_DIR/oscam.ac"
@ -71,6 +72,10 @@ if [ ! "$(pidof oscam)" ]; then
touch $ADDON_CONF_TIERS
touch $ADDON_CONF_USER
if [ ! -f "$ADDON_SETTINGS" ]; then
cp $ADDON_DIR/settings-default.xml $ADDON_SETTINGS
fi
# Restart process if it terminates.
if [ -f "$LOCKDIR/$LOCKFILE" ] ; then
rm -rf "$LOCKDIR/$LOCKFILE"

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="1000">General</string>
<string id="1011">Restart on suspend / resume</string>
</strings>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="1000">
<setting label="1010" type="lsep"/>
<setting type="sep" />
<setting id="RESTART_ON_RESUME" type="bool" label="1011" default="false" />
</category>
</settings>

View File

@ -0,0 +1,51 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
. /etc/profile
ADDON_HOME="$HOME/.xbmc/userdata/addon_data/service.softcam.oscam"
ADDON_SETTINGS="$ADDON_HOME/settings.xml"
RESTART_ON_RESUME=`grep RESTART_ON_RESUME $ADDON_SETTINGS | awk '{print $3}' | sed -e "s,value=,," -e "s,\",,g"`
LOCKFILE="/var/lock/oscam.sleep"
if [ "$RESTART_ON_RESUME" == "true" ] ; then
case "$1" in
hibernate|suspend)
if [ "$(pidof oscam)" ];then
progress "Shutting down oscam for suspending..."
oscam.stop
touch $LOCKFILE
fi
;;
thaw|resume)
progress "Restarting oscam for wakeup..."
if [ -f "$LOCKFILE" ] ; then
rm -rf "$LOCKFILE"
oscam.start
fi
;;
*) exit $NA
;;
esac
fi