forked from tprelog/iocage-homeassistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_update.sh
executable file
·66 lines (55 loc) · 2.19 KB
/
post_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# shellcheck disable=SC1091,2154
. /etc/rc.subr && load_rc_config
: "${plugin_enable_pkglist:="NO"}"
: "${plugin_clean_install_service:="NO"}"
: "${plugin_force_reinstall_service:="NO"}"
: "${plugin_upgrade_service:="NO"}"
install_pkglist() {
## If enabled, re-install packages from a pkglist, during a Plugin UPDATE
## Use `sysrc plugin_pkglist="/path/to/pkglist"` to set a pkglist
## Use `sysrc plugin_enable_pkglist=YES` to enable
local pkgs ; pkgs=$(cat "${plugin_pkglist:-/dev/null}")
echo -e "\nChecking for additional packages to install..."
echo "${pkgs}" | xargs pkg install -y
}
clean_install_service() {
## If enabled, clean-install Home Assistant Core during a Plugin UPDATE
## Use `sysrc plugin_clean_install_service=YES` to enable
local service="homeassistant" ; rm -rf "${homeassistant_venv}"
/root/.plugin/bin/get-pip-required "${service}" \
&& service "${service}" install "${service}" \
-r "/root/.plugin/pip/requirements.${service}"
}
force_reinstall_service() {
## If enabled, force-reinstall Home Assistant Core during a Plugin UPDATE
## Use `sysrc plugin_force_reinstall_service=YES` to enable
local service="homeassistant"
/root/.plugin/bin/get-pip-required "${service}" \
&& service "${service}" install --upgrade --force-reinstall "${service}" \
-r "/root/.plugin/pip/requirements.${service}"
}
upgrade_service() {
## If enabled, upgrade Home Assistant Core during a Plugin UPDATE
## Use `sysrc plugin_upgrade_service=YES` to enable
service homeassistant install --upgrade homeassistant
}
checkyesno plugin_enable_pkglist && install_pkglist
if [ "${plugin_version%%.*}" == "5" ]; then
plugin_clean_install_service=YES
elif [ "${plugin_version%%-*}" == "v6" ]; then
true
fi
## ISSUE 47 - Support for Python 3.8 to be dropped
pkg install -y python39 py39-sqlite3
sysrc homeassistant_python=/usr/local/bin/python3.9
if checkyesno plugin_clean_install_service; then
clean_install_service
elif checkyesno plugin_force_reinstall_service; then
force_reinstall_service
elif checkyesno plugin_upgrade_service; then
upgrade_service
fi
sysrc plugin_version="$(cat /root/.PLUGIN_VERSION)"
## Gererate PLUGIN_INFO
/root/.plugin/bin/plugin-info