[X2Go-Commits] [live-build-x2go] 134/167: fixed useless use of cat made sure double/single quotes work for parameters with spaces

git-admin at x2go.org git-admin at x2go.org
Sat Nov 18 00:32:57 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch feature/openbox-magic-pixel-workaround
in repository live-build-x2go.

commit 54a435487bf70842c90f1d90ef57d86c95e2a301
Author: Stefan Baur <kontakt at baur-itcs.de>
Date:   Mon Oct 30 10:51:36 2017 +0100

    fixed useless use of cat
    made sure double/single quotes work for parameters with spaces
---
 .../lib/live/config/2100-show-sysconf              |  2 +-
 .../lib/live/config/2250-getsshpubkeysfromserver   |  3 +-
 .../lib/live/config/2300-xserver-xorg-getxorgconf  |  7 ++--
 .../lib/live/config/2400-live-autoupdate           | 26 ++++++-------
 .../includes.chroot/lib/live/config/2600-tcpprint  |  7 ++--
 .../lib/live/config/2700-x2go-getsessions          |  7 ++--
 .../lib/live/config/2710-x2go-getbranding          |  7 ++--
 .../lib/live/config/2720-x2go-getbg                |  7 ++--
 .../lib/live/config/2900-x2go-thinclientconfig     | 45 ++++++++++------------
 9 files changed, 48 insertions(+), 63 deletions(-)

diff --git a/config/includes.chroot/lib/live/config/2100-show-sysconf b/config/includes.chroot/lib/live/config/2100-show-sysconf
index 35b86c5..f703a6c 100755
--- a/config/includes.chroot/lib/live/config/2100-show-sysconf
+++ b/config/includes.chroot/lib/live/config/2100-show-sysconf
@@ -20,7 +20,7 @@ fi
 
 (
 	if grep -q findiso /proc/cmdline ; then
-		BOOTEDENV=\$(basename \$(dirname \$(cat /proc/cmdline | sed -e 's/ \([^ ]*\)=/\n\1=/g' | awk -F'=' ' \$1 == "findiso" { print \$2 }')) | tr -dc 'a-zA-Z0-9. _\-')
+		BOOTEDENV=\$(basename \$(dirname \$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | awk -F'=' ' \$1 == "findiso" { print \$2 }')) | tr -dc 'a-zA-Z0-9. _\-')
 	fi
 	for TIMESTAMPFILE in /lib/live/mount/rootfs/*/lib; do
 		TIMESTAMP=\$(stat -c %Y \$TIMESTAMPFILE)
diff --git a/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver b/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver
index e6cac51..473fe01 100755
--- a/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver
+++ b/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver
@@ -8,8 +8,7 @@ GetSSHPubKeysFromServer ()
 	echo -n " getsshpubkeysfromserver"
 
 
-	PUBKEYURL=$(cat /proc/cmdline | \
-		    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
+	PUBKEYURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
 		    awk -F'=' ' /^pubkey=/ { print $2 }' |\
 		    tr -dc 'a-zA-Z0-9.:/?%_\-')
 
diff --git a/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf b/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf
index c20e59f..9390e9e 100755
--- a/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf
+++ b/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf
@@ -6,10 +6,9 @@ XServerXorgGetXorgConf ()
 #
 echo -n " xserver-xorg-getxorgconf"
 
-        XORGCONFURL=$(cat /proc/cmdline | \
-                       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-                       awk -F'=' ' /^xorgconfurl=/ { print $2 }' | \
-		       tr -dc 'a-zA-Z0-9.:/?%_\-')
+        XORGCONFURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+                      awk -F'=' ' /^xorgconfurl=/ { print $2 }' | \
+		      tr -dc 'a-zA-Z0-9.:/?%_\-')
         if [ -n "$XORGCONFURL" ] && [ -d /etc/X11 ] ; then 
 		XORGCONFDESTINATION=/etc/X11/xorg.conf.new
 	        cat >/etc/network/if-up.d/0300-getxorgconf <<GETXORG
diff --git a/config/includes.chroot/lib/live/config/2400-live-autoupdate b/config/includes.chroot/lib/live/config/2400-live-autoupdate
index 7e94258..919cb44 100755
--- a/config/includes.chroot/lib/live/config/2400-live-autoupdate
+++ b/config/includes.chroot/lib/live/config/2400-live-autoupdate
@@ -119,7 +119,7 @@ echo -n " live-autoupdater (backgrounding update task)"
 	unset LC_MESSAGES
 
 	# Define our mountpoint and check if we're capable of auto-updating
-	NTFSROOT=$(cat /proc/cmdline | sed -e 's/ \([^ ]*\)=/\n\1=/g' | awk -F '=' '/^ntfs-uuid/ { print $2 }' |  tr -dc 'a-zA-Z0-9_\-')
+	NTFSROOT=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | awk -F '=' '/^ntfs-uuid/ { print $2 }' |  tr -dc 'a-zA-Z0-9_\-')
 	if [ -n "$NTFSROOT" ]; then
 		mkdir -p /lib/live/mount/ntfsroot
 		# This is in case we've been passed an incomplete UUID and/or one with dashes
@@ -128,7 +128,7 @@ echo -n " live-autoupdater (backgrounding update task)"
 		if ! [ -L "/dev/disk/by-uuid/$NTFSROOT" ]; then
 			NTFSROOT=$(echo $NTFSROOT | tr -d '-')
 			if ! [ -L "/dev/disk/by-uuid/$NTFSROOT" ]; then
-				NTFSROOT=$(basename $(echo /dev/disk/by-uuid/*$NTFSROOT | sed -e 's/ \([^ ]*\)=/\n\1=/g' | head -1))
+				NTFSROOT=$(basename $(echo /dev/disk/by-uuid/*$NTFSROOT | tr ' ' '\n' | head -1))
 			fi
 		fi
 
@@ -162,8 +162,7 @@ echo -n " live-autoupdater (backgrounding update task)"
 	fi
 
 	# determine our booted environment as well as the other available ones
-	RUNNINGSYSTEMFULLPATH=$(dirname $(readlink -m "$MOUNTPOINT/$(cat /proc/cmdline | \
-				sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
+	RUNNINGSYSTEMFULLPATH=$(dirname $(readlink -m "$MOUNTPOINT/$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
 				awk -F'=' ' /^findiso=/ { print $2 }' | \
 				tr -dc 'a-zA-Z0-9./ _\-')"))
 
@@ -171,8 +170,7 @@ echo -n " live-autoupdater (backgrounding update task)"
 	RUNNINGSYSTEMNAME=$(basename $RUNNINGSYSTEMFULLPATH)
 
 	# download url pointing to directory with all required files goes here
-	DOWNLOADURL=$(cat /proc/cmdline | \
-		       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
+	DOWNLOADURL=$( sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
 		       awk -F'=' ' /^updateurl=/ { print $2 }' | \
 		       tr -dc 'a-zA-Z0-9.:/?%_\-')
 
@@ -185,7 +183,7 @@ echo -n " live-autoupdater (backgrounding update task)"
 		echo -n "\n$(date +'%F | %T | ')'$0': '/lib/live/mount/findiso' directory not found. Scanning for partitions."
 		LISTOFPARTITIONS=$(grep -H ^0$ /sys/block/*/removable | awk -F '/' '{ print $4 }' | xargs -n 1 -I XXX fdisk -l /dev/XXX 2>/dev/null | awk '$0 ~ /Linux$/ { print $1}')
 		TEMPMOUNT=$(mktemp -d -p /lib/live/mount/)
