2023-03-23 00:48:20 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-11-02 07:48:05 +00:00
|
|
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
2025-01-01 12:37:29 +00:00
|
|
|
# Copyright (c) 2021-2025 tteck
|
2023-03-23 00:48:20 +00:00
|
|
|
# Author: tteck (tteckster)
|
2024-12-16 11:42:51 +00:00
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
2023-03-23 00:48:20 +00:00
|
|
|
|
2024-12-16 11:42:51 +00:00
|
|
|
# App Default Values
|
2023-03-23 00:48:20 +00:00
|
|
|
APP="Alpine-Vaultwarden"
|
2024-12-16 12:31:48 +00:00
|
|
|
var_tags="alpine;vault"
|
2023-03-23 00:48:20 +00:00
|
|
|
var_cpu="1"
|
|
|
|
var_ram="256"
|
2024-12-16 11:42:51 +00:00
|
|
|
var_disk="0.3"
|
2023-03-23 00:48:20 +00:00
|
|
|
var_os="alpine"
|
2024-12-16 11:42:51 +00:00
|
|
|
var_version="3.20"
|
|
|
|
var_unprivileged="1"
|
|
|
|
|
|
|
|
# App Output & Base Settings
|
|
|
|
header_info "$APP"
|
|
|
|
base_settings
|
|
|
|
|
|
|
|
# Core
|
2023-03-23 00:48:20 +00:00
|
|
|
variables
|
|
|
|
color
|
|
|
|
catch_errors
|
|
|
|
|
|
|
|
function update_script() {
|
2023-03-24 17:26:04 +00:00
|
|
|
if ! apk -e info newt >/dev/null 2>&1; then
|
|
|
|
apk add -q newt
|
|
|
|
fi
|
2023-03-23 00:48:20 +00:00
|
|
|
while true; do
|
|
|
|
CHOICE=$(
|
2023-09-09 09:13:17 +00:00
|
|
|
whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --menu "Select option" 11 58 2 \
|
2023-03-24 12:07:49 +00:00
|
|
|
"1" "Update Vaultwarden" \
|
2023-04-10 12:16:47 +00:00
|
|
|
"2" "Reset ADMIN_TOKEN" 3>&2 2>&1 1>&3
|
2023-03-23 00:48:20 +00:00
|
|
|
)
|
|
|
|
exit_status=$?
|
|
|
|
if [ $exit_status == 1 ]; then
|
|
|
|
clear
|
|
|
|
exit-script
|
|
|
|
fi
|
|
|
|
header_info
|
|
|
|
case $CHOICE in
|
|
|
|
1)
|
2024-08-19 02:30:57 +00:00
|
|
|
apk update && apk upgrade && rc-service vaultwarden restart -q
|
2023-03-23 00:48:20 +00:00
|
|
|
exit
|
|
|
|
;;
|
|
|
|
2)
|
2023-09-09 09:13:17 +00:00
|
|
|
if NEWTOKEN=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "Setup your ADMIN_TOKEN (make it strong)" 10 58 3>&1 1>&2 2>&3); then
|
2023-04-10 12:16:47 +00:00
|
|
|
if [[ -z "$NEWTOKEN" ]]; then exit-script; fi
|
|
|
|
if ! command -v argon2 >/dev/null 2>&1; then apk add argon2 &>/dev/null; fi
|
|
|
|
TOKEN=$(echo -n ${NEWTOKEN} | argon2 "$(openssl rand -base64 32)" -e -id -k 19456 -t 2 -p 1)
|
|
|
|
if [[ ! -f /var/lib/vaultwarden/config.json ]]; then
|
|
|
|
sed -i "s|export ADMIN_TOKEN=.*|export ADMIN_TOKEN='${TOKEN}'|" /etc/conf.d/vaultwarden
|
|
|
|
else
|
|
|
|
sed -i "s|\"admin_token\": .*|\"admin_token\": \"${TOKEN}\",|" /var/lib/vaultwarden/config.json
|
|
|
|
fi
|
|
|
|
rc-service vaultwarden restart -q
|
2024-12-16 11:42:51 +00:00
|
|
|
fi
|
2023-03-23 00:48:20 +00:00
|
|
|
clear
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
start
|
|
|
|
build_container
|
|
|
|
description
|
|
|
|
|
|
|
|
msg_ok "Completed Successfully!\n"
|
|
|
|
echo -e "${APP} should be reachable by going to the following URL.
|
|
|
|
${BL}http://${IP}:8000${CL} \n"
|