diff --git a/packages/addons/driver/hdhomerun/changelog.txt b/packages/addons/driver/hdhomerun/changelog.txt index 84281cae66..fb1539bfea 100644 --- a/packages/addons/driver/hdhomerun/changelog.txt +++ b/packages/addons/driver/hdhomerun/changelog.txt @@ -1,3 +1,7 @@ +3.0.2 +- added addon settings for + modifying tuner type (DVB-C, DVB-T, ATSC) + setting delays 3.0.1 - bump addon version - binary files are stored with OpenELEC image diff --git a/packages/addons/driver/hdhomerun/icon/icon.png b/packages/addons/driver/hdhomerun/icon/icon.png index 3e86018bdd..af1fddcd3e 100644 Binary files a/packages/addons/driver/hdhomerun/icon/icon.png and b/packages/addons/driver/hdhomerun/icon/icon.png differ diff --git a/packages/addons/driver/hdhomerun/meta b/packages/addons/driver/hdhomerun/meta index 5c5b7f5f8b..34b6e460a4 100644 --- a/packages/addons/driver/hdhomerun/meta +++ b/packages/addons/driver/hdhomerun/meta @@ -20,7 +20,7 @@ PKG_NAME="hdhomerun" PKG_VERSION="3.0" -PKG_REV="1" +PKG_REV="2" PKG_ARCH="any" PKG_LICENSE="GPL" PKG_SITE="http://www.silicondust.com/products/hdhomerun/dvbt/" @@ -31,8 +31,6 @@ PKG_PRIORITY="optional" PKG_SECTION="driver/dvb" PKG_SHORTDESC="A linux DVB driver for the HDHomeRun (http://www.silicondust.com)." PKG_LONGDESC="A linux DVB driver for the HDHomeRun (http://www.silicondust.com)." - PKG_AUTORECONF="no" - PKG_IS_ADDON="yes" PKG_ADDON_TYPE="xbmc.python.script" diff --git a/packages/addons/driver/hdhomerun/settings-default.xml b/packages/addons/driver/hdhomerun/settings-default.xml new file mode 100644 index 0000000000..240d6ac22e --- /dev/null +++ b/packages/addons/driver/hdhomerun/settings-default.xml @@ -0,0 +1,4 @@ + + + + diff --git a/packages/addons/driver/hdhomerun/source/bin/hdhomerun.start b/packages/addons/driver/hdhomerun/source/bin/hdhomerun.start new file mode 100644 index 0000000000..3224d26d4d --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/bin/hdhomerun.start @@ -0,0 +1,28 @@ +#!/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_DIR="$HOME/.xbmc/addons/driver.dvb.hdhomerun" + +logger -t Hdhomerun "### Hdhomerun manual start ###" +. $ADDON_DIR/bin/userspace-driver.sh diff --git a/packages/addons/driver/hdhomerun/source/bin/hdhomerun.stop b/packages/addons/driver/hdhomerun/source/bin/hdhomerun.stop new file mode 100644 index 0000000000..94b1c5f60a --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/bin/hdhomerun.stop @@ -0,0 +1,26 @@ +#!/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 + +logger -t Hdhomerun "### Hdhomerun manual stop ###" +killall userhdhomerun diff --git a/packages/addons/driver/hdhomerun/source/bin/refresh-tuners.py b/packages/addons/driver/hdhomerun/source/bin/refresh-tuners.py new file mode 100644 index 0000000000..bc382eeb01 --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/bin/refresh-tuners.py @@ -0,0 +1,125 @@ +""" +################################################################################ +# This file is part of OpenELEC - http://www.openelec.tv +# Copyright (C) 2009-2013 Stephan Raue (stephan@openelec.tv) +# Copyright (C) 2013 ultraman/vpeter +# +# 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 +################################################################################ +""" + +import os +import sys +import shutil +import xmlpp +import xbmcaddon + +from xml.dom import minidom +from array import array + +__settings__ = xbmcaddon.Addon(id='driver.dvb.hdhomerun') +__cwd__ = __settings__.getAddonInfo('path') +__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml')) + +__hdhomerun_log__ = '/var/log/dvbhdhomerun.log' + +# make backup settings only once +try: + with open(__settings_xml__ + '_orig') as f: pass +except IOError as e: + shutil.copyfile(__settings_xml__, __settings_xml__ + '_orig') + +###################################################################################################### + +# get supported devices on a system (name) +tuners = [] +try: + for line in open(__hdhomerun_log__, 'r'): + line = line.strip() + if line.startswith('Registered tuner'): + name = line.split(':'); + name = name[2].strip() + tuners.append(name) +except IOError: + print 'Error reading log file ', __hdhomerun_log__ + +""" +root ~ # grep "Registered tuner" /var/log/dvbhdhomerun.log +Registered tuner, id from kernel: 0 name: 101ADD2B-0 +Registered tuner, id from kernel: 1 name: 101ADD2B-1 +Registered tuner, id from kernel: 2 name: 1031D75A-0 +Registered tuner, id from kernel: 3 name: 1031D75A-1 +""" + +###################################################################################################### + +xmldoc = minidom.parse(__settings_xml__) +category = xmldoc.getElementsByTagName('category') + +# remove all nodes with id started with ATTACHED_TUNER_ +for node_cat in category: + setting = node_cat.getElementsByTagName('setting') + for node_set in setting : + if 'id' in node_set.attributes.keys() and not node_set.getAttribute('id').find('ATTACHED_TUNER_'): + node_set.parentNode.removeChild(node_set) + +# add new ATTACHED_TUNER_ nodes for available tuners +for node_cat in category: + setting = node_cat.getElementsByTagName('setting') + for node_set in setting : + if 'label' in node_set.attributes.keys() and '9010' in node_set.getAttribute('label'): + for ix, tuner_name in enumerate(tuners): + tuner_name_var = tuner_name.replace('-', '_') + + node1 = xmldoc.createElement("setting") + node1.setAttribute("id", 'ATTACHED_TUNER_' + tuner_name_var + '_DVBMODE') + node1.setAttribute("label", tuner_name) + node1.setAttribute("type", 'labelenum') + node1.setAttribute("default", 'auto') + node1.setAttribute("values", 'auto|ATSC|DVB-C|DVB-T') + node_cat.appendChild(node1) + + node2 = xmldoc.createElement("setting") + node2.setAttribute("id", 'ATTACHED_TUNER_' + tuner_name_var + '_FULLNAME') + node2.setAttribute("label", '9020') + node2.setAttribute("type", 'bool') + node2.setAttribute("default", 'false') + node_cat.appendChild(node2) + + node3 = xmldoc.createElement("setting") + node3.setAttribute("id", 'ATTACHED_TUNER_' + tuner_name_var + '_DISABLE') + node3.setAttribute("label", '9030') + node3.setAttribute("type", 'bool') + node3.setAttribute("default", 'false') + node_cat.appendChild(node3) + + # for tuner + break + +###################################################################################################### + +# save file back +try: + outputfile=open(__settings_xml__, 'w') + xmlpp.pprint(xmldoc.toxml(), output=outputfile, indent=2) + outputfile.close() +except IOError: + print 'Error writing file ', __settings_xml__ + +###################################################################################################### + +# dialog is closed already so just open settings again +xbmcaddon.Addon(id='driver.dvb.hdhomerun').openSettings() diff --git a/packages/addons/driver/hdhomerun/source/bin/userspace-driver.sh b/packages/addons/driver/hdhomerun/source/bin/userspace-driver.sh old mode 100755 new mode 100644 index 3f589962a8..393cc2a5c9 --- a/packages/addons/driver/hdhomerun/source/bin/userspace-driver.sh +++ b/packages/addons/driver/hdhomerun/source/bin/userspace-driver.sh @@ -24,6 +24,11 @@ ADDON_DIR="$HOME/.xbmc/addons/driver.dvb.hdhomerun" ADDON_HOME="$HOME/.xbmc/userdata/addon_data/driver.dvb.hdhomerun" +ADDON_SETTINGS="$ADDON_HOME/settings.xml" + +# modules are not automatically loaded +modprobe dvb_hdhomerun +modprobe dvb_hdhomerun_fe mkdir -p $ADDON_HOME @@ -31,31 +36,84 @@ if [ ! -f "$ADDON_HOME/dvbhdhomerun.sample" ]; then cp $ADDON_DIR/config/* $ADDON_HOME/ fi +if [ ! -f "$ADDON_SETTINGS" ]; then + cp $ADDON_DIR/settings-default.xml $ADDON_SETTINGS +fi + +mkdir -p /var/config +cat "$ADDON_SETTINGS" | awk -F\" '{print $2"=\""$4"\""}' | sed '/^=/d' > /var/config/hdhomerun-addon.conf +. /var/config/hdhomerun-addon.conf + if [ -z "$(pidof userhdhomerun)" ]; then + if [ "$ENABLE_TUNER_TYPES" = "true" ]; then + DVBHDHOMERUN_CONF_TMP=/tmp/dvbhdhomerun.conf + touch $ADDON_HOME/dvbhdhomerun.conf + cp $ADDON_HOME/dvbhdhomerun.conf $DVBHDHOMERUN_CONF_TMP + + # get tuner serial numbers + SERIALS=$(cat /var/config/hdhomerun-addon.conf | sed -n 's|^ATTACHED_TUNER_\(.*\)_\(.*\)_DVBMODE=.*|\1-\2|gp' | sort | uniq) + . /var/config/hdhomerun-addon.conf + + for SERIAL in ${SERIALS[@]}; do + SERIAL_VAR=$(echo $SERIAL | sed 's|-|_|') + DVBMODE=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_DVBMODE) + FULLNAME=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_FULLNAME) + DISABLE=$(eval echo \$ATTACHED_TUNER_${SERIAL_VAR}_DISABLE) + + [ "$DVBMODE" = "auto" ] && DVBMODE="" + + # remove setttings for this tuner + awk -v val="[$SERIAL]" '$0 == val {flag=1; next} /^tuner_type=|^use_full_name=|^disable=|^#|^$/{if (flag==1) next} /.*/{flag=0; print}' $DVBHDHOMERUN_CONF_TMP >${DVBHDHOMERUN_CONF_TMP}-types + mv ${DVBHDHOMERUN_CONF_TMP}-types $DVBHDHOMERUN_CONF_TMP + echo "" >>$DVBHDHOMERUN_CONF_TMP + # remove empty lines at the end of file + sed -i '${/^$/d;}' $DVBHDHOMERUN_CONF_TMP + + ADDNEW=true + if [ -n "$DVBMODE" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP + echo "tuner_type=$DVBMODE" >>$DVBHDHOMERUN_CONF_TMP + fi + if [ "$FULLNAME" = "true" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP + echo "use_full_name=true" >>$DVBHDHOMERUN_CONF_TMP + fi + if [ "$DISABLE" = "true" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo "[$SERIAL]" >>$DVBHDHOMERUN_CONF_TMP + echo "disable=true" >>$DVBHDHOMERUN_CONF_TMP + fi + + echo "" >>$DVBHDHOMERUN_CONF_TMP + done + + md5_1=$(md5sum -b $DVBHDHOMERUN_CONF_TMP | awk '{print $1}') + md5_2=$(md5sum -b $ADDON_HOME/dvbhdhomerun.conf | awk '{print $1}') + if [ "$md5_1" != "$md5_2" ]; then + # file changed - copy to addon home + cp $DVBHDHOMERUN_CONF_TMP $ADDON_HOME/dvbhdhomerun.conf + fi + fi + rm -f /tmp/dvbhdhomerun if [ -f $ADDON_HOME/dvbhdhomerun.conf ]; then ln -s $ADDON_HOME/dvbhdhomerun.conf /tmp/dvbhdhomerun fi - # modules are not automatically loaded - modprobe dvb_hdhomerun - modprobe dvb_hdhomerun_fe - usleep 2000000 + [ -z "$PRE_WAIT" ] && PRE_WAIT=0 + PRE_WAIT=$(( $PRE_WAIT *1 )) + [ -z "$POST_WAIT" ] && POST_WAIT=0 + POST_WAIT=$(( $POST_WAIT *1 )) - # could be useful - if [ -f $ADDON_HOME/pre-wait.sh ]; then - sh $ADDON_HOME/pre-wait.sh - fi + logger -t HDHomeRun "### Pre wait for $PRE_WAIT sec ###" + sleep $PRE_WAIT mkdir -p /var/log/ rm -f /var/log/dvbhdhomerun.log - + userhdhomerun -f - # how much time should we wait? - usleep 1000000 - if [ -f $ADDON_HOME/post-wait.sh ]; then - sh $ADDON_HOME/post-wait.sh - fi + + logger -t HDHomeRun "### Post wait for $POST_WAIT sec ###" + sleep $POST_WAIT # save adapter names in background ( @@ -67,3 +125,5 @@ if [ -z "$(pidof userhdhomerun)" ]; then fi )& fi + +logger -t HDHomeRun "### HDHomeRun ready ###" diff --git a/packages/addons/driver/hdhomerun/source/bin/xmlpp.py b/packages/addons/driver/hdhomerun/source/bin/xmlpp.py new file mode 100644 index 0000000000..342dcc01d7 --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/bin/xmlpp.py @@ -0,0 +1,161 @@ +"""Pretty print an XML document. + +LICENCE: +Copyright (c) 2008, Fredrik Ekholdt +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +* Neither the name of Fredrik Ekholdt nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.""" + +import sys as _sys +import re as _re + +def _usage(this_file): + return """SYNOPSIS: pretty print an XML document +USAGE: python %s \n""" % this_file + +def _pprint_line(indent_level, line, width=100, output=_sys.stdout): + if line.strip(): + start = "" + number_chars = 0 + for l in range(indent_level): + start = start + " " + number_chars = number_chars + 1 + try: + elem_start = _re.findall("(\<\W{0,1}\w+:\w+) ?", line)[0] + elem_finished = _re.findall("([?|\]\]/]*\>)", line)[0] + #should not have * + attrs = _re.findall("(\S*?\=\".*?\")", line) + output.write(start + elem_start) + number_chars = len(start + elem_start) + for attr in attrs: + if (attrs.index(attr) + 1) == len(attrs): + number_chars = number_chars + len(elem_finished) + if (number_chars + len(attr) + 1) > width: + output.write("\n") + for i in range(len(start + elem_start) + 1): + output.write(" ") + number_chars = len(start + elem_start) + 1 + else: + output.write(" ") + number_chars = number_chars + 1 + output.write(attr) + number_chars = number_chars + len(attr) + output.write(elem_finished + "\n") + except IndexError: + #give up pretty print this line + output.write(start + line + "\n") + + +def _pprint_elem_content(indent_level, line, output=_sys.stdout): + if line.strip(): + for l in range(indent_level): + output.write(" ") + output.write(line + "\n") + +def _get_next_elem(data): + start_pos = data.find("<") + end_pos = data.find(">") + 1 + retval = data[start_pos:end_pos] + stopper = retval.rfind("/") + if stopper < retval.rfind("\""): + stopper = -1 + single = (stopper > -1 and ((retval.find(">") - stopper) < (stopper - retval.find("<")))) + + ignore_excl = retval.find(" -1 + ignore_question = retval.find(" -1 + + if ignore_excl: + cdata = retval.find(" -1 + if cdata: + end_pos = data.find("]]>") + if end_pos > -1: + end_pos = end_pos + len("]]>") + + elif ignore_question: + end_pos = data.find("?>") + len("?>") + ignore = ignore_excl or ignore_question + + no_indent = ignore or single + + #print retval, end_pos, start_pos, stopper > -1, no_indent + return start_pos, \ + end_pos, \ + stopper > -1, \ + no_indent + +def get_pprint(xml, indent=4, width=80): + """Returns the pretty printed xml """ + class out: + output = "" + + def write(self, string): + self.output += string + out = out() + pprint(xml, output=out, indent=indent, width=width) + + return out.output + + +def pprint(xml, output=_sys.stdout, indent=4, width=80): + """Pretty print xml. + Use output to select output stream. Default is sys.stdout + Use indent to select indentation level. Default is 4 """ + data = xml + indent_level = 0 + start_pos, end_pos, is_stop, no_indent = _get_next_elem(data) + while ((start_pos > -1 and end_pos > -1)): + _pprint_elem_content(indent_level, data[:start_pos].strip(), + output=output) + data = data[start_pos:] + if is_stop and not no_indent: + indent_level = indent_level - indent + _pprint_line(indent_level, + data[:end_pos - start_pos], + width=width, + output=output) + data = data[end_pos - start_pos:] + if not is_stop and not no_indent : + indent_level = indent_level + indent + + if not data: + break + else: + start_pos, end_pos, is_stop, no_indent = _get_next_elem(data) + + +if __name__ == "__main__": + if "-h" in _sys.argv or "--help" in _sys.argv: + _sys.stderr.write(_usage(_sys.argv[0])) + _sys.exit(1) + if len(_sys.argv) < 2: + _sys.stderr.write(_usage(_sys.argv[0])) + _sys.exit(1) + else: + filename = _sys.argv[1] + fh = open(filename) + + pprint(fh.read(), output=_sys.stdout, indent=4, width=80) diff --git a/packages/addons/driver/hdhomerun/source/default.py b/packages/addons/driver/hdhomerun/source/default.py old mode 100755 new mode 100644 diff --git a/packages/addons/driver/hdhomerun/source/resources/language/English/strings.xml b/packages/addons/driver/hdhomerun/source/resources/language/English/strings.xml new file mode 100644 index 0000000000..143e077530 --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/resources/language/English/strings.xml @@ -0,0 +1,12 @@ + + + General + Pre wait time [sec] + Post wait time [sec] + + Tuner settings + Enable modifying settings + Refresh... + use full name + disabled + diff --git a/packages/addons/driver/hdhomerun/source/resources/settings.xml b/packages/addons/driver/hdhomerun/source/resources/settings.xml new file mode 100644 index 0000000000..afaf8065f9 --- /dev/null +++ b/packages/addons/driver/hdhomerun/source/resources/settings.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/packages/addons/driver/hdhomerun/source/sleep.d/hdhomerun.power b/packages/addons/driver/hdhomerun/source/sleep.d/hdhomerun.power old mode 100755 new mode 100644 index c2c52fc1cd..02ac8750f3 --- a/packages/addons/driver/hdhomerun/source/sleep.d/hdhomerun.power +++ b/packages/addons/driver/hdhomerun/source/sleep.d/hdhomerun.power @@ -23,22 +23,22 @@ . /etc/profile LOCKDIR="/var/lock/" -LOCKFILE="hdhomerun" +LOCKFILE="$LOCKDIR/hdhomerun" case "$1" in hibernate|suspend) if [ -n "$(pidof userhdhomerun)" ]; then progress "Shutting down HDHomeRun driver for suspending..." mkdir -p "$LOCKDIR" - touch "$LOCKDIR/$LOCKFILE" + touch "$LOCKFILE" killall userhdhomerun fi ;; thaw|resume) - if [ -f "$LOCKDIR/$LOCKFILE" ]; then + if [ -f "$LOCKFILE" ]; then # driver started within Tvheadend/VDR - rm -rf "$LOCKDIR/$LOCKFILE" + rm -f "$LOCKFILE" fi ;; diff --git a/packages/addons/driver/sundtek-mediatv/changelog.txt b/packages/addons/driver/sundtek-mediatv/changelog.txt index 000cb4f4e1..7161defcaf 100644 --- a/packages/addons/driver/sundtek-mediatv/changelog.txt +++ b/packages/addons/driver/sundtek-mediatv/changelog.txt @@ -1,3 +1,5 @@ +3.0.3 + added addon settings for modifying tuner type (DVB-C, DVB-T) 3.0.2 added addon settings enable HW PID filter (enabled for RPi by default) diff --git a/packages/addons/driver/sundtek-mediatv/config/rc_key_enter b/packages/addons/driver/sundtek-mediatv/config/rc_key_enter new file mode 100644 index 0000000000..8dc5d931cb --- /dev/null +++ b/packages/addons/driver/sundtek-mediatv/config/rc_key_enter @@ -0,0 +1,32 @@ +0x01 KEY_SELECT +0x02 KEY_3 +0x03 KEY_EXIT +0x04 KEY_1 +0x05 KEY_5 +0x06 KEY_6 +0x07 KEY_CHANNELDOWN +0x08 KEY_2 +0x09 KEY_CHANNELUP +0x0a KEY_9 +0x0b KEY_ZOOM +0x0c KEY_7 +0x0d KEY_8 +0x0e KEY_VOLUMEUP +0x0f KEY_4 +0x10 KEY_BACK +0x11 KEY_0 +0x12 KEY_ENTER +0x13 KEY_VOLUMEDOWN +0x14 KEY_RECORD +0x15 KEY_STOP +0x16 KEY_PLAY +0x17 KEY_MUTE +0x18 KEY_UP +0x19 KEY_DOWN +0x1a KEY_LEFT +0x1b KEY_RIGHT +0x1c KEY_RED +0x1d KEY_GREEN +0x1e KEY_YELLOW +0x1f KEY_BLUE +0x43 KEY_POWER diff --git a/packages/addons/driver/sundtek-mediatv/config/rc_key_ok b/packages/addons/driver/sundtek-mediatv/config/rc_key_ok new file mode 100644 index 0000000000..13f2c608c8 --- /dev/null +++ b/packages/addons/driver/sundtek-mediatv/config/rc_key_ok @@ -0,0 +1,32 @@ +0x01 KEY_SELECT +0x02 KEY_3 +0x03 KEY_EXIT +0x04 KEY_1 +0x05 KEY_5 +0x06 KEY_6 +0x07 KEY_CHANNELDOWN +0x08 KEY_2 +0x09 KEY_CHANNELUP +0x0a KEY_9 +0x0b KEY_ZOOM +0x0c KEY_7 +0x0d KEY_8 +0x0e KEY_VOLUMEUP +0x0f KEY_4 +0x10 KEY_BACK +0x11 KEY_0 +0x12 KEY_OK +0x13 KEY_VOLUMEDOWN +0x14 KEY_RECORD +0x15 KEY_STOP +0x16 KEY_PLAY +0x17 KEY_MUTE +0x18 KEY_UP +0x19 KEY_DOWN +0x1a KEY_LEFT +0x1b KEY_RIGHT +0x1c KEY_RED +0x1d KEY_GREEN +0x1e KEY_YELLOW +0x1f KEY_BLUE +0x43 KEY_POWER diff --git a/packages/addons/driver/sundtek-mediatv/icon/icon.png b/packages/addons/driver/sundtek-mediatv/icon/icon.png index 912c71d6b9..eb4144b290 100644 Binary files a/packages/addons/driver/sundtek-mediatv/icon/icon.png and b/packages/addons/driver/sundtek-mediatv/icon/icon.png differ diff --git a/packages/addons/driver/sundtek-mediatv/meta b/packages/addons/driver/sundtek-mediatv/meta index 163e8d3de9..cb1b74034b 100644 --- a/packages/addons/driver/sundtek-mediatv/meta +++ b/packages/addons/driver/sundtek-mediatv/meta @@ -20,7 +20,7 @@ PKG_NAME="sundtek-mediatv" PKG_VERSION="3.0" -PKG_REV="2" +PKG_REV="3" PKG_ARCH="any" PKG_LICENSE="nonfree" PKG_SITE="http://support.sundtek.com/" diff --git a/packages/addons/driver/sundtek-mediatv/source/bin/refresh-tuners.py b/packages/addons/driver/sundtek-mediatv/source/bin/refresh-tuners.py new file mode 100644 index 0000000000..ba9771d103 --- /dev/null +++ b/packages/addons/driver/sundtek-mediatv/source/bin/refresh-tuners.py @@ -0,0 +1,172 @@ +""" +################################################################################ +# This file is part of OpenELEC - http://www.openelec.tv +# Copyright (C) 2009-2013 Stephan Raue (stephan@openelec.tv) +# Copyright (C) 2013 ultraman/vpeter +# +# 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 +################################################################################ +""" + +import os +import sys +import shutil +import xmlpp +import xbmcaddon + +from xml.dom import minidom +from array import array + +__settings__ = xbmcaddon.Addon(id='driver.dvb.sundtek-mediatv') +__cwd__ = __settings__.getAddonInfo('path') +__mediaclient__ = xbmc.translatePath(os.path.join(__cwd__, 'bin', 'mediaclient')) +__ld_preload__ = xbmc.translatePath(os.path.join(__cwd__, 'lib', 'libmediaclient.so')) +__settings_xml__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'settings.xml')) + +__mediaclient_e__ = 'LD_PRELOAD=' + __ld_preload__ + ' ' + __mediaclient__ + ' -e' + +# make backup settings only once +try: + with open(__settings_xml__ + '_orig') as f: pass +except IOError as e: + shutil.copyfile(__settings_xml__, __settings_xml__ + '_orig') + +###################################################################################################### + +# get supported devices on a system (name, serial number, type) +tuners = [] +p = os.popen(__mediaclient_e__, "r") +while 1: + line = p.readline() + if not line: + break + else: + str = line.strip() + if str.startswith('device '): + name = str[str.find("[")+1:str.find("]")] + tuners.append([name, 0, 's']) + + if str.startswith('[SERIAL]:'): + line = p.readline() + str = line.strip() + if str.startswith('ID:'): + id = str.split(':'); + id = id[1].strip() + tuners[len(tuners)-1] = [name, id, 's'] + + if str.startswith('[DVB-C]:'): + tuners[len(tuners)-1] = [name, id, 'c'] + elif str.startswith('[DVB-T]:'): + tuners[len(tuners)-1] = [name, id, 'c'] + elif str.startswith('[DVB-T2]:'): + tuners[len(tuners)-1] = [name, id, 'c'] + +""" +root ~ # mediaclient -e +**** List of Media Hardware Devices **** +device 0: [Sundtek MediaTV Pro (USB 2.0)] DVB-C, DVB-T, ANALOG-TV, FM-RADIO, REMOTE-CONTROL, OSS-AUDIO, RDS + [BUS]: + ID: 1-7 + [SERIAL]: + ID: U110714145205 + [DVB-C]: + FRONTEND: /dev/dvb/adapter0/frontend0 + DVR: /dev/dvb/adapter0/dvr0 + DMX: /dev/dvb/adapter0/demux0 + [DVB-T]: + FRONTEND: /dev/dvb/adapter0/frontend0 + DVR: /dev/dvb/adapter0/dvr0 + DMX: /dev/dvb/adapter0/demux0 + [ANALOG-TV]: + VIDEO0: /dev/video0 + VBI0: /dev/vbi0 + [FM-RADIO]: + RADIO0: /dev/radio0 + RDS: /dev/rds0 + [REMOTECONTROL]: + INPUT0: /dev/mediainput0 + [OSS]: + OSS0: /dev/dsp0 +""" + +###################################################################################################### + +xmldoc = minidom.parse(__settings_xml__) +category = xmldoc.getElementsByTagName('category') + +# remove all nodes with id started with ATTACHED_TUNER_ +for node_cat in category: + setting = node_cat.getElementsByTagName('setting') + for node_set in setting : + if 'id' in node_set.attributes.keys() and not node_set.getAttribute('id').find('ATTACHED_TUNER_'): + node_set.parentNode.removeChild(node_set) + +# add new ATTACHED_TUNER_ nodes for available tuners +for node_cat in category: + setting = node_cat.getElementsByTagName('setting') + for node_set in setting : + if 'label' in node_set.attributes.keys() and '9010' in node_set.getAttribute('label'): + for ix, tuner in enumerate(tuners): + tuner_name = tuner[0] + tuner_serial = tuner[1] + tuner_type = tuner[2] + + node1 = xmldoc.createElement("setting") + node1.setAttribute("id", 'ATTACHED_TUNER_' + tuner_serial + '_DVBMODE') + node1.setAttribute("label", tuner_name + ", " + tuner_serial) + node1.setAttribute("type", 'labelenum') + + if (tuner_type == 's'): + node1.setAttribute("default", 'DVB-S') + node1.setAttribute("values", 'DVB-S') + else: + node1.setAttribute("default", 'DVB-C') + node1.setAttribute("values", 'DVB-C|DVB-T') + + node_cat.appendChild(node1) + + node2 = xmldoc.createElement("setting") + node2.setAttribute("id", 'ATTACHED_TUNER_' + tuner_serial + '_IRPROT') + node2.setAttribute("label", '9020') + node2.setAttribute("type", 'labelenum') + node2.setAttribute("default", 'auto') + node2.setAttribute("values", 'auto|RC5|NEC|RC6') + node_cat.appendChild(node2) + + node3 = xmldoc.createElement("setting") + node3.setAttribute("id", 'ATTACHED_TUNER_' + tuner_serial + '_KEYMAP') + node3.setAttribute("label", '9030') + node3.setAttribute("type", 'text') + node3.setAttribute("default", 'rc_key_ok') + node_cat.appendChild(node3) + + # for tuner + break + +###################################################################################################### + +# save file back +try: + outputfile=open(__settings_xml__, 'w') + xmlpp.pprint(xmldoc.toxml(), output=outputfile, indent=2) + outputfile.close() +except IOError: + print 'Error writing file ', __settings_xml__ + +###################################################################################################### + +# dialog is closed already so just open settings again +xbmcaddon.Addon(id='driver.dvb.sundtek-mediatv').openSettings() diff --git a/packages/addons/driver/sundtek-mediatv/source/bin/userspace-driver.sh b/packages/addons/driver/sundtek-mediatv/source/bin/userspace-driver.sh index 3b50b046a5..b720d77cd5 100644 --- a/packages/addons/driver/sundtek-mediatv/source/bin/userspace-driver.sh +++ b/packages/addons/driver/sundtek-mediatv/source/bin/userspace-driver.sh @@ -46,7 +46,7 @@ else if [ -z "$entry_set" ]; then sed -i 's|^device_attach=.*|# device_attach not used anymore\n\n# enable HW PID filter\nuse_hwpidfilter=off\n\n# enable listening on network\nenablenetwork=off|g' $ADDON_HOME/sundtek.conf sed -i 's|^#first_adapter=.*|first_adapter=0|g' $ADDON_HOME/sundtek.conf - + sed -i 's|.*network tuner IP address (OpenELEC specific).*||g' $ADDON_HOME/sundtek.conf sed -i 's|.*network_tuner_ip=.*||g' $ADDON_HOME/sundtek.conf fi @@ -95,6 +95,7 @@ if [ ! -f $ADDON_DIR/bin/mediasrv ]; then # enable HW PID filter on RPi by default sed -i 's|^use_hwpidfilter=.*|use_hwpidfilter=on|g' $ADDON_DIR/config/sundtek.conf sed -i 's|^use_hwpidfilter=.*|use_hwpidfilter=on|g' $ADDON_HOME/sundtek.conf + sed -i 's|.*id="ENABLE_HW_PID_FILTER".*||' $ADDON_DIR/settings-default.xml sed -i 's|.*id="ENABLE_HW_PID_FILTER".*||' $ADDON_SETTINGS else logger -t Sundtek "### Unsupported architecture ###" @@ -214,7 +215,7 @@ if [ -z "$(pidof mediasrv)" ]; then # remove empty lines at the end of file sed -i '${/^$/d;}' $SUNDTEK_CONF_TMP # add entries - echo "[NETWORK]" >>$SUNDTEK_CONF_TMP + echo -e "\n[NETWORK]" >>$SUNDTEK_CONF_TMP for dev in $(seq 0 $DEVICE1_NUM); do echo "device=$DEVICE1_IP:$dev" >>$SUNDTEK_CONF_TMP done @@ -247,6 +248,53 @@ if [ -z "$(pidof mediasrv)" ]; then sed -i '${/^$/d;}' $SUNDTEK_CONF_TMP fi + if [ "$ENABLE_TUNER_TYPES" = "true" ]; then + # get tuner serial numbers + SERIALS=$(cat /var/config/sundtek-addon.conf | sed -n 's|^ATTACHED_TUNER_\(.*\)_DVBMODE=.*|\1|gp' | sort | uniq) + . /var/config/sundtek-addon.conf + + for SERIAL in ${SERIALS[@]}; do + DVBMODE=$(eval echo \$ATTACHED_TUNER_${SERIAL}_DVBMODE) + IRPROT=$(eval echo \$ATTACHED_TUNER_${SERIAL}_IRPROT) + KEYMAP=$(eval echo \$ATTACHED_TUNER_${SERIAL}_KEYMAP) + + if [ "$DVBMODE" = "DVB-T" ]; then + # only set DVB-T because default is DVB-C (and DVB-S is not set either) + DVBMODE="DVBT" + else + DVBMODE="" + fi + + [ "$IRPROT" = "NEC" -o "$IRPROT" = "auto" ] && IRPROT="" + + KEYMAP_FILE="$ADDON_HOME/$KEYMAP" + [ ! -f $KEYMAP_FILE ] && KEYMAP_FILE="" + + # remove setttings for this tuner + awk -v val="[$SERIAL]" '$0 == val {flag=1; next} /^ir_protocol=|^rcmap=|^initial_dvb_mode=|^#|^$/{if (flag==1) next} /.*/{flag=0; print}' $SUNDTEK_CONF_TMP >${SUNDTEK_CONF_TMP}-types + mv ${SUNDTEK_CONF_TMP}-types $SUNDTEK_CONF_TMP + echo "" >>$SUNDTEK_CONF_TMP + # remove empty lines at the end of file + sed -i '${/^$/d;}' $SUNDTEK_CONF_TMP + + ADDNEW=true + if [ -n "$DVBMODE" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo -e "\n[$SERIAL]" >>$SUNDTEK_CONF_TMP + echo "initial_dvb_mode=$DVBMODE" >>$SUNDTEK_CONF_TMP + fi + if [ -n "$IRPROT" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo -e "\n[$SERIAL]" >>$SUNDTEK_CONF_TMP + echo "ir_protocol=$IRPROT" >>$SUNDTEK_CONF_TMP + fi + if [ -n "$KEYMAP_FILE" ]; then + [ $ADDNEW = true ] && ADDNEW=false && echo -e "\n[$SERIAL]" >>$SUNDTEK_CONF_TMP + echo "rcmap=$KEYMAP_FILE" >>$SUNDTEK_CONF_TMP + fi + + echo "" >>$SUNDTEK_CONF_TMP + done + fi + md5_1=$(md5sum -b $SUNDTEK_CONF_TMP | awk '{print $1}') md5_2=$(md5sum -b $ADDON_HOME/sundtek.conf | awk '{print $1}') if [ "$md5_1" != "$md5_2" ]; then diff --git a/packages/addons/driver/sundtek-mediatv/source/bin/xmlpp.py b/packages/addons/driver/sundtek-mediatv/source/bin/xmlpp.py new file mode 100644 index 0000000000..342dcc01d7 --- /dev/null +++ b/packages/addons/driver/sundtek-mediatv/source/bin/xmlpp.py @@ -0,0 +1,161 @@ +"""Pretty print an XML document. + +LICENCE: +Copyright (c) 2008, Fredrik Ekholdt +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +* Neither the name of Fredrik Ekholdt nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE.""" + +import sys as _sys +import re as _re + +def _usage(this_file): + return """SYNOPSIS: pretty print an XML document +USAGE: python %s \n""" % this_file + +def _pprint_line(indent_level, line, width=100, output=_sys.stdout): + if line.strip(): + start = "" + number_chars = 0 + for l in range(indent_level): + start = start + " " + number_chars = number_chars + 1 + try: + elem_start = _re.findall("(\<\W{0,1}\w+:\w+) ?", line)[0] + elem_finished = _re.findall("([?|\]\]/]*\>)", line)[0] + #should not have * + attrs = _re.findall("(\S*?\=\".*?\")", line) + output.write(start + elem_start) + number_chars = len(start + elem_start) + for attr in attrs: + if (attrs.index(attr) + 1) == len(attrs): + number_chars = number_chars + len(elem_finished) + if (number_chars + len(attr) + 1) > width: + output.write("\n") + for i in range(len(start + elem_start) + 1): + output.write(" ") + number_chars = len(start + elem_start) + 1 + else: + output.write(" ") + number_chars = number_chars + 1 + output.write(attr) + number_chars = number_chars + len(attr) + output.write(elem_finished + "\n") + except IndexError: + #give up pretty print this line + output.write(start + line + "\n") + + +def _pprint_elem_content(indent_level, line, output=_sys.stdout): + if line.strip(): + for l in range(indent_level): + output.write(" ") + output.write(line + "\n") + +def _get_next_elem(data): + start_pos = data.find("<") + end_pos = data.find(">") + 1 + retval = data[start_pos:end_pos] + stopper = retval.rfind("/") + if stopper < retval.rfind("\""): + stopper = -1 + single = (stopper > -1 and ((retval.find(">") - stopper) < (stopper - retval.find("<")))) + + ignore_excl = retval.find(" -1 + ignore_question = retval.find(" -1 + + if ignore_excl: + cdata = retval.find(" -1 + if cdata: + end_pos = data.find("]]>") + if end_pos > -1: + end_pos = end_pos + len("]]>") + + elif ignore_question: + end_pos = data.find("?>") + len("?>") + ignore = ignore_excl or ignore_question + + no_indent = ignore or single + + #print retval, end_pos, start_pos, stopper > -1, no_indent + return start_pos, \ + end_pos, \ + stopper > -1, \ + no_indent + +def get_pprint(xml, indent=4, width=80): + """Returns the pretty printed xml """ + class out: + output = "" + + def write(self, string): + self.output += string + out = out() + pprint(xml, output=out, indent=indent, width=width) + + return out.output + + +def pprint(xml, output=_sys.stdout, indent=4, width=80): + """Pretty print xml. + Use output to select output stream. Default is sys.stdout + Use indent to select indentation level. Default is 4 """ + data = xml + indent_level = 0 + start_pos, end_pos, is_stop, no_indent = _get_next_elem(data) + while ((start_pos > -1 and end_pos > -1)): + _pprint_elem_content(indent_level, data[:start_pos].strip(), + output=output) + data = data[start_pos:] + if is_stop and not no_indent: + indent_level = indent_level - indent + _pprint_line(indent_level, + data[:end_pos - start_pos], + width=width, + output=output) + data = data[end_pos - start_pos:] + if not is_stop and not no_indent : + indent_level = indent_level + indent + + if not data: + break + else: + start_pos, end_pos, is_stop, no_indent = _get_next_elem(data) + + +if __name__ == "__main__": + if "-h" in _sys.argv or "--help" in _sys.argv: + _sys.stderr.write(_usage(_sys.argv[0])) + _sys.exit(1) + if len(_sys.argv) < 2: + _sys.stderr.write(_usage(_sys.argv[0])) + _sys.exit(1) + else: + filename = _sys.argv[1] + fh = open(filename) + + pprint(fh.read(), output=_sys.stdout, indent=4, width=80) diff --git a/packages/addons/driver/sundtek-mediatv/source/resources/language/English/strings.xml b/packages/addons/driver/sundtek-mediatv/source/resources/language/English/strings.xml index a76c6fd8d5..97d55aa426 100644 --- a/packages/addons/driver/sundtek-mediatv/source/resources/language/English/strings.xml +++ b/packages/addons/driver/sundtek-mediatv/source/resources/language/English/strings.xml @@ -3,11 +3,12 @@ General Auto update binary driver Enable analog TV - Extra settle time + Extra delay [sec] Run user script Enable hardware PID filter Enable IR receiver Lowest adapter number (/dev/dvb/adapterX/) + Networking Share local tuner over network Use network shared tuners @@ -21,4 +22,10 @@ # of tuners Server 5 IP address # of tuners + + Tuner settings + Enable modifying settings + Refresh... + IR protocol + keymap filename diff --git a/packages/addons/driver/sundtek-mediatv/source/resources/settings.xml b/packages/addons/driver/sundtek-mediatv/source/resources/settings.xml index 6b4940cfdc..24ffab9056 100644 --- a/packages/addons/driver/sundtek-mediatv/source/resources/settings.xml +++ b/packages/addons/driver/sundtek-mediatv/source/resources/settings.xml @@ -1,7 +1,6 @@ - @@ -12,7 +11,6 @@ - @@ -27,4 +25,9 @@ + + + + + diff --git a/packages/mediacenter/xbmc/init.d/93_xbmc b/packages/mediacenter/xbmc/init.d/93_xbmc index dbf86a2f69..fa4606486f 100644 --- a/packages/mediacenter/xbmc/init.d/93_xbmc +++ b/packages/mediacenter/xbmc/init.d/93_xbmc @@ -52,6 +52,15 @@ fi # waiting for Xorg to start wait_for_xorg +# wait for network + wait_for_inet_addr + +# set cpu's to 'conservative' + ( usleep 15000000 + progress "set cpu's to 'ondemand'" + cpupower frequency-set -g ondemand > /dev/null 2>&1 + )& + # prevent restrating XBMC at reboot or shutdown LOCKDIR="/var/lock/" LOCKFILE="xbmc.disabled" diff --git a/packages/network/connman/profile.d/connman.conf b/packages/network/connman/profile.d/connman.conf new file mode 100644 index 0000000000..ec281cd8e6 --- /dev/null +++ b/packages/network/connman/profile.d/connman.conf @@ -0,0 +1,36 @@ +################################################################################ +# 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 +################################################################################ + +wait_for_inet_addr () { + if [ -f /var/config/settings.conf ]; then + . /var/config/settings.conf + fi + + if [ "$WAIT_NETWORK" = "true" ] ; then + progress "Wait for network" + [ -z "$WAIT_NETWORK_TIME" ] && WAIT_NETWORK_TIME=10 + LOOP_COUNT=$[$WAIT_NETWORK_TIME * 5] + for i in $(seq 1 $LOOP_COUNT) ; do + cnt=$(ifconfig | sed -e '/inet addr:/!d' -e '/127.0.0.1/d' |wc -l) + [ $cnt -gt 0 ] && break + usleep 200000 + done + fi +}