-		FINDFILE=$(cat /proc/cmdline | sed -e 's/ \([^ ]*\)=/\n\1=/g' | awk -F '=' '$1 == "findiso" { print $2 }' | tr -dc 'a-zA-Z0-9./ _\-')
+		FINDFILE=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | awk -F '=' '$1 == "findiso" { print $2 }' | tr -dc 'a-zA-Z0-9./ _\-')
 		[ -z "$FINDFILE" ] && exit 0
 		for PARTITION in $LISTOFPARTITIONS ; do
 			mount -oro $PARTITION $TEMPMOUNT
@@ -215,10 +213,9 @@ echo -n " live-autoupdater (backgrounding update task)"
 	# Bandwidth limit goes here
 	#
 	#BWLIMITPERCENT=20 # in percent, numeric-only
-	BWLIMITPERCENT=$(cat /proc/cmdline | \
-				sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-				awk -F'=' ' /^bwlimit=/ { print $2 }' | \
-				tr -dc '0-9')
+	BWLIMITPERCENT=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+			 awk -F'=' ' /^bwlimit=/ { print $2 }' | \
+			 tr -dc '0-9')
 	if [ -z "$BWLIMITPERCENT" ]; then 
 		BWLIMITPERCENT=20
 		echo -n "\n$(date +'%F | %T | ')'$0': Bandwidth limit not set. Defaulting to 20%."
@@ -227,10 +224,9 @@ echo -n " live-autoupdater (backgrounding update task)"
 
 	# sleeping a random amount of time to ease load on the update server
 	#
