From b08a6ad72a66d841106b0c7a5efaada2b68c6f61 Mon Sep 17 00:00:00 2001 From: Tim Wagner Date: Wed, 28 Aug 2024 09:38:20 +0200 Subject: [PATCH] Set 'setKey' and 'webpwd' only on new installations. Change debian postinst scripts to run some shell commands for setting 'setKey' and 'webpwd' parameter only if no weakforce is already installed (or configurations are left). This is necessary because running these commands if weakforce is already runnig they will fail and upgrading exits with failure. postinst maintainer script is only run _without_ additional arguments beside 'configure' if it's a new installation. See https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#summary-of-ways-maintainer-scripts-are-called --- builder-support/debian/wforce-trackalert.postinst | 12 +++++++----- builder-support/debian/wforce.postinst | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/builder-support/debian/wforce-trackalert.postinst b/builder-support/debian/wforce-trackalert.postinst index 5a3906bc..d1b63f2b 100755 --- a/builder-support/debian/wforce-trackalert.postinst +++ b/builder-support/debian/wforce-trackalert.postinst @@ -16,11 +16,13 @@ case "$1" in adduser --quiet --system --home /var/spool/wforce --shell /bin/false --ingroup wforce --disabled-password --disabled-login --gecos "wforce" wforce echo "done" fi - echo -n "Modifying trackalert.conf to replace password and key..." - SETKEY=`echo "makeKey()" | trackalert | grep setKey` - WEBPWD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2-14 | rev` - sed -e "s#--WEBPWD#$WEBPWD#" -e "s#--SETKEY#$SETKEY#" -i $TRACKALERTCONF - echo "done" + if [ -z "$2" ]; then + echo -n "Modifying trackalert.conf to replace password and key..." + SETKEY=`echo "makeKey()" | trackalert | grep setKey` + WEBPWD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2-14 | rev` + sed -e "s#--WEBPWD#$WEBPWD#" -e "s#--SETKEY#$SETKEY#" -i $TRACKALERTCONF + echo "done" + fi ;; *) diff --git a/builder-support/debian/wforce.postinst b/builder-support/debian/wforce.postinst index 07e29540..4b9ea187 100755 --- a/builder-support/debian/wforce.postinst +++ b/builder-support/debian/wforce.postinst @@ -28,11 +28,13 @@ case "$1" in mv /etc/wforce.conf /etc/wforce/wforce.conf && \ echo "Moved /etc/wforce.conf to /etc/wforce/wforce.conf" fi - echo -n "Modifying wforce.conf to replace password and key..." - SETKEY=`echo "makeKey()" | wforce | grep setKey` - WEBPWD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2-14 | rev` - sed -e "s#--WEBPWD#$WEBPWD#" -e "s#--SETKEY#$SETKEY#" -i $WFORCECONF - echo "done" + if [ -z "$2" ]; then + echo -n "Modifying wforce.conf to replace password and key..." + SETKEY=`echo "makeKey()" | wforce | grep setKey` + WEBPWD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 | rev | cut -b 2-14 | rev` + sed -e "s#--WEBPWD#$WEBPWD#" -e "s#--SETKEY#$SETKEY#" -i $WFORCECONF + echo "done" + fi ;; *)