[X2Go-Commits] [live-build-x2go] 37/160: renamed files to make space for a new 2000- file

git-admin at x2go.org git-admin at x2go.org
Sat Nov 18 01:55:36 CET 2017


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

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

commit bf9d1d070fbf59399da1faf983028568a11871a7
Author: Stefan Baur (BAUR-ITCS) <kontakt at baur-itcs.de>
Date:   Sun Jul 23 14:32:47 2017 +0200

    renamed files to make space for a new 2000- file
---
 .../lib/live/config/2100-showifconfig              |  43 ++
 .../includes.chroot/lib/live/config/2200-lockuser  |  20 +
 .../lib/live/config/2250-getsshpubkeysfromserver   |  55 +++
 .../lib/live/config/2300-xserver-xorg-getxorgconf  |  45 +++
 .../lib/live/config/2400-live-autoupdate           | 439 +++++++++++++++++++++
 .../live/config/2500-x2go-getportableappsessions   |  23 ++
 .../config/2510-x2go-getopensshportableclientkey   |  46 +++
 .../includes.chroot/lib/live/config/2600-tcpprint  |  76 ++++
 .../lib/live/config/2700-x2go-getsessions          |  49 +++
 .../lib/live/config/2800-x2go-powerbuttonmonitor   |  13 +
 .../lib/live/config/2900-x2go-thinclientconfig     | 162 ++++++++
 11 files changed, 971 insertions(+)

