|
|
@ -152,16 +152,23 @@ install_file() { |
|
|
|
get_charm_store() { |
|
|
|
local branch="${1:master}" |
|
|
|
if ! [ -d "$CHARM_PATH" ]; then |
|
|
|
echo "Creating charm-store in '$CHARM_PATH'." |
|
|
|
git clone https://git.0k.io/0k-charms.git -b "$branch" "$CHARM_PATH" || exit 1 |
|
|
|
info "Creating charm-store in '$CHARM_PATH'.." |
|
|
|
git clone https://git.0k.io/0k-charms.git -b "$branch" "$CHARM_PATH" || { |
|
|
|
echo " .. ${RED}Failed${NORMAL}." >&2 |
|
|
|
return 1 |
|
|
|
} |
|
|
|
echo " .. ${GREEN}Done${NORMAL}." >&2 |
|
|
|
else |
|
|
|
echo "Updating existing charm-store in '$CHARM_PATH'." |
|
|
|
info "Updating existing charm-store in '$CHARM_PATH'." |
|
|
|
cd "$CHARM_PATH" || exit 1 |
|
|
|
git fetch && |
|
|
|
git checkout "$branch" && |
|
|
|
git pull -r || { |
|
|
|
warn "Could not update charm-store, do you have devs ingoing ?" |
|
|
|
echo " .. ${BLUE}No action${NORMAL}." >&2 |
|
|
|
return 0 |
|
|
|
} |
|
|
|
echo " .. ${GREEN}Done${NORMAL}." >&2 |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
@ -173,12 +180,20 @@ fetch_binary() { |
|
|
|
( |
|
|
|
tmpfile=$(mktemp) && trap "rm -f '$tmpfile'" EXIT && |
|
|
|
curl -sS "$url" > "$tmpfile" && |
|
|
|
chmod +x "$tmpfile" |
|
|
|
if [ -e "$BIN_PATH/$name" ] && diff "$tmpfile" "$BIN_PATH/$name"; then |
|
|
|
echo " .. Done (File '$BIN_PATH/$name' was already up to date.)" |
|
|
|
chmod +x "$tmpfile" || { |
|
|
|
echo " .. ${RED}Failed${NORMAL}." >&2 |
|
|
|
return 1 |
|
|
|
} |
|
|
|
if [[ "$(cat "$tmpfile")" == "<!DOCTYPE html>"* ]]; then |
|
|
|
echo " $GRAY|$NORMAL fetching: $url" >&2 |
|
|
|
echo " .. ${RED}Failed${NORMAL} (fetched content is HTML !?!)." >&2 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
if [ -e "$BIN_PATH/$name" ] && diff "$tmpfile" "$BIN_PATH/$name" >/dev/null; then |
|
|
|
echo " .. ${GREEN}Done${NORMAL} (File '$BIN_PATH/$name' was already up to date.)" >&2 |
|
|
|
else |
|
|
|
mv "$tmpfile" "$BIN_PATH/$name" |
|
|
|
echo " .. Done !" |
|
|
|
mv "$tmpfile" "$BIN_PATH/$name" && |
|
|
|
echo " .. ${GREEN}Done${NORMAL}." >&2 |
|
|
|
fi |
|
|
|
) || return 1 |
|
|
|
hash -r |
|
|
@ -212,17 +227,17 @@ install.linux() { |
|
|
|
COMPOSE_OPTION_FILE=/etc/compose/local.conf |
|
|
|
fi |
|
|
|
|
|
|
|
fetch_binary https://git.0k.io/0k-compose.git/plain/bin/compose?h="${DEPLOY_REF}" compose |
|
|
|
get_docker_ip |
|
|
|
fetch_binary "https://git.0k.io/0k-compose.git/plain/bin/compose?h=${DEPLOY_REF}" compose || return 1 |
|
|
|
get_docker_ip || return 1 |
|
|
|
|
|
|
|
if [[ ":$PATH:" != *":$BIN_PATH:"* ]]; then |
|
|
|
warn "Please ensure that '$BIN_PATH' is in your \$PATH to ensure" \ |
|
|
|
"the simple usage of 'compose' command." |
|
|
|
fi |
|
|
|
|
|
|
|
get_charm_store "${DEPLOY_REF}" || exit 1 |
|
|
|
get_charm_store "${DEPLOY_REF}" || return 1 |
|
|
|
|
|
|
|
cat <<EOF | install_file "$COMPOSE_OPTION_FILE" |
|
|
|
cat <<EOF | install_file "$COMPOSE_OPTION_FILE" || return 1 |
|
|
|
#CHARM_STORE=$CHARM_STORE |
|
|
|
COMPOSE_DOCKER_IMAGE=docker.0k.io/compose:${DEPLOY_REF//\//-} |
|
|
|
|
|
|
|