mirror of
https://github.com/hassio-addons/addon-home-panel.git
synced 2025-05-04 19:01:21 +00:00
🔨 Persist secret and db
This commit is contained in:
parent
fd47050d0e
commit
44ff20cc1a
1 changed files with 12 additions and 4 deletions
|
@ -3,10 +3,18 @@
|
|||
# Community Hass.io Add-ons: Home Panel
|
||||
# This updates the internal auth secret for the API
|
||||
# ==============================================================================
|
||||
if [ "$(grep -i 'API_AUTH_SECRET' /opt/panel/config/default.json)" = 0 ]; then
|
||||
bashio::log.info "Update auth secret.."
|
||||
sed -i -e "s/API_AUTH_SECRET/$(openssl rand -base64 32)/g" /opt/panel/config/default.json
|
||||
declare key
|
||||
|
||||
if ! bashio::fs.file_exists "/data/secret.txt"; then
|
||||
bashio::log.info "Generating secret"
|
||||
newkey=$(openssl rand -base64 32)
|
||||
echo "${newkey}" > /data/secret.txt
|
||||
fi
|
||||
|
||||
# Force database to use /data
|
||||
key=$(cat /data/secret.txt)
|
||||
|
||||
# Set secret to persistent secret file
|
||||
sed -i "s/API_AUTH_SECRET/${key}/g" /opt/panel/config/default.json
|
||||
|
||||
# Set database to /data
|
||||
sed -i "s#../db#/data#g" /opt/panel/config/default.json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue