[X2Go-Commits] [x2goserver] 01/17: debian/x2goserver-desktopsharing.postinst: more curly braces, quotes etc.

git-admin at x2go.org git-admin at x2go.org
Fri Nov 16 03:47:03 CET 2018


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

x2go pushed a commit to branch master
in repository x2goserver.

commit c706cef34d81f05833f5522aedf533b2435fda06
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri Nov 16 02:55:11 2018 +0100

    debian/x2goserver-desktopsharing.postinst: more curly braces, quotes etc.
---
 debian/changelog                          |   2 +
 debian/x2goserver-desktopsharing.postinst | 115 ++++++++++++++----------------
 2 files changed, 57 insertions(+), 60 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1845523..789b031 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -55,6 +55,8 @@ x2goserver (4.1.0.3-0x2go1) UNRELEASED; urgency=medium
     + Pull in openSUSE-release manually on OpenSuSE Tumbleweed to work around
       a bug.
     + Also pass %{__global_{c{,pp},ld}flags} down via {C,LD}FLAGS.
+  * debian/x2goserver-desktopsharing.postinst:
+    + More curly braces, quotes etc.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Tue, 14 Aug 2018 16:41:40 +0200
 
diff --git a/debian/x2goserver-desktopsharing.postinst b/debian/x2goserver-desktopsharing.postinst
index 94a4e89..3ece3d4 100755
--- a/debian/x2goserver-desktopsharing.postinst
+++ b/debian/x2goserver-desktopsharing.postinst
@@ -1,11 +1,9 @@
 #!/bin/sh
-
-set -e
-
 # postinst script for x2godesktopsharing
 #
 # see: dh_installdeb(1)
 
+set -e
 
 # summary of how this script can be called:
 #        * <postinst> `configure' <most-recently-configured-version>
@@ -20,74 +18,71 @@ set -e
 # the debian-policy package
 
 # Source debconf library.
-. /usr/share/debconf/confmodule
-
-case "$1" in
-	configure)
-
-	# fetch debconf-variables for x2godesktopsharing
-	db_get x2goserver-desktopsharing/create-group-for-sharing && x2godesktopsharing_create_group_for_sharing=$RET
-	db_get x2goserver-desktopsharing/use-existing-group-for-sharing && x2godesktopsharing_use_existing_group_for_sharing=$RET
+. '/usr/share/debconf/confmodule'
 
-	# create debconf-configured sharing group
+case "${1}" in
+	'configure')
+		# fetch debconf-variables for x2godesktopsharing
+		db_get 'x2goserver-desktopsharing/create-group-for-sharing' && x2godesktopsharing_create_group_for_sharing="${RET}"
+		db_get 'x2goserver-desktopsharing/use-existing-group-for-sharing' && x2godesktopsharing_use_existing_group_for_sharing="${RET}"
 
-	group=""
-	if [ "$x2godesktopsharing_create_group_for_sharing" = "true" ] || [ "$x2godesktopsharing_use_existing_group_for_sharing" = "true" ]; then
-		db_get x2goserver-desktopsharing/group-sharing
-		# for sanity: we take everything as a group name until we find a blank...
-		group=$(echo $RET | cut -d" " -f1)
-	fi
+		# create debconf-configured sharing group
 
-	if [ "$x2godesktopsharing_create_group_for_sharing" = "true" ] && [ "x$group" != "x" ]; then
-		# this should create the hard-coded "x2godesktopsharing" group
-		if ! getent group $group >/dev/null; then
-			echo "Creating $group group." 1>&2
-			addgroup --system $group
-		else
-			echo "Group »$group« already exists." 1>&2
+		group=''
+		if [ "${x2godesktopsharing_create_group_for_sharing}" = 'true' ] || [ "${x2godesktopsharing_use_existing_group_for_sharing}" = 'true' ]; then
+			db_get 'x2goserver-desktopsharing/group-sharing'
+			# for sanity: we take everything as a group name until we find a blank...
+			group="$(echo "${RET}" | cut -d ' ' -f '1')"
 		fi
-	fi
 
-	if [ "$x2godesktopsharing_use_existing_group_for_sharing" = "true" ] && [ "x$group" != "x" ]; then
-		if echo "$group" | egrep '^[[:digit:]]{1,5}$' 1>/dev/null; then
-			echo "Specified sharing group is a gidNumber." 1>&2
-			group=$(getent group $group | cut -d":" -f1)
+		if [ "${x2godesktopsharing_create_group_for_sharing}" = 'true' ] && [ -n "${group}" ]; then
+			# this should create the hard-coded "x2godesktopsharing" group
+			if ! getent 'group' "${group}" >'/dev/null'; then
+				echo "Creating »${group}« group." 1>&2
+				addgroup --system "${group}"
+			else
+				echo "Group »${group}« already exists." 1>&2
+			fi
 		fi
-	fi
 
