Skip to content

Commit

Permalink
apt upgrade fixes (openhab#286)
Browse files Browse the repository at this point in the history
* remove cache
* ensure exit status 0 on service stop

Signed-off-by: Theo Weiss <[email protected]> (github: theoweiss)
  • Loading branch information
theoweiss authored and kaikreuzer committed Oct 16, 2016
1 parent f5b5338 commit 661c52f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@ removeOpenHABInit() {
fi
}

removeCache(){
rm -rf /var/lib/openhab2/cache
rm -rf /var/lib/openhab2/tmp
}

case "$1" in
remove)
removeOpenHABInit
removeCache
exit 0
;;
purge)
removeOpenHABInit
Expand All @@ -31,7 +38,11 @@ case "$1" in
rm -rf /etc/openhab2
exit 0
;;
abort-install|abort-upgrade|disappear|failed-upgrade|upgrade)
upgrade)
removeCache
exit 0
;;
abort-install|abort-upgrade|disappear|failed-upgrade)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

set -e

UD_CACHE=/var/lib/openhab2/cache
UD_TMP=/var/lib/openhab2/tmp

removeCache(){
[ -d ${UD_CACHE} ] && rm -rf ${UD_CACHE}
[ -d ${UD_TMP} ] && rm -rf ${UD_TMP}
}

case "$1" in
install)
removeCache
OH_USER=openhab
OH_GROUP=openhab
if [ x"${USER_AND_GROUP}" != x ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ set -e

stopOpenHAB() {
if [ -x /bin/systemctl ] ; then
/bin/systemctl --no-reload stop openhab2.service > /dev/null 2>&1 || :
/bin/systemctl --no-reload stop openhab2.service > /dev/null 2>&1 || true
elif [ -x "/etc/init.d/openhab2" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d openhab2 stop
invoke-rc.d openhab2 stop > /dev/null 2>&1 || true
else
/etc/init.d/openhab2 stop
/etc/init.d/openhab2 stop > /dev/null 2>&1 || true
fi
# waiting for the openhab2 process stop (max 10 seconds), otherwise the removal of the user will fail.
# workaround /etc/init.d/openhab2 stop the service needs some time to stop
Expand All @@ -22,9 +22,11 @@ stopOpenHAB() {
case "$1" in
upgrade)
stopOpenHAB
exit 0
;;
remove|deconfigure)
stopOpenHAB
exit 0
;;
failed-upgrade)
;;
Expand Down

0 comments on commit 661c52f

Please sign in to comment.