Update 00-migration.sh

This commit is contained in:
Alexandre
2023-12-09 15:16:14 +01:00
committed by GitHub
parent 47abbb0bfa
commit 81b3914daf

View File

@@ -7,6 +7,8 @@ mkdir -p /config/openvpn
mkdir -p /config/qBittorrent/config
mkdir -p /config/qBittorrent/data
MIGRATED=""
if [ -f /homeassistant/addons_config/qBittorrent/qBittorrent.conf ]; then
bashio::log.warning "----------------------------------------"
bashio::log.warning "Migrating configuration to the new addon"
@@ -33,11 +35,13 @@ if [ -f /homeassistant/addons_config/qbittorrent/config.yaml ]; then
mv /homeassistant/addons_config/qbittorrent/* /config/
rm -r /homeassistant/addons_config/qbittorrent
bashio::log.yellow "... moved config.yaml from /config/addons_config/qbittorrent to /addon_configs/$HOSTNAME"
MIGRATED=true
fi || true
if [ -f /homeassistant/addons_autoscrips/qbittorrent.sh ]; then
mv /homeassistant/addons_autoscrips/qbittorrent.sh /config/
bashio::log.yellow "... moved qbittorrent.sh from /config/addons_autoscripts to /addon_configs/$HOSTNAME"
MIGRATED=true
fi || true
if bashio::config.has_value 'openvpn_enable'; then
@@ -49,6 +53,7 @@ if bashio::config.has_value 'openvpn_enable'; then
fi
bashio::addon.option "openvpn_enable"
bashio::log.yellow "... openvpn_enable : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'openvpn_username'; then
@@ -56,6 +61,7 @@ if bashio::config.has_value 'openvpn_username'; then
bashio::log.yellow "... openvpn_username : was set, VPN_USERNAME set to $(bashio::config "openvpn_username")"
bashio::addon.option "openvpn_username"
bashio::log.yellow "... openvpn_username : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'Username'; then
@@ -63,6 +69,7 @@ if bashio::config.has_value 'Username'; then
bashio::log.yellow "... Username : was set, QBT_USERNAME set to $(bashio::config "Username")"
bashio::addon.option "Username"
bashio::log.yellow "... Username : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'openvpn_password'; then
@@ -70,6 +77,7 @@ if bashio::config.has_value 'openvpn_password'; then
bashio::log.yellow "... openvpn_password : was set, VPN_PASSWORD set to $(bashio::config "openvpn_password")"
bashio::addon.option "openvpn_password"
bashio::log.yellow "... openvpn_password : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'whitelist'; then
@@ -77,11 +85,13 @@ if bashio::config.has_value 'whitelist'; then
bashio::log.yellow "... whitelist : was set, LAN_NETWORK set to $(bashio::config "whitelist")"
bashio::addon.option "whitelist"
bashio::log.yellow "... whitelist : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'smbv1'; then
bashio::addon.option "smbv1"
bashio::log.yellow "... smbv1 : removed as not used anymore"
MIGRATED=true
fi || true
if bashio::config.has_value 'openvpn_config'; then
@@ -89,8 +99,15 @@ if bashio::config.has_value 'openvpn_config'; then
if [ -f "$openvpn_config" ]; then
mv "$openvpn_config" /config/openvpn/
fi
MIGRATED=true
fi || true
if [[ "$MIGRATED" == "true" ]]; then
bashio::log.warning "Options were changed, restarting the addon"
bashio::addon.restart
fi
if [ -d /config/qBittorrent/qBittorrent ]; then
rm -r /config/qBittorrent/qBittorrent
fi || true