Skip to content

Commit

Permalink
Changed control scripts for RPM
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Clark <ben@benjyc.uk>
  • Loading branch information
BClark09 committed Feb 18, 2017
1 parent a2c0fdf commit bd4f748
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
4 changes: 2 additions & 2 deletions resources/deb/control-runtime/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 17 additions & 6 deletions resources/deb/control-runtime/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,32 @@ 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
rm -rf /usr/share/openhab2
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)
;;
*)
Expand Down
25 changes: 21 additions & 4 deletions resources/deb/control-runtime/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion resources/deb/control-runtime/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ case "$1" in
stopOpenHAB
exit 0
;;
remove|deconfigure)
remove|deconfigure|0)
stopOpenHAB
exit 0
;;
Expand Down

0 comments on commit bd4f748

Please sign in to comment.