You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

3 years ago
3 years ago
3 years ago
  1. #!/bin/bash
  2. set -Eeuo pipefail
  3. if [[ -d /opt/debian-bash ]]; then
  4. local_release=$(cat /opt/debian-bash/.semver_git_tag)
  5. fi
  6. echo -n "debian-bash: collecting latest release from server url ... "
  7. remote_release=$(wget_semver artcode pvincent/debian-bash)
  8. echo -n "$remote_release"
  9. if [[ $local_release != $remote_release ]]; then
  10. echo " , upgrading from <$local_release> to <$remote_release> ..."
  11. curl https://git.artcode.re/pvincent/debian-bash/raw/branch/master/install.sh | sudo bash -s -- --full
  12. else
  13. echo " up-to-date!"
  14. # install inside active LXC containers
  15. if [[ -f '/snap/bin/lxc' ]]; then
  16. echo "debian-bash: refreshing containers ..."
  17. for container in $(lxc list --format=json | yq '.[] | select(.state.status == "Running") | .name' -); do
  18. container_release=$(lxc exec $container -- cat /opt/debian-bash/.semver_git_tag)
  19. if [[ $container_release != $remote_release ]]; then
  20. echo "upgrade container <$container> from <$container_release> to <$remote_release>"
  21. /snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r
  22. else
  23. echo -e "\\tcontainer <$container> already up-to-date!"
  24. fi
  25. done
  26. echo DONE
  27. fi
  28. fi