Update vaultwarden.sh

add Admin Token to `/opt/vaultwarden/data/config.json`
pull/3406/head
tteckster 2024-07-17 13:32:26 -04:00 committed by GitHub
parent 00a8f07170
commit 9deea7a983
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -127,7 +127,9 @@ function update_script() {
if [[ -z "$NEWTOKEN" ]]; then exit; fi if [[ -z "$NEWTOKEN" ]]; then exit; fi
if ! command -v argon2 >/dev/null 2>&1; then apt-get install -y argon2 &>/dev/null; fi if ! command -v argon2 >/dev/null 2>&1; then apt-get install -y argon2 &>/dev/null; fi
TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -t 2 -m 16 -p 4 -l 64 -e) TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -t 2 -m 16 -p 4 -l 64 -e)
sed -i "s|ADMIN_TOKEN=.*|ADMIN_TOKEN='${TOKEN}'|" /opt/vaultwarden/.env for file in /opt/vaultwarden/.env /opt/vaultwarden/data/config.json; do
sed -i "s|ADMIN_TOKEN=.*|ADMIN_TOKEN='${TOKEN}'|" "$file"
done
systemctl restart vaultwarden systemctl restart vaultwarden
fi fi
exit exit