Proxmox/misc/vaultwarden-update.sh

51 lines
1.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \
2022-02-28 10:56:20 +00:00
| grep "tag_name" \
2022-08-23 13:04:51 +00:00
| awk '{print substr($2, 2, length($2)-3) }')
2022-02-28 10:56:20 +00:00
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 V / (_| | | | (_| | __/ | | |
\/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
${VAULT} UPDATE
2022-02-28 10:56:20 +00:00
${CL}"
}
update_info
while true; do
read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn
2022-02-28 10:56:20 +00:00
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
2022-03-26 15:34:12 +00:00
sleep 2
2022-02-28 15:06:48 +00:00
echo -e "${GN} Stopping Vaultwarden... ${CL}"
systemctl stop vaultwarden.service
2022-02-28 15:07:57 +00:00
sleep 1
2022-02-28 10:56:20 +00:00
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/
2022-02-28 15:06:48 +00:00
echo -e "${GN} Starting Vaultwarden ${VAULT}... ${CL}"
2022-02-28 15:06:48 +00:00
systemctl start vaultwarden.service
sleep 1
echo -e "${GN} Cleaning up... ${CL}"
cd ~ && rm -rf vaultwarden
echo -e "${GN} Finished Update (set resources back to normal settings)${CL}"