forked from Myceliandre/myc-manage
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.
69 lines
2.0 KiB
69 lines
2.0 KiB
#!/bin/bash
|
|
|
|
. /etc/shlib
|
|
|
|
include parse
|
|
include common
|
|
include pretty
|
|
|
|
|
|
start=$SECONDS
|
|
|
|
if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then
|
|
MYC_UPDATE_VERSION="${MYC_UPDATE_VERSION:-master}"
|
|
Elt "Checking if myc-manage requires update..."
|
|
cd /opt/apps/myc-manage
|
|
REMOTE_HEAD="$(git ls-remote origin "refs/heads/${MYC_UPDATE_VERSION}" 2>/dev/null | cut -f 1)"
|
|
if [ -z "$REMOTE_HEAD" ]; then
|
|
err "Can't find remote branch '$MYC_UPDATE_VERSION'."
|
|
echo " - Either this branch is not available on 'origin' remote." >&2
|
|
echo " - Either 'origin' remote is not correctly set." >&2
|
|
exit 1
|
|
fi
|
|
HEAD="$(git rev-parse HEAD)"
|
|
if [ "$REMOTE_HEAD" != "$HEAD" ]; then
|
|
print_info "new version available"
|
|
Wrap -d "Update myc-manage" <<EOF || exit 1
|
|
if ! [ -d "/opt/apps/myc-manage" ]; then
|
|
mkdir -p /opt/apps && cd /opt/apps
|
|
git clone https://git.myceliandre.fr/Myceliandre/myc-manage.git -b "$MYC_UPDATE_VERSION"
|
|
else
|
|
cd /opt/apps/myc-manage &&
|
|
git checkout "$MYC_UPDATE_VERSION" &&
|
|
git pull -r || exit 1
|
|
fi
|
|
|
|
ln -sfn /opt/apps/myc-manage/bin/* /usr/local/sbin/
|
|
find -L /usr/local/sbin -maxdepth 1 -type l -ilname /opt/apps/myc-manage/bin/\* -delete
|
|
EOF
|
|
|
|
Feed || exit 1
|
|
export NO_UPDATE=1
|
|
exec myc-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 || exit 1
|
|
|
|
## 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
|
|
|
|
Wrap -d "Updating cron scripts" <<EOF || exit 1
|
|
ln -sfn /opt/apps/myc-manage/etc/cron.d/* /etc/cron.d/
|
|
find -L /etc/cron.d -maxdepth 1 -type l -ilname /opt/apps/myc-manage/etc/cron.d/\* -delete
|
|
EOF
|
|
|
|
|
|
printf "Update finished ${GREEN}successfully${NORMAL} ${GRAY}(in %.2fs)${NORMAL}.\n" "$((SECONDS - start))"
|