From bdee71bc743a5eee9d0700dfd25c8376c754cfbc Mon Sep 17 00:00:00 2001 From: tteckster Date: Sun, 17 Jul 2022 16:34:23 -0400 Subject: [PATCH] Fix Vaultwarden/Web-vault Update scripts (#355) * Update and rename vaultwarden-update.sh to web-vault-update.sh * Create vaultwarden-update.sh * Update web-vault-update.sh * Update web-vault-update.sh * Update web-vault-update.sh * Update web-vault-update.sh * Update web-vault-update.sh * Update vaultwarden-update.sh * Update README.md * Update CHANGELOG.MD * Update vaultwarden-update.sh * Update vaultwarden-update.sh * Update README.md * Update vaultwarden-update.sh * Update vaultwarden-update.sh --- CHANGELOG.MD | 8 ++++++ README.md | 12 ++++++--- misc/vaultwarden-update.sh | 31 ++++++++++++----------- misc/web-vault-update.sh | 50 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 misc/web-vault-update.sh diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 1455042f..8c231e81 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -3,6 +3,14 @@ # Change Log All notable changes to this project will be documented in this file. +## 2022-07-17 + +### Changed + +- **Vaultwarden LXC** + - NEW Vaultwarden Update (post 2022-05-29 only) Script + - NEW Web-vault Update (any) Script + ## 2022-07-14 ### Changed diff --git a/README.md b/README.md index 9d9fc2ad..cb04974f 100644 --- a/README.md +++ b/README.md @@ -1888,7 +1888,7 @@ ________________________________________________________________________________
- Vaultwarden LXC + 🔸Vaultwarden LXC

@@ -1909,19 +1909,25 @@ Expect 30+ minute install time.

⚡ Build Settings: 2048Mib RAM - 6GB Storage - 2vCPU ⚡

⚡ Normal Settings: 512Mib RAM - 6GB Storage - 1vCPU ⚡

-**Vaultwarden Interface - IP:8000** +**Vaultwarden Interface: CTIP:8000** ⚙️ **Path to Vaultwarden .env file** (to enable `ADMIN_TOKEN`) ```yaml /opt/vaultwarden/.env ``` -⚙️ **To Update Vaultwarden** +⚙️ **To Update Vaultwarden (post 2022-05-29 only)** Run in the LXC console ```yaml bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/vaultwarden-update.sh)" ``` +⚙️ **To Update Web-vault (any)** + +Run in the LXC console +```yaml +bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/misc/web-vault-update.sh)" +``` ____________________________________________________________________________________________ diff --git a/misc/vaultwarden-update.sh b/misc/vaultwarden-update.sh index 1a5e7a7d..b645e810 100644 --- a/misc/vaultwarden-update.sh +++ b/misc/vaultwarden-update.sh @@ -1,5 +1,5 @@ -#!/bin/sh -VWRELEASE=$(curl -s https://api.github.com/repos/dani-garcia/bw_web_builds/releases/latest \ +#!/usr/bin/env bash +VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \ | grep "tag_name" \ | awk '{print substr($2, 2, length($2)-3) }') \ @@ -16,13 +16,13 @@ echo -e "${BL} \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \ \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | | \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| - UPDATE + ${VAULT} UPDATE ${CL}" } update_info while true; do - read -p "This will Update Vaultwarden to $VWRELEASE. Proceed(y/n)?" yn + read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn case $yn in [Yy]* ) break;; [Nn]* ) exit;; @@ -34,18 +34,17 @@ echo -e "${GN} Stopping Vaultwarden... ${CL}" systemctl stop vaultwarden.service sleep 1 -echo -e "${GN} Updating to ${VWRELEASE}... ${CL}" -curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$VWRELEASE/bw_web_$VWRELEASE.tar.gz &>/dev/null -if [ -d "/var/lib/vaultwarden" ]; then -tar -xzf bw_web_$VWRELEASE.tar.gz -C /var/lib/vaultwarden/ &>/dev/null -else -tar -zxf bw_web_$VWRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null -fi +echo -e "${GN} Updating (Building) to ${VAULT} (Patience)... ${CL}" +git clone https://github.com/dani-garcia/vaultwarden &>/dev/null +cd vaultwarden +cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null +cp target/release/vaultwarden /opt/vaultwarden/bin/ -echo -e "${GN} Cleaning up... ${CL}" -rm bw_web_$VWRELEASE.tar.gz - -echo -e "${GN} Starting Vaultwarden... ${CL}" +echo -e "${GN} Starting Vaultwarden ${VAULT}... ${CL}" systemctl start vaultwarden.service sleep 1 -echo -e "${GN} Finished Update ${CL}" + +echo -e "${GN} Cleaning up... ${CL}" +cd ~ && rm -rf vaultwarden + +echo -e "${GN} Finished Update (set resources back to normal settings)${CL}" diff --git a/misc/web-vault-update.sh b/misc/web-vault-update.sh new file mode 100644 index 00000000..d55b0aeb --- /dev/null +++ b/misc/web-vault-update.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +VWRELEASE=$(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) }') \ + +RD=`echo "\033[01;31m"` +BL=`echo "\033[36m"` +CM='\xE2\x9C\x94\033' +GN=`echo "\033[1;92m"` +CL=`echo "\033[m"` +function update_info { +echo -e "${BL} + __ __ _ _ _ + \ \ / / | | | | | + \ \ /\ / /__| |__ ________ ____ _ _ _| | |_ + \ \/ \/ / _ \ _ \______\ \ / / _ | | | | | __| + \ /\ / __/ |_) | \ V / (_| | |_| | | |_ + \/ \/ \___|_.__/ \_/ \__,_|\__,_|_|\__| + ${VWRELEASE} UPDATE +${CL}" +} +update_info +while true; do + read -p "This will Update Web-Vault to $VWRELEASE. Proceed(y/n)?" yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac +done +sleep 2 +echo -e "${GN} Stopping Vaultwarden... ${CL}" +systemctl stop vaultwarden.service +sleep 1 + +echo -e "${GN} Updating to ${VWRELEASE}... ${CL}" +curl -fsSLO https://github.com/dani-garcia/bw_web_builds/releases/download/$VWRELEASE/bw_web_$VWRELEASE.tar.gz &>/dev/null +if [ -d "/var/lib/vaultwarden" ]; then +tar -xzf bw_web_$VWRELEASE.tar.gz -C /var/lib/vaultwarden/ &>/dev/null +else +tar -zxf bw_web_$VWRELEASE.tar.gz -C /opt/vaultwarden/ &>/dev/null +fi + +echo -e "${GN} Cleaning up... ${CL}" +rm bw_web_$VWRELEASE.tar.gz + +echo -e "${GN} Starting Vaultwarden... ${CL}" +systemctl start vaultwarden.service +sleep 1 +echo -e "${GN} Finished Update ${CL}"