Subject: Allow x2gothinclientcreate to run non-interactive
From: Arnold Krille <[email-masked]>
To: [email-masked]
Cc: Arnold Krille <[email-masked]>
Date: Thu, 5 Sep 2013 10:50:18 +0200

Package: x2gothinclient

When you want to set up your X2Go-TCE via a script (like chef or puppet), the
installer shouldn't ask questions on the command-line. So deactivate waiting
for confirmation and make apt-get use the defaults for configuring instead of
asking.
---
 .../sbin/x2gothinclient_create                     |   24 +++++++++++++++-----
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/x2gothinclientmanagement/sbin/x2gothinclient_create b/x2gothinclientmanagement/sbin/x2gothinclient_create
index 0e6037c..aae0124 100755
--- a/x2gothinclientmanagement/sbin/x2gothinclient_create
+++ b/x2gothinclientmanagement/sbin/x2gothinclient_create
@@ -43,6 +43,8 @@ TC_DEBMIRROR_URL="${TC_DEBMIRROR_URL:-'http://ftp.debian.org/debian'}"
 TC_X2GO_DEBURL="${TC_X2GO_DEBURL:-'deb http://packages.x2go.org $TC_DISTRO_CODENAME main'}"
 TC_MODULE_BLACKLIST="${TC_MODULE_BLACKLIST:-'pcspkr'}"
 
+TC_NONINTERACTIVE="${TC_NONINTERACTIVE:-}"
+
 test -e "$TC_CHROOT" && { 
 	echo "ERROR: X2Go Thin Client chroot already exists at $TC_CHROOT."
 	echo "Clear $TC_BASE/ and then run $(basename $0) again..."
@@ -54,11 +56,15 @@ test -e "$TC_CHROOT" && {
 	exit -2
 }
 
-echo "Hit <RETURN> to continue with X2Go TCE chroot creation using"
-echo "the above TCE parameters..."
-echo
-echo "Alternatively, hit STRG-C to cancel the operation now!!!"
-read
+if [ "x${TC_NONINTERACTIVE}" = "x" ]; then
+    echo "Hit <RETURN> to continue with X2Go TCE chroot creation using"
+    echo "the above TCE parameters..."
+    echo
+    echo "Alternatively, hit STRG-C to cancel the operation now!!!"
+    read
+else
+    echo "Non-interactive mode selected, will continue with the above settings"
+fi
 
 export LANG=C
 
@@ -124,6 +130,10 @@ export http_proxy=$TC_HTTP_PROXY
 export https_proxy=$TC_HTTPS_PROXY
 export ftp_proxy=$TC_FTP_PROXY
 
+if [ "x${TC_NONINTERACTIVE}" != "x" ]; then
+    export DEBIAN_FRONTEND=noninteractive
+fi
+
 mkdir -p /tmp/user/0
 mkdir -p /var/lib/xkb
 mkdir -p /var/lib/nfs
@@ -156,7 +166,9 @@ export X2GO_HANDLE_DAEMONS=false
 [ \$? -eq 0 ] && apt-get update
 [ \$? -eq 0 ] && apt-get install $TC_SHELL -y
 [ \$? -eq 0 ] && apt-get install syslinux locales -y
-[ \$? -eq 0 ] && dpkg-reconfigure locales
+if [ \$? -eq 0 -a "x${TC_NONINTERACTIVE}" != "x" ]; then
+    dpkg-reconfigure locales
+fi
 [ \$? -eq 0 ] && apt-get install linux-image-486 -y
 [ \$? -eq 0 ] && test -h /vmlinuz && mv /vmlinuz /vmlinuz.486.tmp || true
 [ \$? -eq 0 ] && LINK_TARGET=\$(readlink /vmlinuz.486.tmp | sed 's@/boot@boot@') && ln -sf \$LINK_TARGET /vmlinuz.486 && rm -f /vmlinuz.486.tmp
-- 
1.7.9.5