vaultwarden-update.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. VAULT=$(curl -s https://api.github.com/repos/dani-garcia/vaultwarden/releases/latest \
  3. | grep "tag_name" \
  4. | awk '{print substr($2, 2, length($2)-3) }') \
  5. RD=`echo "\033[01;31m"`
  6. BL=`echo "\033[36m"`
  7. CM='\xE2\x9C\x94\033'
  8. GN=`echo "\033[1;92m"`
  9. CL=`echo "\033[m"`
  10. function update_info {
  11. echo -e "${BL}
  12. __ __ _ _ _
  13. \ \ / / | | | | |
  14. \ \ / /_ _ _ _| | |___ ____ _ _ __ __| | ___ _ __
  15. \ \/ / _ | | | | | __\ \ /\ / / _ | __/ _ |/ _ \ _ \
  16. \ / (_| | |_| | | |_ \ V V / (_| | | | (_| | __/ | | |
  17. \/ \__,_|\__,_|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_|
  18. ${VAULT} UPDATE
  19. ${CL}"
  20. }
  21. update_info
  22. while true; do
  23. read -p "This will Update Vaultwarden to $VAULT (set 2vCPU 2048MiB RAM Min.). Proceed(y/n)?" yn
  24. case $yn in
  25. [Yy]* ) break;;
  26. [Nn]* ) exit;;
  27. * ) echo "Please answer yes or no.";;
  28. esac
  29. done
  30. sleep 2
  31. echo -e "${GN} Stopping Vaultwarden... ${CL}"
  32. systemctl stop vaultwarden.service
  33. sleep 1
  34. echo -e "${GN} Updating (Building) to ${VAULT} (Patience)... ${CL}"
  35. git clone https://github.com/dani-garcia/vaultwarden &>/dev/null
  36. cd vaultwarden
  37. cargo build --features "sqlite,mysql,postgresql" --release &>/dev/null
  38. cp target/release/vaultwarden /opt/vaultwarden/bin/
  39. echo -e "${GN} Starting Vaultwarden ${VAULT}... ${CL}"
  40. systemctl start vaultwarden.service
  41. sleep 1
  42. echo -e "${GN} Cleaning up... ${CL}"
  43. cd ~ && rm -rf vaultwarden
  44. echo -e "${GN} Finished Update (set resources back to normal settings)${CL}"