Migrate data to new folder (to allow backups in the future) https://github.com/alexbelgium/hassio-addons/issues/1550

This commit is contained in:
Alexandre
2024-08-26 14:49:38 +02:00
committed by GitHub
parent bbc26a6be3
commit b0411ed64e
5 changed files with 26 additions and 9 deletions

View File

@@ -114,7 +114,7 @@
## 1.0.1 (03-01-2023) ## 1.0.1 (03-01-2023)
- Migrates data to cp -r /data/\* /config/addons_config/mealie_data/ to enable usage of new addons - Migrates data to cp -r /data/\* /config/ to enable usage of new addons
- WARNING : update to supervisor 2022.11 before installing - WARNING : update to supervisor 2022.11 before installing
- Optional passing of env variables by adding them in a config.yml file (see readme) - Optional passing of env variables by adding them in a config.yml file (see readme)
- Breaking change : amd64 updated to mealie 1.0 - Breaking change : amd64 updated to mealie 1.0

View File

@@ -29,7 +29,7 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
# Correct data path # Correct data path
# hadolint ignore=DL4006 # hadolint ignore=DL4006
RUN grep -rl "/app/data" /app | xargs sed -i 's|/app/data|/config/addons_config/mealie_data|g' && \ RUN grep -rl "/app/data" /app | xargs sed -i 's|/app/data|/config|g' && \
sed -i "s|change_user$|# change_user|g" /app/run.sh sed -i "s|change_user$|# change_user|g" /app/run.sh
################## ##################

View File

@@ -51,7 +51,7 @@ Options can be configured through two ways :
``` ```
- Config.yaml - Config.yaml
Additional options can be configured using the config.yaml file found in /config/addons_config/mealie/config.yaml Additional options can be configured using the config.yaml file found in /homeassistant/addons_config/xxx-mealie/config.yaml
The complete list of options can be seen here : https://nightly.mealie.io/documentation/getting-started/installation/backend-config/ The complete list of options can be seen here : https://nightly.mealie.io/documentation/getting-started/installation/backend-config/

View File

@@ -65,7 +65,7 @@
"/dev/nvme2" "/dev/nvme2"
], ],
"environment": { "environment": {
"DATA_DIR": "/config/addons_config/mealie_data", "DATA_DIR": "/config",
"DB_ENGINE": "sqlite", "DB_ENGINE": "sqlite",
"MAX_WORKERS": "1", "MAX_WORKERS": "1",
"WEB_CONCURRENCY": "2", "WEB_CONCURRENCY": "2",
@@ -74,14 +74,15 @@
}, },
"image": "ghcr.io/alexbelgium/mealie-{arch}", "image": "ghcr.io/alexbelgium/mealie-{arch}",
"map": [ "map": [
"config:rw", "addon_config:rw",
"homeassistant_config:rw",
"share:rw", "share:rw",
"ssl:rw" "ssl:rw"
], ],
"name": "Mealie", "name": "Mealie",
"options": { "options": {
"ALLOW_SIGNUP": true, "ALLOW_SIGNUP": true,
"DATA_DIR": "/config/addons_config/mealie_data", "DATA_DIR": "/config",
"PGID": 1000, "PGID": 1000,
"PUID": 1000, "PUID": 1000,
"certfile": "fullchain.pem", "certfile": "fullchain.pem",

View File

@@ -31,11 +31,27 @@ for k in $(bashio::jq "/data/options.json" 'keys | .[]'); do
export "$k"="$(bashio::config "$k")" export "$k"="$(bashio::config "$k")"
done done
####################
# MIGRATE DATA DIR #
####################
if [ -d /homeassistant/addons_config/mealie_data ] && [ ! -f /homeassistant/addons_config/mealie_data/migrated ]; then
bashio::log.warning "Migrating data"
cp -rnf /homeassistant/addons_config/mealie_data/* /config/ || true
touch /homeassistant/addons_config/mealie_data/migrated
fi
if [ -f /homeassistant/addons_config/mealie/config.yaml ] && [ ! -f /homeassistant/addons_config/mealie/migrated ]; then
bashio::log.warning "Migrating config.yaml"
cp -nf /homeassistant/addons_config/mealie/config.yaml /config/ || true
touch /homeassistant/addons_config/mealie/migrated
fi
############### ###############
# CONFIG YAML # # CONFIG YAML #
############### ###############
CONFIGSOURCE="/config/addons_config/mealie/config.yaml" CONFIGSOURCE="/config/config.yaml"
if [ -f "$CONFIGSOURCE" ]; then if [ -f "$CONFIGSOURCE" ]; then
bashio::log.info "config.yaml found in $CONFIGSOURCE, exporting variables" bashio::log.info "config.yaml found in $CONFIGSOURCE, exporting variables"
@@ -70,10 +86,10 @@ while IFS= read -r line; do
echo "secret detected" echo "secret detected"
secret=${line#*secret } secret=${line#*secret }
# Check if single match # Check if single match
secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) secretnum=$(sed -n "/$secret:/=" /homeassistant/secrets.yaml)
[[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" [[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
# Get text # Get text
secret=$(sed -n "/$secret:/p" /config/secrets.yaml) secret=$(sed -n "/$secret:/p" /homeassistant/secrets.yaml)
secret=${secret#*: } secret=${secret#*: }
line="${line%%=*}='$secret'" line="${line%%=*}='$secret'"
fi fi