diff --git a/config/includes.chroot/lib/live/config/2100-showifconfig b/config/includes.chroot/lib/live/config/2100-showifconfig
new file mode 100755
index 0000000..9467e47
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2100-showifconfig
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+ShowIFConfig ()
+{
+
+# Output startup message
+#
+echo -n " showifconfig"
+
+# wait until terminal is available
+while ! [ -c /dev/tty$(fgconsole -n) ] ; do
+	sleep 10
+done
+
+# Make sure no language-specific stuff interferes with our matching
+# grep: highlight everything that matches "inet" to the end of its line
+# and also (-E, |$) show every line that has an end => Everything else
+cat >/etc/network/if-up.d/0100-showips <<SHOWIPS
+#!/bin/bash
+export TERM=linux;
+
+while [ -z "\$(hostname -I)" ] ; do
+	echo -en "\n\$(date +'%F | %T | ')'\$0' is waiting for a client IP." | tee -a /dev/tty\$(fgconsole -n)
+	sleep 2
+done
+
+IPMSG=\$(LANG=C \
+/sbin/ip a | \
+/bin/grep -P --color=always "inet.*? [\. 0-9a-f:/]*? |$" | \
+GREP_COLOR="1;32" \
+/bin/grep -P --color=always "link/ether .*? |$" ); \
+IPMSG=\$( sed 's/^/- /' <<< "\$IPMSG" ); 
+sed -i '/^- /d' /etc/issue; 
+sed -i '/^- /d' /etc/issue.net; 
+echo "\$IPMSG" >> /etc/issue; 
+echo "\$IPMSG" >> /etc/issue.net
+SHOWIPS
+
+chmod 755 /etc/network/if-up.d/0100-showips
+
+}
+
+ShowIFConfig
diff --git a/config/includes.chroot/lib/live/config/2200-lockuser b/config/includes.chroot/lib/live/config/2200-lockuser
new file mode 100755
index 0000000..1cbcc15
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2200-lockuser
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+LockUser ()
+{
+
+# Output startup message
+#
+echo -n " lockuser"
+
+
+# Set password
+#
+if grep -q "\W*nouser\W*" /proc/cmdline ; then
+	passwd -l user >/dev/null
+fi
+
+}
+
+LockUser
+
diff --git a/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver b/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver
new file mode 100755
index 0000000..21f0c31
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2250-getsshpubkeysfromserver
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+GetSSHPubKeysFromServer ()
+{
+
+	# Output startup message
+	#
+	echo -n " getsshpubkeysfromserver"
+
+
+	PUBKEYURL=$(cat /proc/cmdline | \
+		    tr ' ' '\n' | \
+		    awk -F'=' ' /^pubkey=/ { print $2 }')
+
+	if [ -n "$PUBKEYURL" ] ; then
+		cat >/etc/network/if-up.d/0200-getsshpubkeysfromserver <<GETPUBKEY
+#!/bin/bash
+export TERM=linux;
+
+while [ -z "\$(hostname -I)" ] ; do
+	echo -en "\n\$(date +'%F | %T | ')'\$0' is waiting for a client IP." | tee -a /dev/tty\$(fgconsole -n)
+	sleep 2
+done
+
+# Set Keyfile
+#
+mkdir -p /root/.ssh
+chmod 600 /root/.ssh
+touch /root/.ssh/authorized_keys
+chmod 600 /root/.ssh/authorized_keys
+
+if echo "$PUBKEYURL" | grep -q "^tftp://" ; then
+	PUBKEYSERVER=$(echo "$PUBKEYURL" | sed 's#^tftp://\([^/]*\)/.*$#\1#' )
+	PUBKEYPATH=$(echo "$PUBKEYURL" | sed 's#^tftp://[^/]*/\(.*\)$#\1#' )
+	if [ -n "\$PUBKEYSERVER" ] && [ -n "\$PUBKEYPATH" ] ; then
+		while ! atftp $PUBKEYSERVER -g -r $PUBKEYPATH -l /root/.ssh/authorized_keys ; do
+			echo "Waiting for SSH Public Key ..."
+			sleep 5
+		done
+	fi
+else
+	while ! wget -q -O - $PUBKEYURL >/root/.ssh/authorized_keys ; do
+		echo "Waiting for SSH Public Key ..."
+		sleep 5
+	done
+fi
+GETPUBKEY
+
+		chmod 755 /etc/network/if-up.d/0200-getsshpubkeysfromserver
+	fi
+
+}
+
+GetSSHPubKeysFromServer
+
diff --git a/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf b/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf
new file mode 100755
index 0000000..06794b1
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2300-xserver-xorg-getxorgconf
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+XServerXorgGetXorgConf ()
+{
+# Output startup message
+#
+echo -n " xserver-xorg-getxorgconf"
+
+        XORGCONFURL=$(cat /proc/cmdline | \
+                       tr ' ' '\n' | \
+                       awk -F'=' ' /^xorgconfurl=/ { print $2 }')
+        if [ -n "$XORGCONFURL" ] && [ -d /etc/X11 ] ; then 
+		XORGCONFDESTINATION=/etc/X11/xorg.conf.new
+	        cat >/etc/network/if-up.d/0300-getxorgconf <<GETXORG
+#!/bin/bash
+export TERM=linux;
+
+while [ -z "\$(hostname -I)" ] ; do
+	echo -en "\n\$(date +'%F | %T | ')'\$0' is waiting for a client IP." | tee -a /dev/tty\$(fgconsole -n)
+	sleep 2
+done
+if echo "$XORGCONFURL" | grep -q "^tftp://" ; then
+	XORGCONFSERVER=$(echo "$XORGCONFURL" | sed 's#^tftp://\([^/]*\)/.*$#\1#' )
+	XORGCONFPATH=$(echo "$XORGCONFURL" | sed 's#^tftp://[^/]*/\(.*\)$#\1#' )
+	if [ -n "\$XORGCONFSERVER" ] && [ -n "\$XORGCONFPATH" ] ; then
+		while ! atftp \$XORGCONFSERVER -g -r \$XORGCONFPATH -l $XORGCONFDESTINATION ; do
+			echo "Waiting for xorg.conf download ..."
+			sleep 5
+		done
+	fi
+else
+	while ! wget -q -O $XORGCONFDESTINATION $XORGCONFURL ; do
+		echo "Waiting for xorg.conf download ..."
+		sleep 5 
+	done
+fi
+
+if [ -s $XORGCONFDESTINATION ] ; then
+	mv $XORGCONFDESTINATION /etc/X11/xorg.conf
+fi
+GETXORG
+                chmod 755 /etc/network/if-up.d/0300-getxorgconf
+        fi
+}
+XServerXorgGetXorgConf
diff --git a/config/includes.chroot/lib/live/config/2400-live-autoupdate b/config/includes.chroot/lib/live/config/2400-live-autoupdate
new file mode 100755
index 0000000..7e88812
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2400-live-autoupdate
@@ -0,0 +1,439 @@
+#!/bin/sh
+
+cleanup () 
+{ # discard contents of tmpfs, umount if necessary
+	if [ -n "$NTFSROOT" ]; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Removing '$TEMPDIR/*'."
+		rm -rf $TEMPDIR/*
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Unmounting '$TEMPDIR'."
+		umount $TEMPDIR
+	fi
+	if rmdir $TEMPDIR; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Removed empty directory '$TEMPDIR'."
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Could not remove directory '$TEMPDIR'."
+	fi
+	if [ -n "$NTFSROOT" ]; then
+		if umount $MOUNTPOINT; then
+			echo -en "\n$(date +'%F | %T | ')'\$0': Unmounted '$MOUNTPOINT'."
+		else
+			echo -en "\n$(date +'%F | %T | ')'\$0': Could not unmount '$MOUNTPOINT'."
+		fi
+	fi
+}
+
+LiveAutoUpdateMain ()
+{
+# Output startup message
+#
+echo -n " live-autoupdater (backgrounding update task)"
+
+
+# Background everything
+#
+(
+
+# redirect all output to first available VT console
+#
+exec >/dev/tty$(fgconsole -n) 2>&1
+
+
+# clear console
+#
+clear
+
+
+# This is so grep, awk and sed will match the right terms regardless of LANG
+#
+unset LANG
+unset LC_ALL
+unset LC_MESSAGES
+
+
+# download url pointing to directory with all required files goes here
+DOWNLOADURL=$(cat /proc/cmdline | \
+               tr ' ' '\n' | \
+               awk -F'=' ' /^updateurl=/ { print $2 }')
+
+if [ -z "$DOWNLOADURL" ]; then
+	echo -en "\n$(date +'%F | %T | ')'\$0': No update URL. Exiting."
+	return 0
+fi
+
+# Bandwidth limit goes here
+#
+#BWLIMITPERCENT=20 # in percent, numeric-only
+BWLIMITPERCENT=$(cat /proc/cmdline | \
+                        tr ' ' '\n' | \
+                        awk -F'=' ' /^bwlimit=/ { print $2 }')
+if [ -z "$BWLIMITPERCENT" ]; then 
+	BWLIMITPERCENT=20
+	echo -en "\n$(date +'%F | %T | ')'\$0': Bandwidth limit not set. Defaulting to 20%."
+fi
+
+
+
+# sleeping a random amount of time to ease load on the update server
+#
+MAXSLEEPTIME=$(cat /proc/cmdline | \
+                        tr ' ' '\n' | \
+                        awk -F'=' ' /^updatesleep=/ && $2 ~ /^[0-9]*$/ { print $2 }')
+if [ -z "$MAXSLEEPTIME" ] || [ $MAXSLEEPTIME -lt 240 ] ; then
+	MAXSLEEPTIME=900
+fi
+SLEEPTIME=0
+echo -en "\n$(date +'%F | %T | ')'\$0': Calculating random update delay (120-$MAXSLEEPTIME seconds)..."
+# During startup, script is run with /bin/sh, 
+# even when #!/bin/bash is set,
+# so we need to improvise.
+RND=$(/bin/bash -c 'echo $RANDOM')
+SLEEPTIME=$((RND%MAXSLEEPTIME))
+if [ $SLEEPTIME -lt 120 ]; then
+	SLEEPTIME=$((SLEEPTIME+120))
+fi
+echo -en "\n$(date +'%F | %T | ')'\$0': Sleeping for $SLEEPTIME seconds ..."
+sleep $SLEEPTIME
+
+
+# Define our mountpoint and check if we're capable of auto-updating
+NTFSROOT=$(cat /proc/cmdline | tr ' ' '\n' | awk -F '=' '/^ntfs-uuid/ { print $2 }')
+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
+	# For example, "vol c:" on Windows will return the last 8 digits of the UUID
+        # only, and separate them with a dash.
+	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 | tr ' ' '\n' | head -1))
+		fi
+	fi
+
+	if mount -t ntfs-3g -rw /dev/disk/by-uuid/$NTFSROOT /lib/live/mount/ntfsroot ; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Mounted '/dev/disk/by-uuid/$NTFSROOT'."
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Unable to mount '/dev/disk/by-uuid/$NTFSROOT'."
+	fi
+	# TODO: Further error handling
+	MOUNTPOINT="/lib/live/mount/ntfsroot/"
+	# create a temporary directory
+	TEMPDIR=$(mktemp -d --tmpdir=$MOUNTPOINT)
+else
+	MOUNTPOINT="/lib/live/mount/findiso/"
+	# create a temporary directory and mount a tmpfs there
+	TEMPDIR=$(mktemp -d --tmpdir=/mnt)
+	
+	if [ -d /lib/live/mount/findiso/ ] ; then
+		# if we have access to the entire filesystem, use the
+		# directory size as base size for the current image - 
+		# and if the download directory is even bigger, use that size
+		IMGSIZE=$(du -s "/lib/live/mount/findiso/$(dirname $(sed -e 's/^.*findiso/findiso/' -e 's/ .*$//' /proc/cmdline | awk -F '=' '{ print $2 }'))")
+		IMGSIZEDOWNLOAD=$(du -s "/lib/live/mount/findiso/boot/X2Go-live-download")
+		[ $IMGSIZEDOWNLOAD -gt $IMGSIZE ] && IMGSIZE=$IMGSIZEDOWNLOAD
+	else
+		IMGSIZE=$(df /lib/live/mount/medium | awk ' /medium/ { print $2}')
+	fi
+	# multiply current size by 1.5 as safety margin
+	mount -t tmpfs -osize=$((IMGSIZE*15/10))k tmpfs $TEMPDIR
+
+fi
+if ! (	[ -d "$MOUNTPOINT/boot/X2Go-live-download" ] && \
+	( \
+		[ -d "$MOUNTPOINT/boot/X2Go-live1" ] || \
+		[ -d "$MOUNTPOINT/boot/X2Go-live2" ] \
+	) \
+     ); then
+	[ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+	echo -en "\n$(date +'%F | %T | ')'\$0': No directories suitable for update."
+	return 0 # directories missing, most likely not a writeable medium
+fi
+
+
+# define and figure out some paths that we will be needing later on
+#
+if [ -f "$MOUNTPOINT/syslinux.cfg" ]; then
+	SYSLINUXPATH="$MOUNTPOINT/"
+elif [ -f "$MOUNTPOINT/syslinux/syslinux.cfg" ]; then
+	SYSLINUXPATH="$MOUNTPOINT/syslinux/"
+elif [ -f "$MOUNTPOINT/menu.lst" ]; then
+	GRUBPATH="$MOUNTPOINT/"
+elif  [ -f "$MOUNTPOINT/boot/menu.lst" ]; then
+	GRUBPATH="$MOUNTPOINT/grub/"
+elif  [ -f "$MOUNTPOINT/boot/grub/menu.lst" ]; then
+	GRUBPATH="$MOUNTPOINT/boot/grub/"
+else
+	[ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+	echo -en "\n$(date +'%F | %T | ')'\$0': No suitable bootloader found."
+	return 1
+fi
+
+RUNNINGSYSTEMFULLPATH=$(dirname $(readlink -m "$MOUNTPOINT/$(cat /proc/cmdline | \
+                        tr ' ' '\n' | \
+                        awk -F'=' ' /^findiso=/ { print $2 }')"))
+
+ALLSYSTEMSROOT=$(dirname $RUNNINGSYSTEMFULLPATH)
+RUNNINGSYSTEMNAME=$(basename $RUNNINGSYSTEMFULLPATH)
+if [ "$RUNNINGSYSTEMNAME" = "X2Go-live1" ]; then
+	OTHERSYSTEMNAME="X2Go-live2"
+elif [ "$RUNNINGSYSTEMNAME" = "X2Go-live2" ]; then
+	OTHERSYSTEMNAME="X2Go-live1"
+else
+	[ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+	echo -en "\n$(date +'%F | %T | ')'\$0': Unable to determine path/name of running system."
+	return 1
+fi
+OTHERSYSTEMFULLPATH=$(readlink -m "$ALLSYSTEMSROOT/$OTHERSYSTEMNAME")
+DOWNLOADPATH=$(readlink -m "$ALLSYSTEMSROOT/X2Go-live-download/")
+
+
+# Now we'll copy the content of the X2Go-live-download folder to our tempdir
+# this is so we can run wget in update mode (-N) or rsync without needing
+# write access to our boot medium (write access means increased wear and tear,
+# and we want to avoid that especially for media that has no wear-leveling
+# like CF cards)
+#
+while ! rsync -aPv --inplace --modify-window=1 $DOWNLOADPATH/ $TEMPDIR; do
+	echo -en "\n$(date +'%F | %T | ')'\$0': Sleeping 30 seconds ..."
+	sleep 30
+	echo -en "\n$(date +'%F | %T | ')'\$0': Retrying ..."
+done
+
+
+# Now let's figure out if we're supposed to use wget or rsync for downloading
+#
+if echo "$DOWNLOADURL" | grep -q "^http" || \
+   echo "$DOWNLOADURL" | grep -q "^ftp"
+   then
+	# Attempt to determine available bandwidth & to set BWLIMIT accordingly
+	wget -Nr -o /tmp/dl.log -P /tmp/ -nd \
+		--progress=bar:force $DOWNLOADURL/x2go-tce-initrd.img 
+	cp --update "/tmp/x2go-tce-initrd.img" "$TEMPDIR"
+	rm "/tmp/x2go-tce-initrd.img"
+	SIZEFACTORSTRING=$(	awk -F' |\(|\)' ' $9 == "saved" && \
+				$7 == "-" { print $5 }' /tmp/dl.log | \
+				tail -1 \
+			   )
+	case $SIZEFACTORSTRING in
+		"" | \
+		[0-9]) 	echo -en "\n$(date +'%F | %T | ')'\$0': Not enough Bandwidth for update task - "
+			echo -n "aborting."
+			cleanup
+			return 0
+			;;
+                "KB/s") SIZEFACTOR=1;;
+                "MB/s") SIZEFACTOR=1024;;
+                "GB/s") SIZEFACTOR=1048576;;
+		*)     	SIZEFACTOR=$((1024*1024*1024));;
+	esac
+	DLRATE=$(	awk -F' |\(|\)' ' $9 == "saved" && $7 == "-" \
+			{ print $4 }' /tmp/dl.log | \
+			tail -1
+                 )
+	BWLIMIT=$(	echo "$DLRATE $SIZEFACTOR $BWLIMITPERCENT" | \
+			awk ' { print $1*$2*$3/100 }' | \
+			awk -F'.' '{ print $1 }' \
+		  ) # outputs integer kilobytes, not rounded
+	echo -en "\n$(date +'%F | %T | ')'\$0': Determined bandwidth limit: '$BWLIMIT KB/s'"
+	DOWNLOADCOMMAND="wget -Nr -l 1 -nd -P "$TEMPDIR" \
+			  --progress=bar:force \
+			  --limit-rate=${BWLIMIT}k $DOWNLOADURL"
+
+elif echo "$DOWNLOADURL" | grep -q "^rsync"; then
+
+	rsync -hh -aPv -W --inplace --log-file=/tmp/dl.log $DOWNLOADURL/x2go-tce-initrd.img \
+		$TEMPDIR/x2go-tce-initrd.img.new
+	mv $TEMPDIR/x2go-tce-initrd.img.new $TEMPDIR/x2go-tce-initrd.img
+	SIZEFACTORSTRING=$(	sed -e's_\(. bytes/sec\)_ \1_' /tmp/dl.log | \
+				awk '$4 == "sent" && $12 == "bytes/sec" \
+				{ print $11 }' \
+			   )
+	case $SIZEFACTORSTRING in
+		"" | \
+		[0-9]) 	echo -en "\n$(date +'%F | %T | ')'\$0': Not enough Bandwidth for update task - "
+			echo -n "aborting."
+			cleanup
+			return 0
+			;;
+		"K")   	SIZEFACTOR=1;;
+		"M")   	SIZEFACTOR=1024;;
+		"G")   	SIZEFACTOR=$((1024*1024));;
+		*)     	SIZEFACTOR=$((1024*1024*1024));;
+	esac
+	DLRATE=$(	sed -e's_\(. bytes/sec\)_ \1_' /tmp/dl.log | \
+			awk '$4 == "sent" && $12 == "bytes/sec" \
+			{ print $10 }')
+	BWLIMIT=$(	echo "$DLRATE $SIZEFACTOR $BWLIMITPERCENT" | \
+			awk ' { print $1*$2*$3/100 }' | \
+			awk -F'.' '{ print $1 }' \
+		  ) # outputs integer kilobytes, not rounded
+	echo -en "\n$(date +'%F | %T | ')'\$0': Determined bandwidth limit: '$BWLIMIT KB/s'"
+	DOWNLOADCOMMAND="rsync -aPv --inplace --bwlimit=$BWLIMIT $DOWNLOADURL/ \
+			  $TEMPDIR"
+else 
+	[ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+	echo -en "\n$(date +'%F | %T | ')'\$0': Unsupported download mechanism - aborting."
+	return 1
+fi
+rm /tmp/dl.log
+
+
+# Proceed to download from update location
+#
+while ! $DOWNLOADCOMMAND; do
+	echo -en "\n$(date +'%F | %T | ')'\$0': Sleeping 30 seconds ..."
+	sleep 30
+	echo -en "\n$(date +'%F | %T | ')'\$0': Retrying ..."
+done
+
+# Now check if these files are different from what we already have in our
+# download directory on the boot medium
+#
+echo -en "\n$(date +'%F | %T | ')'\$0': Diff'ing '$DOWNLOADPATH' '$TEMPDIR' ..."
+if diff -q $DOWNLOADPATH $TEMPDIR \
+	>/dev/null
+
+	then
+	cleanup
+	echo -en "\n$(date +'%F | %T | ')'\$0': Nothing to do. - Files on server not newer than '$DOWNLOADPATH'."
+	return 0 	# current is newest, nothing to do, we want to avoid
+			# unneccessary writes to the medium
+else
+	echo -en "\n$(date +'%F | %T | ')'\$0': Differences detected. Continuing ..."
+fi
+
+
+# If we made it past that point, it's time to update the boot medium, so let's
+# remount it rw and async for speed
+#
+if mount -oremount,rw,async $MOUNTPOINT; then
+	echo -en "\n$(date +'%F | %T | ')'\$0': Remounted '$MOUNTPOINT' as rw and async."
+else
+	echo -en "\n$(date +'%F | %T | ')'\$0': Could not remount '$MOUNTPOINT' as rw and async."
+fi
+
+
+# Now, we don't want to copy an index.htm(l) file, so let's do away with that
+#
+rm -f $TEMPDIR/index.ht*
+
+
+# move everything over to the boot medium
+#
+echo -en "\n$(date +'%F | %T | ')'\$0': Moving $TEMPDIR/* => $DOWNLOADPATH"
+mv $TEMPDIR/* $DOWNLOADPATH
+cleanup # FIXME ist dieses Cleanup gerechtfertigt oder macht es dummfoog?
+if [ -n "$NTFSROOT" ]; then
+	echo -en "\n$(date +'%F | %T | ')'\$0': NTFSROOT detected. Attempting to mount '/dev/disk/by-uuid/$NTFSROOT'."
+	if mount -t ntfs-3g -rw /dev/disk/by-uuid/$NTFSROOT /lib/live/mount/ntfsroot; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Mount successful."
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Failed to mount NTFSROOT."
+	fi
+fi
+
+
+# let's check if we just downloaded a copy of our running system
+#
+echo -en "\n$(date +'%F | %T | ')'\$0': Diff'ing '$DOWNLOADPATH' '$RUNNINGSYSTEMFULLPATH'"
+if diff -q $DOWNLOADPATH $RUNNINGSYSTEMFULLPATH >/dev/null && \
+	   [ -d "$OTHERSYSTEMFULLPATH" ] ; then
+	   [ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+	   echo -en "\n$(date +'%F | %T | ')'\$0': Nothing to do. Content of $DOWNLOADPATH equals" \
+		"$RUNNINGSYSTEMNAME."
+		return 0 # current is newest, nothing to do, 
+			 # we want to keep the old system in OTHERSYSTEMFULLPATH
+			 # as a fallback
+fi
+
+
+# make sure our destination path really exists
+#
+mkdir -p $OTHERSYSTEMFULLPATH
+
+
+# let's check if our destination is already up to date or needs updating
+#
+echo -en "\n$(date +'%F | %T | ')'\$0': Diff'ing '$DOWNLOADPATH' '$OTHERSYSTEMFULLPATH'"
+if diff -q $DOWNLOADPATH $OTHERSYSTEMFULLPATH >/dev/null; then
+		[ -n "$NTFSROOT" ] && umount $MOUNTPOINT
+		echo -en "\n$(date +'%F | %T | ')'\$0': Nothing to do - content of '$DOWNLOADPATH' equals"\
+		      "'$OTHERSYSTEMNAME'."
+		return 0 # OTHERSYSTEMFULLPATH is already up to date
+else
+	# keep rsyncing until the update is complete
+	echo -en "\n$(date +'%F | %T | ')'\$0': Copying $DOWNLOADPATH/ => $OTHERSYSTEMFULLPATH"
+	while ! rsync -aPv --inplace --modify-window=1 $DOWNLOADPATH/ $OTHERSYSTEMFULLPATH
+		do
+		echo -en "\n$(date +'%F | %T | ')'\$0': Sleeping 30 seconds ..."
+		sleep 30
+		echo -en "\n$(date +'%F | %T | ')'\$0': Retrying ..."
+	done
+fi
+
+
+# change default boot to the image we just downloaded and installed
+#
+if [ -n "$SYSLINUXPATH" ]; then
+	echo -en "\n$(date +'%F | %T | ')'\$0': Changing syslinux default to $OTHERSYSTEMNAME."
+	sed -i -e"/^default/cdefault $OTHERSYSTEMNAME" \
+		$SYSLINUXPATH/syslinux.cfg
+
+elif [ -n "$GRUBPATH" ]; then
+	MENULST=$GRUBPATH/menu.lst
+	CURRENTDEFAULT=$(awk '/^default/ { print $2 }' $MENULST | tr -d '\r')
+	CURRENTTITLEPOSITION=$(grep '^title' $MENULST | 
+                               grep -n "${RUNNINGSYSTEMNAME}" |
+                               awk -F':' '$2 ~ /'"${RUNNINGSYSTEMNAME}"'/ { print $1 }')
+	CURRENTTITLEPOSITION=$((CURRENTTITLEPOSITION-1))
+	OTHERTITLEPOSITION=$(grep '^title' $MENULST |
+                             grep -n "${OTHERSYSTEMNAME}" |
+                             awk -F':' '$2 ~ /'"${OTHERSYSTEMNAME}"'/ { print $1 }')
+	OTHERTITLEPOSITION=$((OTHERTITLEPOSITION-1))
+	if [ "$CURRENTTITLEPOSITION" = "$CURRENTDEFAULT" ]; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Changing GRUB-legacy default to $OTHERTITLEPOSITION ..."
+		sed -i -e"/^default/cdefault $OTHERTITLEPOSITION" \
+			$MENULST
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Not changing GRUB-legacy default."
+		echo -en "\n$(date +'%F | %T | ')'\$0': Reason: We're at boot position '$CURRENTTITLEPOSITION',"
+		echo -en "\n$(date +'%F | %T | ')'\$0': while default is set to position '$CURRENTDEFAULT'."
+	fi
+else
+	echo -en "\n$(date +'%F | %T | ')'\$0': Unsupported bootloader."
+fi
+
+# we're on an async mount point, so let's sync to be safe
+#
+sync
+
+
+# umount tempdir to free memory
+#
+if [ -d $TEMPDIR ]; then
+	cleanup
+fi
+
+
+# now, change mount back to ro and sync
+#
+if [ -n "$NTFSROOT" ]; then
+	if umount $MOUNTPOINT; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Unmounted '$MOUNTPOINT'."
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Unable to unmount '$MOUNTPOINT'."
+	fi
+else	
+	if mount -oremount,ro,sync $MOUNTPOINT; then
+		echo -en "\n$(date +'%F | %T | ')'\$0': Remounted '$MOUNTPOINT' ro and sync."
+	else
+		echo -en "\n$(date +'%F | %T | ')'\$0': Unable to remount '$MOUNTPOINT' ro and sync."
+	fi
+fi
+
+) &
+
+}
+
+LiveAutoUpdateMain
+
diff --git a/config/includes.chroot/lib/live/config/2500-x2go-getportableappsessions b/config/includes.chroot/lib/live/config/2500-x2go-getportableappsessions
new file mode 100755
index 0000000..4e417db
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2500-x2go-getportableappsessions
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+X2GoGetPortableAppSessions ()
+{
+
+# Output startup message
+#
+echo -n " x2go-getportableappsessions"
+
+# This script is for using the iso-hybrid image along with the "second partition" patch
+# it allows you to share a configuration between X2GoClient for Windows in portable
+# mode and the X2Go-ThinClientEnvironment on the same USB media using different partitions
+
+if [ -L /dev/disk/by-label/PORTABLEAPP ]; then 
+	mkdir -p /media/PORTABLEAPP && \
+	mount -o sync /dev/disk/by-label/PORTABLEAPP /media/PORTABLEAPP && \
+	ln -sf /media/PORTABLEAPP/x2goclient/sessions /etc/x2go/x2gothinclient_sessions
+else
+	true
+fi
+}
+
+X2GoGetPortableAppSessions
diff --git a/config/includes.chroot/lib/live/config/2510-x2go-getopensshportableclientkey b/config/includes.chroot/lib/live/config/2510-x2go-getopensshportableclientkey
new file mode 100755
index 0000000..1f7b486
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2510-x2go-getopensshportableclientkey
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+
+X2GoGetOpenSSHPortableClientKey ()
+{
+	# Output startup message
+	#
+	echo -n " x2go-getopensshportableclientkey"
+
+	# This script is for using the iso-hybrid image along with the "second partition" patch
+	# it allows you to share ssh secret keys between X2GoClient for Windows in portable
+	# mode and the X2Go-ThinClientEnvironment on the same USB media using different partitions
+
+	# Homedir of client side X2Go ThinClient Account
+	#
+	X2GOHOME="/home/user/"
+
+	# Homedir of Portable App Installation
+	#
+	HOME="/media/PORTABLEAPP/"
+
+	if [ -d "$HOME" ] && [ -d "$X2GOHOME" ]; then
+
+		# create .ssh-Directory in case it doesn't exist
+		#
+		mkdir -p $(readlink -m "$X2GOHOME/.ssh/")
+
+		for KEYFILE in $HOME/ssh/* ; do
+			[ -s "$KEYFILE" ] || continue
+			KEYDESTPATH="$X2GOHOME/.ssh/$(basename "$KEYFILE")"
+			touch "$KEYDESTPATH"
+			chown   user:user \
+				$KEYDESTPATH
+			chmod   600 $KEYDESTPATH
+			cat     $(readlink -m "$KEYFILE")>$KEYDESTPATH
+
+		done
+
+		# this is so the path name in the sessions file matches again
+		# (cannot use .ssh on FAT, for example)
+		ln -s $X2GOHOME/.ssh $X2GOHOME/ssh
+	fi
+}
+
+X2GoGetOpenSSHPortableClientKey
+
diff --git a/config/includes.chroot/lib/live/config/2600-tcpprint b/config/includes.chroot/lib/live/config/2600-tcpprint
new file mode 100755
index 0000000..2bb453b
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2600-tcpprint
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+TcpPrint ()
+{
+
+# Output startup message
+#
+echo -n " tcpprint"
+
+if grep -q "\W*tcpprint\W*" /proc/cmdline ; then
+        TCPPRINTONLYFROM=$(cat /proc/cmdline | \
+                       tr ' ' '\n' | \
+                       awk -F'=' ' /^tcpprintonlyfrom=/ { print $2 }')
+	if [ -n "$TCPPRINTONLYFROM" ] ; then
+		TCPPRINTONLYFROM="only_from = $TCPPRINTONLYFROM"
+	fi
+	# Backgrounding
+	(
+
+	while ! lsmod | grep -q "^lp"; do
+		# Wait till modprobe lp has occurred
+		# -> this means /dev is fully populated
+		# => USB-Printers can be detected now, too
+		sleep 30
+	done
+
+	PRINTERDEVICES=""
+	[ -d /dev/usb ] && PRINTERDEVICES=$(find /dev/usb -type c -name "lp*" | sort)
+	PRINTERDEVICES="$PRINTERDEVICES $(find /dev/ -maxdepth 1 -type c -name "lp*" | sort)"
+
+	echo -en "\n\$(date +'%F | %T | ')'\$0' is waiting for a client IP." | tee -a /dev/tty\$(fgconsole -n)
+
+	# Create a listening port for a TCP/9100-RAW-printer
+	#
+	# printers may be at /dev/lp_ and at /dev/usb/lp_
+	PRINTERCOUNT=0
+	for PRINTERDEV in $PRINTERDEVICES; do 
+		PORTNUMBER=$((PRINTERCOUNT+9100))
+		echo "jetdirect${PRINTERCOUNT} ${PORTNUMBER}/tcp" >>/etc/services
+		cat >/etc/xinetd.d/jetdirect${PRINTERCOUNT} << JETDIRCONF 
+service jetdirect${PRINTERCOUNT}
+{
+	socket_type = stream
+	protocol = tcp
+	wait = no
+	user = root
+	server = /bin/dd
+	server_args = of=$PRINTERDEV bs=1024k
+	groups = yes
+	disable = no
+	instances = 1
+	$TCPPRINTONLYFROM
+}
+JETDIRCONF
+		echo -en "\n\$(date +'%F | %T | ')Mapping $PRINTERDEV => $PORTNUMBER" | tee -a /dev/tty\$(fgconsole -n)
+		PRINTERCOUNT=$((PRINTERCOUNT+1))
+	done
+
+	echo "#Local printer config: Done." >/etc/xinetd.d/jetdirect
+
+	if ps -C xinetd --no-header >/dev/null ; then
+		echo -en "\n\$(date +'%F | %T | ')xinetd needs to be restarted, trying to do that ..." | tee -a /dev/tty\$(fgconsole -n)
+		if /etc/init.d/xinetd restart; then
+			echo -n " success. All done." | tee -a /dev/tty\$(fgconsole -n)
+		else
+			echo -n " error." | tee -a /dev/tty\$(fgconsole -n)
+		fi
+	else
+		echo -en "\n\$(date +'%F | %T | ')No xinetd restart necessary. All done." | tee -a /dev/tty\$(fgconsole -n)
+	fi
+
+	) &
+fi
+}
+
+TcpPrint
diff --git a/config/includes.chroot/lib/live/config/2700-x2go-getsessions b/config/includes.chroot/lib/live/config/2700-x2go-getsessions
new file mode 100755
index 0000000..eff3073
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2700-x2go-getsessions
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+X2GoGetSessions ()
+{
+	# Output startup message
+	#
+	echo -n " x2go-getsessions"
+
+	SESSIONSURL=$(cat /proc/cmdline | \
+		       tr ' ' '\n' | \
+		       awk -F'=' ' /^sessionsurl=/ { print $2 }')
+	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
+        	mv /etc/x2go/x2gothinclient_sessions /etc/x2go/x2gothinclient_sessions_old
+		SESSIONSDESTINATION=/etc/x2go/x2gothinclient_sessions_new
+		cat >/etc/network/if-up.d/0400-getsessions <<GETSESS
+#!/bin/bash
+export TERM=linux;
+
+while [ -z "\$(hostname -I)" ] ; do
+	echo -en "\n\$(date +'%F | %T | ')'\$0' is waiting for a client IP." | tee -a /dev/tty\$(fgconsole -n)
+	sleep 2
+done
+if echo "$SESSIONSURL" | grep -q "^tftp://" ; then
+	SESSIONSSERVER=$(echo "$SESSIONSURL" | sed 's#^tftp://\([^/]*\)/.*$#\1#' )
+	SESSIONSPATH=$(echo "$SESSIONSURL" | sed 's#^tftp://[^/]*/\(.*\)$#\1#' )
+	if [ -n "\$SESSIONSSERVER" ] && [ -n "\$SESSIONSPATH" ] ; then
+		while ! atftp \$SESSIONSSERVER -g -r \$SESSIONSPATH -l $SESSIONSDESTINATION ; do
+			echo -en "\n\$(date +'%F | %T | ')Waiting for session config data ..." | tee -a /dev/tty\$(fgconsole -n)
+			sleep 5
+		done
+	fi
+else
+	while ! wget -q -O $SESSIONSDESTINATION $SESSIONSURL ; do
+		echo -en "\n\$(date +'%F | %T | ')Waiting for session config data ..." | tee -a /dev/tty\$(fgconsole -n)
+		sleep 5 
+	done
+fi
+
+if [ -s $SESSIONSDESTINATION ] ; then
+	mv $SESSIONSDESTINATION /etc/x2go/x2gothinclient_sessions
+fi
+GETSESS
+		chmod 755 /etc/network/if-up.d/0400-getsessions
+	fi
+}
+
+X2GoGetSessions
diff --git a/config/includes.chroot/lib/live/config/2800-x2go-powerbuttonmonitor b/config/includes.chroot/lib/live/config/2800-x2go-powerbuttonmonitor
new file mode 100755
index 0000000..8f21eaf
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2800-x2go-powerbuttonmonitor
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+X2GoPowerbuttonMonitor ()
+{
+# Output startup message
+#
+echo -n " x2go-powerbuttonmonitor"
+
+# Spawn Powerbutton-Monitor
+/bin/bash -c '(while ! [ -f /home/user/.halt ] ; do sleep 1 ; done ; poweroff ; chvt 7) &'
+}
+
+X2GoPowerbuttonMonitor
diff --git a/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
new file mode 100755
index 0000000..87fbae9
--- /dev/null
+++ b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
@@ -0,0 +1,162 @@
+#!/bin/bash
+
+X2GoThinClientConfig ()
+{
+
+# Output startup message
+#
+echo -n " x2go-thinclientconfig"
+
+# using xmlstarlet would mean wasting yet another Megabyte of space ...
+# disable virtual desktops
+sed -i -e 's#<number>4</number>#<number>1</number>#' /etc/xdg/openbox/rc.xml
+# disable OpenBox keyboard bindings
+# this also disables the context menu (would be accessible in xinerama) and things like Alt-F4 for X2GoClient, Xephyr, etc.
+sed -i -e '/<keyboard>/,/<\/keyboard>/{//!d}' /etc/xdg/openbox/rc.xml
+# make sure OpenBox maximizes X2GoClient on launch and hides window decorations
+sed -i -e '\#<applications>#a<application title="X2Go Client" type="normal">' -e '\#<applications>#a<decor>no</decor>' -e '\#<applications>#a</application>' /etc/xdg/openbox/rc.xml
+
+cat >/home/user/.xsession <<XSESSION
+# inspired by 
+# http://code.x2go.org/gitweb?p=x2gothinclient.git;a=blob_plain;f=displaymanager/sbin/x2gothinclientd;h=6897d42d17bd6778e7de5e62ec3f51727d4e8800;hb=HEAD
+# check the above file for ideas before reinventing the wheel
+
+# Spawn PulseAudio
+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 | tr ' ' '\n' | awk -F '=' '\$1 == "xinerama" { print \$2 }')
+
+# sanitize input
+case \$XRANDRCMDTAINTED in
+"above")
+	XRANDRCMD="above"
+	;;
+"below")
+	XRANDRCMD="below"
+	;;
+"same-as")
+	XRANDRCMD="same-as"
+	;;
+"right-of")
+	XRANDRCMD="right-of"
+	;;
+*)
+	XRANDRCMD="left-of" # default
+	;;
+esac
+
+# find out how many touch devices we have
+TOUCHDEVICESCOUNT=\$(LANG=C xsetwacom --list devices | wc -l)
+
+# find out how many mouse devices we have
+MICECOUNT=\$(find /dev/input -maxdepth 1 -name "mouse*" | wc -l)
+
+# loop through the following code block for all connected display devices
+for NEXT_DISPLAY in \$(LANG=C xrandr 2>/dev/null | grep ' connected ' | cut -d ' ' -f1); do
+
+	#remove trailing newline from NEXT_DISPLAY
+	NEXT_DISPLAY=\${NEXT_DISPLAY%\$'\n'}
+
+	# THIS_DISPLAY won't be defined until the second time the loop is executed, which is a
+	# neat way of running xrandr only if there are at least two connected display devices
+	if [ -n "\${THIS_DISPLAY+x}" ] ; then
+
+		if [ \$TOUCHDEVICESCOUNT -gt 0 ] &&  [ \$MICECOUNT -lt 1 ] && [ -z \$XRANDRCMDTAINTED ]; then
+			# we have a touch device and no mice, and no xinerama parameter was set,
+			# so switch to clone view to make the touch device usable
+			/usr/bin/xrandr --output \$NEXT_DISPLAY --same-as \$THIS_DISPLAY
+
+		else
+			# else use whatever is in XRANDRCMD (which is either our default of "left-of",
+			# or a valid xinerama kernel parameter value)
+			/usr/bin/xrandr --output \$NEXT_DISPLAY --\$XRANDRCMD \$THIS_DISPLAY
+		fi
+
+		# now set THIS_DISPLAY -> every subsequent iteration of the loop will now enter the code block
+		# above where [ -n \${THIS_DISPLAY+x} ] is the conditional
+		THIS_DISPLAY=\$NEXT_DISPLAY
+	fi
+done
+
+# Spawn openbox
+openbox &
+
+# set screen background to X2Go default blue on all detected screens
+xsetroot -solid "#246ed8"
+
+# Get X2GoConfig
+BROKERURL=\$(cat /proc/cmdline | \
+	    tr ' ' '\n' | \
+	    awk -F'=' ' /^broker-url=/ { print \$2 }')
+LDAP=\$(cat /proc/cmdline | \
+	    tr ' ' '\n' | \
+	    sed 's/^ldap=/ldap#/' | \
+	    awk -F'#' ' /^ldap#/ { print \$2 }')
+LDAP1=\$(cat /proc/cmdline | \
+	    tr ' ' '\n' | \
+	    sed 's/^ldap1=/ldap1#/' | \
+	    awk -F'#' ' /^ldap1#/ { print \$2 }')
+LDAP2=\$(cat /proc/cmdline | \
+	    tr ' ' '\n' | \
+	    sed 's/^ldap2=/ldap2#/' | \
+	    awk -F'#' ' /^ldap2#/ { print \$2 }')
+
+# Spawn X2GoClient
+if [ -n "\$BROKERURL" ]; then
+	SESSIONFROM="--broker-url=\$BROKERURL"
+else 
+	SESSIONFROM="--session-conf=/etc/x2go/x2gothinclient_sessions"
+	while ! [ -s /etc/x2go/x2gothinclient_sessions ]; do
+		OLDCON=$(fgconsole)
+		chvt 1
+	        echo "'$0' is waiting for a valid '/etc/x2go/x2gothinclient_sessions' file."
+		sleep 2
+	done
+	[ -n "$OLDCON" ] && chvt $OLDCON
+fi
+if [ -n "\$LDAP" ] ; then
+	if [ -n "\$LDAP1" ] ; then
+		BACKUPLDAP="--ldap1=\$LDAP1"
+		if [ -n "\$LDAP2" ] ; then
+			BACKUPLDAP="\$BACKUPLDAP --ldap2=\$LDAP2"
+		fi
+	fi
+	LDAPPARAMS="--ldap=\$LDAP \$BACKUPLDAP"
+else
+	LDAPPARAMS=""
+fi
+
+BLANKINGTIME=\$(cat /proc/cmdline | tr ' ' '\n' | awk -F '=' '\$1 == "blank" { print \$2 }')
+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
+		# Disable screensaver and DPMS Power Saving if requested
+		xset s off
+		if ! grep -q '\W*nodpms\W*' /proc/cmdline; then
+			xset -dpms
+		fi
+	else
+		xset s on
+		xset s \${DPMSARR[0]}
+		if ! grep -q '\W*nodpms\W*' /proc/cmdline; then
+			# Yes, "+dpms dpms" is intentional. 
+			xset +dpms dpms \${DPMSARR[0]} \${DPMSARR[1]} \${DPMSARR[2]}
+		fi
+	fi
+fi
+
+x2goclient --thinclient --no-session-edit --no-menu --maximize --add-to-known-hosts --haltbt --read-exports-from=/home/user/export \$LDAPPARAMS \$SESSIONFROM
+XSESSION
+
+chown user:user /home/user/.xsession
+chmod 644 /home/user/.xsession
+
+# This is needed for File Sharing support (USB media and the like)
+mkdir -p /home/user/{export,logins,mounts}
+chown user:user /home/user/{export,logins,mounts}
+chmod 700 /home/user/{export,logins,mounts}
+
+}
+
+X2GoThinClientConfig

--
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