pull/1314/head
nicedevil007 2 years ago
parent 8df374d80d
commit af7b8e66e7
  1. 18
      ct/alpine-vaultwarden.sh

@ -55,9 +55,6 @@ function update_script() {
if ! apk -e info newt >/dev/null 2>&1; then if ! apk -e info newt >/dev/null 2>&1; then
apk add -q newt apk add -q newt
fi fi
if ! apk -e info argon2 >/dev/null 2>&1; then
apk add -q argon2
fi
while true; do while true; do
CHOICE=$( CHOICE=$(
whiptail --title "SUPPORT" --menu "Select option" 11 58 2 \ whiptail --title "SUPPORT" --menu "Select option" 11 58 2 \
@ -78,16 +75,15 @@ function update_script() {
2) 2)
if NEWTOKEN=$(whiptail --passwordbox "Setup your ADMIN_TOKEN (make it strong)" 10 58 3>&1 1>&2 2>&3); then if NEWTOKEN=$(whiptail --passwordbox "Setup your ADMIN_TOKEN (make it strong)" 10 58 3>&1 1>&2 2>&3); then
if [[ -z "$NEWTOKEN" ]]; then exit-script; fi if [[ -z "$NEWTOKEN" ]]; then exit-script; fi
ADMINTOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1) if ! command -v argon2 >/dev/null 2>&1; then apk add argon2 &>/dev/null; fi
if [[ -f /var/lib/vaultwarden/config.json ]]; then TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1)
sed -i '/admin_token/d' /var/lib/vaultwarden/config.json if [[ ! -f /var/lib/vaultwarden/config.json ]]; then
sed -i "2i\\ \"admin_token\": \"$ADMINTOKEN\"," /var/lib/vaultwarden/config.json sed -i "s|export ADMIN_TOKEN=.*|export ADMIN_TOKEN='${TOKEN}'|" /etc/conf.d/vaultwarden
else else
sed -i '/ADMIN_TOKEN/d' /etc/conf.d/vaultwarden sed -i "s|\"admin_token\": .*|\"admin_token\": \"${TOKEN}\",|" /var/lib/vaultwarden/config.json
sed -i "4i\export ADMIN_TOKEN=\'$ADMINTOKEN\'" /etc/conf.d/vaultwarden
fi fi
fi rc-service vaultwarden restart -q
rc-service vaultwarden restart fi
clear clear
exit exit
;; ;;

Loading…
Cancel
Save