-	if [ -z "$group" ]; then
-		group="root"
-	fi
-
-	# finally tweak X2Go Desktop Sharing's configuration file and adapt the group parameter
-	sed -i /etc/x2go/desktopsharing/settings -e "s/group=.*/group=$group/"
+		if [ "${x2godesktopsharing_use_existing_group_for_sharing}" = 'true' ] && [ -n "${group}" ]; then
+			if echo "${group}" | grep -Eq '^[[:digit:]]{1,5}$' 1>'/dev/null'; then
+				echo 'Specified sharing group is a group ID.' 1>&2
+				group="$(getent 'group' "${group}" | cut -d ':' -f '1')"
+			fi
+		fi
 
-	db_get x2goserver-desktopsharing/auto-start-on-logon
-	if [ "$RET" = "true" ] && [ ! -e /etc/xdg/autostart/x2godesktopsharing.desktop ]; then
-		echo "Setting up system-wide XDG autostart for X2Go Desktop Sharing."
-		cp /usr/share/applications/x2godesktopsharing.desktop /etc/xdg/autostart/x2godesktopsharing.desktop
-	elif [ "$RET" = "false" ] && [ -f /etc/xdg/autostart/x2godesktopsharing.desktop ]; then
-		echo "Disabling system-wide XDG autostart for X2Go Desktop Sharing."
-		rm -f /etc/xdg/autostart/x2godesktopsharing.desktop
-	fi
+		if [ -z "${group}" ]; then
+			group='root'
+		fi
 
-	db_get x2goserver-desktopsharing/auto-activate-on-logon
-	if [ "$RET" = "true" ] && [ -e /etc/xdg/autostart/x2godesktopsharing.desktop ]; then
-		echo "Setting up system-wide auto-activation of X2Go Desktop Sharing."
-		sed -i /etc/xdg/autostart/x2godesktopsharing.desktop -e 's@^Exec=.*@Exec=/usr/bin/x2godesktopsharing --activate-desktop-sharing@'
-	elif [ "$RET" = "false" ] && [ -e /etc/xdg/autostart/x2godesktopsharing.desktop ]; then
-		echo "Disabling system-wide auto-activation of X2Go Desktop Sharing."
-		sed -i /etc/xdg/autostart/x2godesktopsharing.desktop -e 's@^Exec=.*@Exec=/usr/bin/x2godesktopsharing@'
-	fi
-	;;
+		# finally tweak X2Go Desktop Sharing's configuration file and adapt the group parameter
+		sed -i '/etc/x2go/desktopsharing/settings' -e "s/group=.*/group=${group}/"
 
-	abort-upgrade|abort-remove|abort-deconfigure)
-	;;
+		db_get 'x2goserver-desktopsharing/auto-start-on-logon'
+		if [ "${RET}" = 'true' ] && [ ! -e '/etc/xdg/autostart/x2godesktopsharing.desktop' ]; then
+			echo 'Setting up system-wide XDG autostart for X2Go Desktop Sharing.'
+			cp '/usr/share/applications/x2godesktopsharing.desktop' '/etc/xdg/autostart/x2godesktopsharing.desktop'
+		elif [ "${RET}" = 'false' ] && [ -f '/etc/xdg/autostart/x2godesktopsharing.desktop' ]; then
+			echo 'Disabling system-wide XDG autostart for X2Go Desktop Sharing.'
+			rm -f '/etc/xdg/autostart/x2godesktopsharing.desktop'
+		fi
 
+		db_get 'x2goserver-desktopsharing/auto-activate-on-logon'
+		if [ "${RET}" = 'true' ] && [ -e '/etc/xdg/autostart/x2godesktopsharing.desktop' ]; then
+			echo 'Setting up system-wide auto-activation of X2Go Desktop Sharing.'
+			sed -i '/etc/xdg/autostart/x2godesktopsharing.desktop' -e 's@^Exec=.*@Exec=/usr/bin/x2godesktopsharing --activate-desktop-sharing@'
+		elif [ "${RET}" = 'false' ] && [ -e '/etc/xdg/autostart/x2godesktopsharing.desktop' ]; then
+			echo 'Disabling system-wide auto-activation of X2Go Desktop Sharing.'
+			sed -i '/etc/xdg/autostart/x2godesktopsharing.desktop' -e 's@^Exec=.*@Exec=/usr/bin/x2godesktopsharing@'
+		fi
+		;;
+	'abort-upgrade'|'abort-remove'|'abort-deconfigure')
+		;;
 	*)
-		echo "postinst called with unknown argument \`$1'" >&2
-		exit 1
-	;;
+		echo "postinst called with unknown argument '${1}'" >&2
+		exit '1'
+		;;
 esac
 
 # dh_installdeb will replace this with shell code automatically
@@ -95,4 +90,4 @@ esac
 
 #DEBHELPER#
 
-exit 0
+exit '0'

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goserver.git


More information about the x2go-commits mailing list