2023-03-22 20:48:20 -04:00
#!/usr/bin/env bash
2023-03-23 00:09:04 -04:00
source <( curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
2024-01-01 12:13:05 -05:00
# Copyright (c) 2021-2024 tteck
2023-03-22 20:48:20 -04:00
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
clear
cat <<"EOF"
_ __ ____ _ __ __
| | / /___ ___ __/ / /| | / /___ __________/ /__ ____
| | / / __ ` / / / / / __/ | /| / / __ ` / ___/ __ / _ \/ __ \
| | / / /_/ / /_/ / / /_ | | / | / / /_/ / / / /_/ / __/ / / /
| ___/\_ _,_/\_ _,_/_/\_ _/ | __/| __/\_ _,_/_/ \_ _,_/\_ __/_/ /_/
EOF
}
header_info
echo -e "Loading..."
APP = "Vaultwarden"
var_disk = "6"
var_cpu = "4"
2024-05-13 11:09:27 -04:00
var_ram = "5120"
2023-03-22 20:48:20 -04:00
var_os = "debian"
2023-11-11 19:35:32 -05:00
var_version = "12"
2023-03-22 20:48:20 -04:00
variables
color
catch_errors
function default_settings( ) {
CT_TYPE = "1"
PW = ""
CT_ID = $NEXTID
HN = $NSAPP
DISK_SIZE = " $var_disk "
CORE_COUNT = " $var_cpu "
RAM_SIZE = " $var_ram "
BRG = "vmbr0"
2023-05-13 21:22:09 -04:00
NET = "dhcp"
2023-03-22 20:48:20 -04:00
GATE = ""
2024-01-12 15:00:42 -05:00
APT_CACHER = ""
APT_CACHER_IP = ""
2023-03-22 20:48:20 -04:00
DISABLEIP6 = "no"
MTU = ""
SD = ""
NS = ""
MAC = ""
VLAN = ""
SSH = "no"
VERB = "no"
echo_default
}
function update_script( ) {
if [ [ ! -f /etc/systemd/system/vaultwarden.service ] ] ; then
msg_error " No ${ APP } Installation Found! "
exit
fi
2024-10-20 22:14:50 -04:00
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "SET RESOURCES" " Please set the resources in your ${ APP } LXC to ${ var_cpu } vCPU and ${ var_ram } RAM for the build process before continuing " 10 75
2023-03-22 20:48:20 -04:00
VAULT = $( curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest |
grep "tag_name" |
awk '{print substr($2, 2, length($2)-3) }' )
WVRELEASE = $( curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest |
grep "tag_name" |
awk '{print substr($2, 2, length($2)-3) }' )
2023-09-09 05:13:17 -04:00
UPD = $( whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 3 \
2023-03-22 20:48:20 -04:00
"1" " VaultWarden $VAULT " ON \
"2" " Web-Vault $WVRELEASE " OFF \
2023-04-09 23:45:57 -04:00
"3" "Set Admin Token" OFF \
2023-03-22 20:48:20 -04:00
3>& 1 1>& 2 2>& 3)
header_info
if [ " $UPD " = = "1" ] ; then
echo -e "\n ⚠️ Ensure you set 4vCPU & 4096MiB RAM minimum!!! \n"
msg_info "Stopping Vaultwarden"
systemctl stop vaultwarden.service
msg_ok "Stopped Vaultwarden"
msg_info " Updating VaultWarden to $VAULT (Patience) "
cd ~ && rm -rf vaultwarden
git clone https://github.com/dani-garcia/vaultwarden & >/dev/null
cd vaultwarden
cargo build --features "sqlite,mysql,postgresql" --release & >/dev/null
DIR = /usr/bin/vaultwarden
if [ -d " $DIR " ] ; then
cp target/release/vaultwarden /usr/bin/
else
cp target/release/vaultwarden /opt/vaultwarden/bin/
fi
msg_ok "Updated VaultWarden"
msg_info "Cleaning up"
cd ~ && rm -rf vaultwarden
msg_ok "Cleaned"
msg_info "Starting Vaultwarden"
systemctl start vaultwarden.service
msg_ok "Started Vaultwarden"
msg_ok " $VAULT Update Successful "
echo -e "\n ⚠️ Ensure you set resources back to normal settings \n"
exit
fi
if [ " $UPD " = = "2" ] ; then
msg_info "Stopping Vaultwarden"
systemctl stop vaultwarden.service
msg_ok "Stopped Vaultwarden"
msg_info " Updating Web-Vault to $WVRELEASE "
curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$WVRELEASE /bw_web_$WVRELEASE .tar.gz & >/dev/null
tar -zxf bw_web_$WVRELEASE .tar.gz -C /opt/vaultwarden/ & >/dev/null
msg_ok "Updated Web-Vault"
msg_info "Cleaning up"
rm bw_web_$WVRELEASE .tar.gz
msg_ok "Cleaned"
msg_info "Starting Vaultwarden"
systemctl start vaultwarden.service
msg_ok "Started Vaultwarden"
msg_ok " $WVRELEASE Update Successful "
exit
fi
if [ " $UPD " = = "3" ] ; then
2023-09-09 05:13:17 -04:00
if NEWTOKEN = $( whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "Set the ADMIN_TOKEN" 10 58 3>& 1 1>& 2 2>& 3) ; then
2023-04-09 23:45:57 -04:00
if [ [ -z " $NEWTOKEN " ] ] ; then exit; 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)
2024-07-17 13:48:42 -04:00
sed -i " s|ADMIN_TOKEN=.*|ADMIN_TOKEN=' ${ TOKEN } '| " /opt/vaultwarden/.env
if [ [ -f /opt/vaultwarden/data/config.json ] ] ; then
sed -i " s|\"admin_token\":.*|\"admin_token\": \" ${ TOKEN } \"| " /opt/vaultwarden/data/config.json
fi
2023-04-09 23:45:57 -04:00
systemctl restart vaultwarden
2023-03-22 20:48:20 -04:00
fi
exit
fi
}
start
build_container
description
msg_info "Setting Container to Normal Resources"
pct set $CTID -memory 512
pct set $CTID -cores 1
msg_ok "Set Container to Normal Resources"
msg_ok "Completed Successfully!\n"
echo -e " ${ APP } should be reachable by going to the following URL.
${ BL } http://${ IP } :8000${ CL } \n "