From bd4f7485ada99a9073741f736b4c12a1a53e7cc4 Mon Sep 17 00:00:00 2001 From: Ben Clark Date: Sat, 18 Feb 2017 22:31:27 +0000 Subject: [PATCH] Changed control scripts for RPM Signed-off-by: Ben Clark --- resources/deb/control-runtime/postinst | 4 ++-- resources/deb/control-runtime/postrm | 23 +++++++++++++++++------ resources/deb/control-runtime/preinst | 25 +++++++++++++++++++++---- resources/deb/control-runtime/prerm | 2 +- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/resources/deb/control-runtime/postinst b/resources/deb/control-runtime/postinst index c2dc94f..1958160 100644 --- a/resources/deb/control-runtime/postinst +++ b/resources/deb/control-runtime/postinst @@ -56,8 +56,8 @@ waitForStopFinished(){ } case "$1" in - configure) - if [ -z $2 ] ; then + configure|1|2) + if [ -z $2 ] && [ $1 -ne 2 ] ; then # this is a fresh installation if [ -x /bin/systemctl ] ; then echo "### NOT starting on installation, please execute the following statements to configure openHAB to start automatically using systemd" diff --git a/resources/deb/control-runtime/postrm b/resources/deb/control-runtime/postrm index 9dd3508..cd690bd 100644 --- a/resources/deb/control-runtime/postrm +++ b/resources/deb/control-runtime/postrm @@ -27,10 +27,10 @@ case "$1" in purge) removeOpenHABInit if getent passwd $OH_USER > /dev/null 2>&1; then - deluser --system --quiet $OH_USER || true + userdel --force $OH_USER || true fi if getent group $OH_GROUP > /dev/null 2>&1; then - delgroup --system --quiet $OH_GROUP || true + groupdel $OH_GROUP || true fi rm -rf /var/log/openhab2 rm -rf /var/lib/openhab2 @@ -38,10 +38,21 @@ case "$1" in rm -rf /etc/openhab2 exit 0 ;; - upgrade) - removeCache - exit 0 - ;; + 0) + removeOpenHABInit + if getent passwd $OH_USER > /dev/null 2>&1; then + userdel --force $OH_USER || true + fi + if getent group $OH_GROUP > /dev/null 2>&1; then + groupdel $OH_GROUP || true + fi + exit 0 + ;; + + upgrade|1) + removeCache + exit 0 + ;; abort-install|abort-upgrade|disappear|failed-upgrade) ;; *) diff --git a/resources/deb/control-runtime/preinst b/resources/deb/control-runtime/preinst index 8549c9e..52a4403 100644 --- a/resources/deb/control-runtime/preinst +++ b/resources/deb/control-runtime/preinst @@ -21,14 +21,31 @@ case "$1" in OH_GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` fi if ! getent group "$OH_GROUP" > /dev/null 2>&1 ; then - groupadd --system "$OH_GROUP" + addgroup --system "$OH_GROUP" --quiet fi if ! getent passwd "$OH_USER" > /dev/null 2>&1 ; then - adduser --quiet --system -g "$OH_GROUP" \ - --shell /bin/false \ - --home /var/lib/openhab2 "$OH_USER" + adduser --quiet --system --ingroup "$OH_GROUP" --no-create-home \ + --disabled-password --shell /bin/false \ + --gecos "openhab2 runtime user" --home /var/lib/openhab2 "$OH_USER" fi ;; + 1) + removeCache + OH_USER=openhab + OH_GROUP=openhab + if [ x"${USER_AND_GROUP}" != x ]; then + OH_USER=`echo ${USER_AND_GROUP} | cut -d ":" -f 1` + OH_GROUP=`echo ${USER_AND_GROUP} | cut -d ":" -f 2` + fi + if ! getent group "$OH_GROUP" > /dev/null 2>&1 ; then + groupadd --system "$OH_GROUP" + fi + if ! getent passwd "$OH_USER" > /dev/null 2>&1 ; then + useradd --system -g "$OH_GROUP" \ + --shell /bin/false \ + --home /var/lib/openhab2 "$OH_USER" + fi + ;; esac exit 0 diff --git a/resources/deb/control-runtime/prerm b/resources/deb/control-runtime/prerm index 0e3b1f1..77dcf51 100644 --- a/resources/deb/control-runtime/prerm +++ b/resources/deb/control-runtime/prerm @@ -24,7 +24,7 @@ case "$1" in stopOpenHAB exit 0 ;; - remove|deconfigure) + remove|deconfigure|0) stopOpenHAB exit 0 ;;