-	MAXSLEEPTIME=$(cat /proc/cmdline | \
-				sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-				awk -F'=' ' /^updatesleep=/ && $2 ~ /^[0-9]*$/ { print $2 }' | \
-				tr -dc '0-9')
+	MAXSLEEPTIME=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+		       awk -F'=' ' /^updatesleep=/ && $2 ~ /^[0-9]*$/ { print $2 }' | \
+		       tr -dc '0-9')
 	if [ -z "$MAXSLEEPTIME" ] || [ $MAXSLEEPTIME -lt 240 ] ; then
 		MAXSLEEPTIME=900
 	fi
diff --git a/config/includes.chroot/lib/live/config/2600-tcpprint b/config/includes.chroot/lib/live/config/2600-tcpprint
index b9fa523..600008a 100755
--- a/config/includes.chroot/lib/live/config/2600-tcpprint
+++ b/config/includes.chroot/lib/live/config/2600-tcpprint
@@ -9,10 +9,9 @@ echo -n " tcpprint"
 
 if grep -q "\W*tcpprint\W*" /proc/cmdline ; then
 
-        TCPPRINTONLYFROM=$(cat /proc/cmdline | \
-                       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-                       awk -F'=' ' /^tcpprintonlyfrom=/ { print $2 }' | \
-		       tr -dc 'a-zA-Z0-9.\-')
+        TCPPRINTONLYFROM=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+                           awk -F'=' ' /^tcpprintonlyfrom=/ { print $2 }' | \
+		           tr -dc 'a-zA-Z0-9.\-')
 	if [ -n "$TCPPRINTONLYFROM" ] ; then
 		TCPPRINTONLYFROM="only_from = $TCPPRINTONLYFROM"
 	fi
diff --git a/config/includes.chroot/lib/live/config/2700-x2go-getsessions b/config/includes.chroot/lib/live/config/2700-x2go-getsessions
index 4972b92..9af7813 100755
--- a/config/includes.chroot/lib/live/config/2700-x2go-getsessions
+++ b/config/includes.chroot/lib/live/config/2700-x2go-getsessions
@@ -6,10 +6,9 @@ X2GoGetSessions ()
 	#
 	echo -n " x2go-getsessions"
 
-	SESSIONSURL=$(cat /proc/cmdline | \
-		       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-		       awk -F'=' ' /^sessionsurl=/ { print $2 }' | \
-		       tr -dc 'a-zA-Z0-9.:/?%_\-')
+	SESSIONSURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+		      awk -F'=' ' /^sessionsurl=/ { print $2 }' | \
+		      tr -dc 'a-zA-Z0-9.:/?%_\-')
 	if [ -n "$SESSIONSURL" ] && [ -d /etc/x2go ] ; then 
 		# only mv this file if SESSIONSURL was set. If not, leave it in place - as
                 # it might have been customized at image creation time
diff --git a/config/includes.chroot/lib/live/config/2710-x2go-getbranding b/config/includes.chroot/lib/live/config/2710-x2go-getbranding
index e9297e1..71bdfaa 100755
--- a/config/includes.chroot/lib/live/config/2710-x2go-getbranding
+++ b/config/includes.chroot/lib/live/config/2710-x2go-getbranding
@@ -7,10 +7,9 @@ X2GoGetBranding ()
 	echo -n " x2go-getbranding"
 
 
-	BRANDINGURL=$(cat /proc/cmdline | \
-		       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-		       awk -F'=' ' /^branding=/ { print $2 }' | \
-		       tr -dc 'a-zA-Z0-9.:/?%_\-')
+	BRANDINGURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+		      awk -F'=' ' /^branding=/ { print $2 }' | \
+		      tr -dc 'a-zA-Z0-9.:/?%_\-')
 	BRANDINGDESTINATION=/etc/x2go/branding.svg
 
 	if [ -n "$BRANDINGURL" ] ; then
diff --git a/config/includes.chroot/lib/live/config/2720-x2go-getbg b/config/includes.chroot/lib/live/config/2720-x2go-getbg
index caae25e..b211f85 100755
--- a/config/includes.chroot/lib/live/config/2720-x2go-getbg
+++ b/config/includes.chroot/lib/live/config/2720-x2go-getbg
@@ -7,10 +7,9 @@ X2GoGetBG ()
 	echo -n " x2go-getbg"
 
 
-	BGURL=$(cat /proc/cmdline | \
-		       sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-		       awk -F'=' ' /^bg=/ { print $2 }' | \
-		       tr -dc 'a-zA-Z0-9.:/?%_\-')
+	BGURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+		awk -F'=' ' /^bg=/ { print $2 }' | \
+		tr -dc 'a-zA-Z0-9.:/?%_\-')
 	BGDESTINATION=/etc/x2go/bg.svg
 
 	if [ -n "$BGURL" ] ; then
