[X2Go-Commits] [live-build-x2go] 26/108: adapted 2280-x2go-getportableappsessions to work more like 2270-getsshclientkeysfrommedia
git-admin at x2go.org
git-admin at x2go.org
Wed Mar 20 22:13:09 CET 2019
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 32e735a85801112856c7834c8ebabf91886a8063
Author: Stefan Baur (BAUR-ITCS) <kontakt at baur-itcs.de>
Date: Thu Feb 8 00:56:16 2018 +0100
adapted 2280-x2go-getportableappsessions to work more like 2270-getsshclientkeysfrommedia
---
.../live/config/2280-x2go-getportableappsessions | 123 +++++++++++++++++----
1 file changed, 102 insertions(+), 21 deletions(-)
diff --git a/config/includes.chroot/lib/live/config/2280-x2go-getportableappsessions b/config/includes.chroot/lib/live/config/2280-x2go-getportableappsessions
index be9c641..873345b 100755
--- a/config/includes.chroot/lib/live/config/2280-x2go-getportableappsessions
+++ b/config/includes.chroot/lib/live/config/2280-x2go-getportableappsessions
@@ -3,26 +3,107 @@
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
- if [ -s /media/PORTABLEAPP/x2goclient/sessions ] ; then
- ln -sf /media/PORTABLEAPP/x2goclient/sessions /etc/x2go/x2gothinclient_sessions
- elif [ -s /media/PORTABLEAPP/x2goclient/.x2goclient/sessions ] ; then
- ln -sf /media/PORTABLEAPP/x2goclient/.x2goclient/sessions /etc/x2go/x2gothinclient_sessions
- else
- true
- fi
-else
- true
-fi
+ # 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
+
+ check_for_config (){
+ if [ -s /media/PORTABLEAPP/x2goclient/sessions ] ; then
+ ln -sf /media/PORTABLEAPP/x2goclient/sessions /etc/x2go/x2gothinclient_sessions
+ elif [ -s /media/PORTABLEAPP/x2goclient/.x2goclient/sessions ] ; then
+ ln -sf /media/PORTABLEAPP/x2goclient/.x2goclient/sessions /etc/x2go/x2gothinclient_sessions
+ else
+ true
+ fi
+
+ }
+
+ while ! [ -c /dev/tty8 ] ; do
+ echo -n "\n$(date +'%F | %T | ')'$0' is waiting for tty8 to become available."
+ sleep 2
+ done
+
+ # always wait for getsshhostkeysfrommedia (config/opensshkeys)
+ while ! [ -e /var/lib/live/config/opensshkeys ] ; do
+ echo -n "\n$(date +'%F | %T | ')'$0' is waiting for getsshhostkeysfrommedia to finish."
+ sleep 2
+ done
+
+ # if copysecring is set, also wait for getsshclientkeysfrommedia (config/opensshclientkeys)
+ if grep -q "\W*copysecring\W*" /proc/cmdline ; then
+ while ! [ -e /var/lib/live/config/opensshclientkeys ] ; do
+ echo -n "\n$(date +'%F | %T | ')'$0' is waiting for getsshclientkeysfrommedia to finish."
+ sleep 2
+ done
+
+ fi
+
+ # list devices (and mountpoints, if present)
+ LABELMPLIST=$(lsblk -oLABEL,NAME,MOUNTPOINT,HOTPLUG -ln)
+
+ # search for our magic label
+ X2GOTCELIVELABELS=$(echo "$LABELMPLIST" | awk '$3~/^[^\/]/ && $3="" ; $1=="X2GO-TCE-LIVE" { print $2 " " $3 " " $4}')
+
+ # support for second label value (for dual-mode media where keys are stored on the windows-readable partition)
+ PORTABLEAPPLABELS=$(echo "$LABELMPLIST" | awk '$3~/^[^\/]/ && $3="" ; $1=="PORTABLEAPP" { print $2 " " $3 " " $4}')
+
+ # block device list, removable first (we want USB media to be able to override keys on fixed disks)
+ BLOCKDEVS="$(echo "$X2GOTCELIVELABELS\n$PORTABLEAPPLABELS" | awk '$3 == "1" {print $2}') $(echo "$X2GOTCELIVELABELS\n$PORTABLEAPPLABELS" | awk '$3 == "0" {print $2}')"
+
+ # for every block device in our list, do ...
+ for BLOCKDEV in $BLOCKDEVS; do
+ # check if it also appears in the list of devices carrying our magic label
+ # this should always be the case since we changed how BLOCKDEVS is assembled
+ NEXTDEVICE=$(echo "$X2GOTCELIVELABELS\n$PORTABLEAPPLABELS" | grep "$BLOCKDEV")
+ if [ -n "$NEXTDEVICE" ] ; then
+ # now figure out the mountpoint
+ MNTPT=$(echo $NEXTDEVICE | awk '{print $2}')
+ # and the device name? Wait, this is the magic label instead.
+ NEXTDEVICE=$(echo $NEXTDEVICE | awk '{print $1}')
+ echo -n "\n$(date +'%F | %T | ')'$0' Checking status of Device '$NEXTDEVICE' for BLOCKDEV '$BLOCKDEV'." | tee -a /dev/tty8
+ if [ -n "$MNTPT" ] ; then
+ # If the mountpoint variable isn't empty, it means the device is already mounted.
+ echo -n "\n$(date +'%F | %T | ')'$0' Device '$NEXTDEVICE' is mounted at: '$MNTPT'" | tee -a /dev/tty8
+ # so let's check if we have a config directory at that mountpoint.
+ if check_for_config $MNTPT ; then
+ # if we managed to pull a config off of it (or save one on it), we make a note of this ...
+ touch /var/lib/live/config/opensshclientkeys
+ # and quit right here.
+ exit 0
+ fi
+ else
+ # So there's no active mount for the device with our magic label ...
+ echo -n "\n$(date +'%F | %T | ')'$0' Device '$NEXTDEVICE' is not mounted." | tee -a /dev/tty8
+ # let's see if this is a fixed disk.
+ if grep -q "^0$" /sys/block/$BLOCKDEV/removable ; then
+ # yes, it is, so let's go ahead and try to mount it ...
+ echo -n "\n$(date +'%F | %T | ')'$0' Device '$NEXTDEVICE' is a fixed disk, mounting ..." | tee -a /dev/tty8
+ # obviously, we need a mountpoint for it ...
+ mkdir -p /media/fixeddisks/$NEXTDEVICE
+ # and now we can try to mount it. Let's do it in readonly mode, just to play it safe.
+ mount -o ro /dev/$NEXTDEVICE /media/fixeddisks/$NEXTDEVICE
+ if check_for_config /media/fixeddisks/$NEXTDEVICE ; then
+ # we umount, then make a note that we succeeded ...
+ umount /media/fixeddisks/$NEXTDEVICE
+ touch /var/lib/live/config/opensshclientkeys
+ # and quit right here.
+ exit 0
+ fi
+ # If we didn't succeed in pulling a config, we still need to umount what we mounted.
+ umount /media/fixeddisks/$NEXTDEVICE
+ else
+ # If a removable disk hasn't been mounted by the automounter, something's amiss and we shouldn't try to meddle with it.
+ # So let's make a note of this and move on.
+ echo -n "\n$(date +'%F | %T | ')'$0' Device '$NEXTDEVICE' is a removable disk, not mounted by automounter, skipping." | tee -a /dev/tty8
+ fi
+ fi
+ fi
+ done
+ ) &
}
X2GoGetPortableAppSessions
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/live-build-x2go.git
More information about the x2go-commits
mailing list