Skip to content

Commit

Permalink
🌱 add PLUGIN_VERSION
Browse files Browse the repository at this point in the history
- attempt to have plugin versions
- maybe this time it'll stick

refactor service upgrade
  • Loading branch information
tprelog committed Feb 20, 2021
1 parent c311403 commit d1c678a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
1 change: 1 addition & 0 deletions overlay/root/.PLUGIN_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.20210220
2 changes: 1 addition & 1 deletion post_install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
version="1.20210219"

version="$(cat /root/.PLUGIN_VERSION)"
sysrc plugin_initialized="${version}"
sysrc plugin_version="${version}"

Expand Down
18 changes: 13 additions & 5 deletions post_update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
version="1.20210219"

# shellcheck disable=SC1091
. /etc/rc.subr && load_rc_config
Expand All @@ -18,12 +17,21 @@ install_pkglist() {
upgrade_service() {
## If enabled, upgrade zwavejs2mqtt during a Plugin UPDATE
## Use `sysrc plugin_upgrade_service=YES` to enable
/root/bin/install_zj2m \
&& sysrc zwavejs2mqtt_enable="YES"
/root/bin/install_zj2m
}

# shellcheck disable=SC2154
version="${plugin_version%%.*}"
if [ "${version}" == '1' ]; then
#plugin_upgrade_service='YES'
true
elif [ "${version}" == '2' ]; then
true
else
err 1 "you shouldn't be here"
fi

checkyesno plugin_enable_pkglist && install_pkglist
checkyesno plugin_upgrade_service && upgrade_service

## Exit 0, else a Plugin UPDATE will fail here
echo ; sysrc plugin_version="${version}" ; exit
sysrc plugin_version="$(cat /root/.PLUGIN_VERSION)"
22 changes: 5 additions & 17 deletions pre_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@

# shellcheck disable=SC1091
. /etc/rc.subr && load_rc_config
: "${plugin_upgrade_service:="NO"}"

# shellcheck disable=SC2154
if [ "${plugin_version%%.*}" == "1" ]; then
true
else # this is a place holder for future use
warn "unknown version"
version="${plugin_version%%.*}"
if [ "${version}" == '1' ] || [ "${version}" == '2' ]; then
exit 0
else
err 1 "unknown plugin version"
fi

upgrade_service() {
## If enabled, upgrade zwavejs2mqtt during a Plugin UPDATE
## Use `sysrc plugin_upgrade_service=YES` to enable
service zwavejs2mqtt stop 2>/dev/null
sysrc -x zwavejs2mqtt_enable 2>/dev/null
}

checkyesno plugin_upgrade_service && upgrade_service

## Exit 0, else a Plugin UPDATE will fail here
exit 0

0 comments on commit d1c678a

Please sign in to comment.