Browse Source

new: self-update before launching all updates.

This prevent the need for a double launch of update script.
rc1
Valentin Lab 5 years ago
parent
commit
a451e191df
  1. 37
      bin/pandachi-update

37
bin/pandachi-update

@ -7,15 +7,16 @@ include common
include pretty
Wrap -d "Updating 0k-charms" <<EOF || exit 1
cd /opt/apps/0k-charms
git pull -r
EOF
charm --debug apply docker-host
Wrap -d "Update pandachi-manage" <<EOF || exit 1
start=$SECONDS
if [ -z "$NO_UPDATE" -a -d "/opt/apps/pandachi-manage" ]; then
Elt "Checking if pandachi-manage requires update..."
cd /opt/apps/pandachi-manage
REMOTE_HEAD="$(git ls-remote origin refs/heads/master 2>/dev/null | cut -f 1)"
HEAD="$(git rev-parse HEAD)"
if [ "$REMOTE_HEAD" != "$HEAD" ]; then
print_info "new version available"
Wrap -d "Update pandachi-manage" <<EOF || exit 1
if ! [ -d "/opt/apps/pandachi-manage" ]; then
mkdir -p /opt/apps && cd /opt/apps
git clone git.0k.io:/var/git/0k/pandachi-manage.git
@ -29,9 +30,27 @@ ln -sfn /opt/apps/pandachi-manage/bin/* /usr/local/sbin/
find -L /usr/local/sbin -maxdepth 1 -type l -ilname /opt/apps/pandachi-manage/bin/\* -delete
EOF
Feed || exit 1
export NO_UPDATE=1
exec pandachi-update
exit 0
else
print_info "up to date"
Feedback noop
fi
fi
Wrap -d "Updating 0k-charms" <<EOF || exit 1
cd /opt/apps/0k-charms
git pull -r
EOF
charm --debug apply docker-host
## there seem to be an error now within compose when trying to download let's encrypt image.
Wrap -d "Updating some docker images" <<EOF || exit 1
docker pull docker.0k.io/letsencrypt
EOF
printf "Update finished ${GREEN}successfully${NORMAL} ${GRAY}(in %.2fs)${NORMAL}.\n" "$((SECONDS - start))"
Loading…
Cancel
Save