Browse Source

chg: dev: [install.sh] refactor out the fetching of binary !minor

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
pull/1/head
Valentin Lab 5 years ago
parent
commit
90cf26ba43
  1. 50
      src/install.sh

50
src/install.sh

@ -215,6 +215,32 @@ get_charm_store() {
}
fetch_binary() {
local url="$1" name="$2" bin_path tmpfile
mkdir -p "$BIN_PATH" || return 1
info "Downloading '$name'..."
(
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.)"
else
mv "$tmpfile" "$BIN_PATH/$name"
echo " .. Done !"
fi
) || return 1
hash -r
if bin_path=$(type -p "$name"); then
if [ "$bin_path" != "$BIN_PATH/$name" ]; then
warn "Found a '$name' in \$PATH at '$bin_path'." \
$'\n'" That doesn't match expected location '$BIN_PATH/$name'." \
$'\n'" You might need to change you \$PATH to include '$BIN_PATH' before '${bin_path%/*}'."
fi
fi
}
install.linux() {
depends docker curl git
@ -230,29 +256,7 @@ install.linux() {
COMPOSE_OPTION_FILE=/etc/compose/local.conf
fi
## COMPOSE
if compose=$(type -p "compose"); then
if [ "$compose" != "$BIN_PATH/compose" ]; then
warn "Found a 'compose' in \$PATH at '$compose' that doesn't match expected compose location '$BIN_PATH/compose'." \
"Not doing anything."
elif [ -L "$compose" ]; then
warn "Found a 'compose' at '$compose' that is a link. " \
"Not doing anything."
else
compose="" ## force overwrite
fi
fi
if [ -z "$compose" ]; then
mkdir -p "$BIN_PATH" || exit 1
info "Downloading 'compose'..."
(
set +x
curl -sS https://git.0k.io/0k-compose.git/plain/bin/compose > /tmp/compose
chmod -v +x /tmp/compose
mv -v /tmp/compose "$BIN_PATH/"
) || exit 1
echo " .. Done !"
fi
fetch_binary https://git.0k.io/0k-compose.git/plain/bin/compose compose
if [[ ":$PATH:" != *":$BIN_PATH:"* ]]; then
warn "Please ensure that '$BIN_PATH' is in your \$PATH to ensure" \

Loading…
Cancel
Save