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.

68 lines
2.0 KiB

6 years ago
6 years ago
6 years ago
  1. #!/bin/bash
  2. . /etc/shlib
  3. include parse
  4. include common
  5. include pretty
  6. start=$SECONDS
  7. if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then
  8. MYC_UPDATE_VERSION="${MYC_UPDATE_VERSION:-master}"
  9. Elt "Checking if myc-manage requires update..."
  10. cd /opt/apps/myc-manage
  11. REMOTE_HEAD="$(git ls-remote origin "refs/heads/${MYC_UPDATE_VERSION}" 2>/dev/null | cut -f 1)"
  12. if [ -z "$REMOTE_HEAD" ]; then
  13. err "Can't find remote branch '$MYC_UPDATE_VERSION'."
  14. echo " - Either this branch is not available on 'origin' remote." >&2
  15. echo " - Either 'origin' remote is not correctly set." >&2
  16. exit 1
  17. fi
  18. HEAD="$(git rev-parse HEAD)"
  19. if [ "$REMOTE_HEAD" != "$HEAD" ]; then
  20. print_info "new version available"
  21. Wrap -d "Update myc-manage" <<EOF || exit 1
  22. if ! [ -d "/opt/apps/myc-manage" ]; then
  23. mkdir -p /opt/apps && cd /opt/apps
  24. git clone https://git.myceliandre.fr/Myceliandre/myc-manage.git -b "$MYC_UPDATE_VERSION"
  25. else
  26. cd /opt/apps/myc-manage &&
  27. git checkout "$MYC_UPDATE_VERSION" &&
  28. git pull -r || exit 1
  29. fi
  30. ln -sfn /opt/apps/myc-manage/bin/* /usr/local/sbin/
  31. find -L /usr/local/sbin -maxdepth 1 -type l -ilname /opt/apps/myc-manage/bin/\* -delete
  32. EOF
  33. Feed || exit 1
  34. export NO_UPDATE=1
  35. exec myc-update
  36. exit 0
  37. else
  38. print_info "up to date"
  39. Feedback noop
  40. fi
  41. fi
  42. Wrap -d "Updating 0k-charms" <<EOF || exit 1
  43. cd /opt/apps/0k-charms
  44. git pull -r
  45. EOF
  46. charm --debug apply docker-host || exit 1
  47. ## there seem to be an error now within compose when trying to download let's encrypt image.
  48. Wrap -d "Updating some docker images" <<EOF || exit 1
  49. docker pull docker.0k.io/letsencrypt
  50. EOF
  51. Wrap -d "Updating cron scripts" <<EOF || exit 1
  52. ln -sfn /opt/apps/myc-manage/etc/cron.d/* /etc/cron.d/
  53. find -L /etc/cron.d -maxdepth 1 -type l -ilname /opt/apps/myc-manage/etc/cron.d/\* -delete
  54. EOF
  55. printf "Update finished ${GREEN}successfully${NORMAL} ${GRAY}(in %.2fs)${NORMAL}.\n" "$((SECONDS - start))"