Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #243 from ContainerSolutions/refactoring/installer…
Browse files Browse the repository at this point in the history
…-enhancements

Refactoring: installer enhancements
  • Loading branch information
sadovnikov committed Feb 19, 2016
2 parents 884532d + e63727c commit 951ea8e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 28 deletions.
36 changes: 15 additions & 21 deletions bin/install
@@ -1,48 +1,42 @@
#!/bin/bash
#!/bin/sh

# This script is meant for quick & easy install via:
# `sudo curl -sSL https://raw.githubusercontent.com/ContainerSolutions/minimesos/master/bin/install | bash`
#
# Uses the latest release, unless a version identifier is specified as a parameter of this script.

command_exists() {
command -v "$@" > /dev/null 2>&1
command -v "$@" > /dev/null 2>&1
}

install_version() {
echo "Using $1 to install minimesos $2"
curl -sSL $1 | bash -s $2
curl -sSL $1 | sh -s $2
}

if ! command_exists curl; then
echo "Please install curl to fetch the minimesos files"
exit 1
echo "Please install curl to fetch the minimesos files"
exit 1
fi

VERSION=$(echo $@ | xargs)

if [ -z "$VERSION" ]; then
MAVEN_METADATA=$(curl -s https://jitpack.io/com/github/ContainerSolutions/minimesos/maven-metadata.xml)
VERSION=$(echo "$MAVEN_METADATA" | awk -F '[<>]' '/release/{print $3}')
if [ ! "$VERSION" ]; then
echo "Cannot determine latest release of minimesos"
exit 1
fi
MAVEN_METADATA=$(curl -s https://jitpack.io/com/github/ContainerSolutions/minimesos/maven-metadata.xml)
VERSION=$(echo "$MAVEN_METADATA" | awk -F '[<>]' '/release/{print $3}')
if [ ! "$VERSION" ]; then
echo "Cannot determine latest release of minimesos"
exit 1
fi
fi

curl -sSL -X HEAD https://jitpack.io/com/github/ContainerSolutions/minimesos/$VERSION/pom

# invoking versioned installation script
echo "Installing minimesos $VERSION"
SCRIPT_PATH=https://raw.githubusercontent.com/ContainerSolutions/minimesos/$VERSION
httpcode=$(curl -s -o /dev/null -I -w '%{http_code}' --max-time 1 $SCRIPT_PATH/bin/install-version || echo "404" )
if [ $httpcode -eq 200 ]; then
install_version $SCRIPT_PATH/bin/install-version $VERSION
install_version $SCRIPT_PATH/bin/install-version $VERSION
else
# initial version of minimesos used single install script
install_version $SCRIPT_PATH/bin/install $VERSION
echo "Failed to pull installer off github.com (http err: ${httpcode}), please try again."
exit 1
fi

echo "Done"

exit 0
exit 0
22 changes: 15 additions & 7 deletions bin/install-version
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh

# This script is meant to be invoked with VERSION given as a parameter.
# Installs the given version of minimesos on the box

command_exists() {
command -v "$@" > /dev/null 2>&1
command -v "$@" > /dev/null 2>&1
}

if ! command_exists curl; then
Expand All @@ -17,12 +17,20 @@ if [ ! "$#" -eq 1 ]; then
exit 1
fi

INSTALL_LOCATION=$HOME/.minimesos/bin
VERSION=$1
echo "VERSION GIVEN IS " $VERSION

curl -sSL https://raw.githubusercontent.com/ContainerSolutions/minimesos/$VERSION/bin/minimesos > /usr/local/bin/minimesos
chmod +x /usr/local/bin/minimesos
echo "Installing version " $VERSION
mkdir -p $INSTALL_LOCATION
curl -sSL https://raw.githubusercontent.com/ContainerSolutions/minimesos/$VERSION/bin/minimesos > $INSTALL_LOCATION/minimesos
chmod +x $INSTALL_LOCATION/minimesos

if [ -f "/usr/local/bin/minimesos" ]; then
echo "Found an old version of minimesos, please remove it:" && echo
echo "rm -f /usr/local/bin/minimesos" && echo
fi

# TODO: pull docker image from Docker Hub
echo "minimesos is installed into ${INSTALL_LOCATION}/minimesos"
echo "Run the following command to add it to your executables path:" && echo
echo "export PATH=\$PATH:$INSTALL_LOCATION"

exit 0

0 comments on commit 951ea8e

Please sign in to comment.