From 1014ab1653a87762e5c3d1191d2cee3f1fbc55e7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 6 Oct 2024 14:52:58 +0200 Subject: [PATCH] Improve backuplocation and set password --- portainer/rootfs/etc/services.d/portainer/run | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/portainer/rootfs/etc/services.d/portainer/run b/portainer/rootfs/etc/services.d/portainer/run index f0ddc6e65..3cc54b05d 100644 --- a/portainer/rootfs/etc/services.d/portainer/run +++ b/portainer/rootfs/etc/services.d/portainer/run @@ -34,9 +34,10 @@ fi # Set up the initial password PASSWORD_FILE="/data/portainer_password" HIDDEN_FILE="/data/hidden" -PASSWORD="${PASSWORD:-empty}" if ! bashio::config.has_value 'password'; then PASSWORD="empty" +else + PASSWORD="$(bashio::config 'password')" fi # Check current password @@ -47,9 +48,10 @@ CURRENTPASSWORD="$(cat "$PASSWORD_FILE")" # Reset password if not first run if bashio::fs.file_exists "$HIDDEN_FILE"; then if [[ "$CURRENTPASSWORD" != "$PASSWORD" ]]; then - mv -f /data/portainer.db /data/portainer.old || true + BACKUPLOCATION="/share/portainer_$(date +%m-%d-%Y)_$RANDOM.backup" + mv -f /data/portainer.db "$BACKUPLOCATION" || true rm "$HIDDEN_FILE" || true - bashio::log.warning "... password changed, database reset. Previous version stored in /share/portainer_$(date +%m-%d-%Y)_$RANDOM.backup" + bashio::log.warning "... password changed, database reset. Previous version stored in $BACKUPLOCATION" fi fi