diff --git a/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
index 72dc7b7..e5dbdbe 100755
--- a/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
+++ b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
@@ -28,7 +28,7 @@ cat >/home/user/.xsession <<XSESSION
 pulseaudio -D -n -L 'module-native-protocol-tcp port=4713' -L 'module-udev-detect' --exit-idle-time=65535 &
 
 # additional variable instead of "case \$(...) in", as we need the value again later on
-XRANDRCMDTAINTED=\$(cat /proc/cmdline | sed -e 's/ \([^ ]*\)=/\n\1=/g' | awk -F '=' '\$1 == "xinerama" { print \$2 }')
+XRANDRCMDTAINTED=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | awk -F '=' '\$1 == "xinerama" { print \$2 }')
 
 # sanitize input
 case \$XRANDRCMDTAINTED in
@@ -89,29 +89,24 @@ openbox &
 xsetroot -solid "#246ed8"
 
 # Get X2GoConfig
-BROKERURL=\$(cat /proc/cmdline | \
-	    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-	    awk -F'=' ' /^broker-url=/ { print \$2 }' | \
-	    tr -dc 'a-zA-Z0-9.:/?%_\-')
-SESSIONSELECT=\$(cat /proc/cmdline | \
-	    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-	    awk -F'=' ' /^session=/ { print \$2 }' | \
-	    tr -dc 'a-zA-Z0-9.:/ _\-')
-LDAP=\$(cat /proc/cmdline | \
-	    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-	    sed 's/^ldap=/ldap#/' | \
-	    awk -F'#' ' /^ldap#/ { print \$2 }' | \
-	    tr -dc 'a-zA-Z0-9.:_\-')
-LDAP1=\$(cat /proc/cmdline | \
-	    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-	    sed 's/^ldap1=/ldap1#/' | \
-	    awk -F'#' ' /^ldap1#/ { print \$2 }' | \
-	    tr -dc 'a-zA-Z0-9.:_\-')
-LDAP2=\$(cat /proc/cmdline | \
-	    sed -e 's/ \([^ ]*\)=/\n\1=/g' | \
-	    sed 's/^ldap2=/ldap2#/' | \
-	    awk -F'#' ' /^ldap2#/ { print \$2 }' | \
-	    tr -dc 'a-zA-Z0-9.:_\-')
+BROKERURL=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+	     awk -F'=' ' /^broker-url=/ { print \$2 }' | \
+	     tr -dc 'a-zA-Z0-9.:/?%_\-')
+SESSIONSELECT=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+	         awk -F'=' ' /^session=/ { print \$2 }' | \
+	         tr -dc 'a-zA-Z0-9.:/ _\-')
+LDAP=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+	sed 's/^ldap=/ldap#/' | \
+	awk -F'#' ' /^ldap#/ { print \$2 }' | \
+	tr -dc 'a-zA-Z0-9.:_\-')
+LDAP1=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+	 sed 's/^ldap1=/ldap1#/' | \
+	 awk -F'#' ' /^ldap1#/ { print \$2 }' | \
+	 tr -dc 'a-zA-Z0-9.:_\-')
+LDAP2=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | \
+	 sed 's/^ldap2=/ldap2#/' | \
+	 awk -F'#' ' /^ldap2#/ { print \$2 }' | \
+	 tr -dc 'a-zA-Z0-9.:_\-')
 
 
 # Check for background and branding SVGs
@@ -166,7 +161,7 @@ else
 	LDAPPARAMS=""
 fi
 
-BLANKINGTIME=\$(cat /proc/cmdline | sed -e 's/ \([^ ]*\)=/\n\1=/g' | awk -F '=' '\$1 == "blank" { print \$2 }' | tr -dc '0-9:')
+BLANKINGTIME=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' /proc/cmdline | awk -F '=' '\$1 == "blank" { print \$2 }' | tr -dc '0-9:')
 if [ -n "\$BLANKINGTIME" ]; then
 	DPMSARR=(\$(echo \$BLANKINGTIME | awk -F ':' '\$1 ~/^[0-9]*\$/ && \$2 ~/^[0-9]*\$/ && \$3 ~/^[0-9]*\$/  { print \$1 " " \$2 " " \$3}'))
 	if [ \${DPMSARR[0]} -eq 0 ]; then

--
Alioth's /srv/git/code.x2go.org/live-build-x2go.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/live-build-x2go.git


More information about the x2go-commits mailing list