From 4f2ae968eae25728842499f8251aca3d5dc7e2c8 Mon Sep 17 00:00:00 2001 From: theuni Date: Wed, 1 Dec 2010 04:01:44 +0000 Subject: [PATCH] Backport ipv6 disabling script. Squashed 3 commits. disable IPv6 from within XBMC via advancedsettings (cherry picked from commit 4adc0fb8907751e2b39d58aeab5403266cab7ac4) proper initial commit (cherry picked from commit 875600bebfe514c7b87b5b0573a73cd0cf315f1e) skip if advsetting is in place (cherry picked from commit d177ec063a4af8b310d80675b7ff8d678b380deb) git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@35554 568bbfeb-2a22-0410-94d2-cc84cf5bfa90 --- tools/XBMCLive/live.d/13-disableXBMCIPv6.sh | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 tools/XBMCLive/live.d/13-disableXBMCIPv6.sh diff --git a/tools/XBMCLive/live.d/13-disableXBMCIPv6.sh b/tools/XBMCLive/live.d/13-disableXBMCIPv6.sh new file mode 100755 index 0000000..d96170a --- /dev/null +++ b/tools/XBMCLive/live.d/13-disableXBMCIPv6.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Copyright (C) 2005-2008 Team XBMC +# http://www.xbmc.org +# +# 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 XBMC; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# http://www.gnu.org/copyleft/gpl.html + +kernelParams=$(cat /proc/cmdline) + +subString=${kernelParams##*xbmc=} +xbmcParams=${subString%% *} + +activationToken="doNotDisableIPv6InXBMC" + +# if strings are the same the token is NOT part of the parameters list +# here we want to stop script if the token is NOT there +if [ "$xbmcParams" != "${xbmcParams%$activationToken*}" ] ; then + exit +fi + +xbmcUser=xbmc +# Read configuration variable file if it is present +[ -r /etc/default/xbmc-live ] && . /etc/default/xbmc-live +if ! getent passwd $xbmcUser >/dev/null; then + xbmcUser=$(getent passwd 1000 | sed -e 's/\:.*//') +fi + +if [ ! -f /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml ] ; then + mkdir -p /home/$xbmcUser/.xbmc/userdata &> /dev/null + cat > /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml << 'EOF' + + + true + + +EOF + chown -R $xbmcUser:$xbmcUser /home/$xbmcUser/.xbmc +else + if ! grep -i -q disableipv6 /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml ; then + if grep -i -q "" /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml ; then + sed -i -e 's%%&\ntrue%' /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml + else + sed -i -e 's%%&\n\ntrue\n%' /home/$xbmcUser/.xbmc/userdata/advancedsettings.xml + fi + fi +fi + +exit 0 -- 2.7.4