2022-07-17 20:34:23 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-10-30 01:04:45 +00:00
|
|
|
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) }')
|
2022-07-17 20:34:23 +00:00
|
|
|
|
2022-10-30 01:04:45 +00:00
|
|
|
RD=$(echo "\033[01;31m")
|
|
|
|
BL=$(echo "\033[36m")
|
2022-07-17 20:34:23 +00:00
|
|
|
CM='\xE2\x9C\x94\033'
|
2022-10-30 01:04:45 +00:00
|
|
|
GN=$(echo "\033[1;92m")
|
|
|
|
CL=$(echo "\033[m")
|
2022-07-17 20:34:23 +00:00
|
|
|
function update_info {
|
2022-10-30 01:04:45 +00:00
|
|
|
echo -e "${BL}
|
2022-07-17 20:34:23 +00:00
|
|
|
__ __ _ _ _
|
|
|
|
\ \ / / | | | | |
|
|
|
|
\ \ /\ / /__| |__ ________ ____ _ _ _| | |_
|
|
|
|
\ \/ \/ / _ \ _ \______\ \ / / _ | | | | | __|
|
|
|
|
\ /\ / __/ |_) | \ 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
|
2022-10-30 01:04:45 +00:00
|
|
|
[Yy]*) break ;;
|
|
|
|
[Nn]*) exit ;;
|
|
|
|
*) echo "Please answer yes or no." ;;
|
2022-07-17 20:34:23 +00:00
|
|
|
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
|
2022-10-30 01:04:45 +00:00
|
|
|
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
|
2022-07-17 20:34:23 +00:00
|
|
|
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}"
|