Skip to content

Commit

Permalink
Improve backuplocation and set password
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium authored Oct 6, 2024
1 parent f0823b0 commit 1014ab1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions portainer/rootfs/etc/services.d/portainer/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 1014ab1

Please sign in to comment.