Merge pull request #165 from mesosphere/install-scripts
Add install scripts to repo
This commit is contained in:
86
bin/install/install-dcos-cli.ps1
Normal file
86
bin/install/install-dcos-cli.ps1
Normal file
@@ -0,0 +1,86 @@
|
||||
param([Parameter(Mandatory=$true,ValueFromPipeline=$true)]
|
||||
[string]
|
||||
$installation_path,
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
|
||||
[string]
|
||||
$marathon_host,
|
||||
[int]
|
||||
$marathon_port=8080
|
||||
)
|
||||
|
||||
if (-Not(Get-Command python -errorAction SilentlyContinue))
|
||||
{
|
||||
echo "The program 'python' could not be found. Make sure that 'python' is installed and that its directory is included in the PATH system variable."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-Not(Get-Command pip -errorAction SilentlyContinue))
|
||||
{
|
||||
echo "The program 'pip' could not be found. Make sure that 'pip' is installed and that its directory (eg 'C:\Python27\Scripts') is included in the PATH system variable."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-Not(Get-Command virtualenv -errorAction SilentlyContinue))
|
||||
{
|
||||
echo "The program 'virtualenv' could not be found. Make sure that it has been installed with the 'pip' Python package program."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$VIRTUAL_ENV_VERSION = (virtualenv --version)
|
||||
|
||||
$VIRTUAL_ENV_VERSION -match "[0-9]+"
|
||||
|
||||
if ($matches[0] -lt 12) {
|
||||
echo "Virtualenv version must be 12 or greater. Aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-Not(Get-Command git -errorAction SilentlyContinue))
|
||||
{
|
||||
echo "The program 'git' could not be found. Make sure that 'git' is installed and that its directory is included in the PATH system variable."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo "Installing DCOS CLI from PyPI..."
|
||||
echo ""
|
||||
|
||||
if (-Not([System.IO.Path]::IsPathRooted("$installation_path"))) {
|
||||
$installation_path = Join-Path (pwd) $installation_path
|
||||
}
|
||||
|
||||
if (-Not( Test-Path $installation_path)) {
|
||||
mkdir $installation_path
|
||||
}
|
||||
|
||||
& virtualenv $installation_path
|
||||
& $installation_path\Scripts\activate
|
||||
& $installation_path\Scripts\easy_install "http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20219/pywin32-219.win32-py2.7.exe?r=&ts=1429187018&use_mirror=heanet" 2>&1 | out-null
|
||||
|
||||
if ($env:DCOS_CLI_VERSION) {
|
||||
& $installation_path\Scripts\pip install --quiet "dcoscli==$env:DCOS_CLI_VERSION"
|
||||
} else {
|
||||
& $installation_path\Scripts\pip install --quiet "dcoscli"
|
||||
}
|
||||
|
||||
|
||||
[Environment]::SetEnvironmentVariable("Path", "$installation_path\Scripts\;", "User")
|
||||
$env:Path="$env:Path;$installation_path\Scripts\"
|
||||
|
||||
$DCOS_CONFIG="$env:USERPROFILE\.dcos\dcos.toml"
|
||||
|
||||
if (-Not(Test-Path $DCOS_CONFIG)) {
|
||||
mkdir "$env:USERPROFILE\.dcos"
|
||||
New-Item $DCOS_CONFIG -type file
|
||||
}
|
||||
[Environment]::SetEnvironmentVariable("DCOS_CONFIG", "$DCOS_CONFIG", "User")
|
||||
$env:DCOS_CONFIG = $DCOS_CONFIG
|
||||
|
||||
dcos config set core.reporting true
|
||||
dcos config set marathon.host $marathon_host
|
||||
dcos config set marathon.port $marathon_port
|
||||
dcos config set package.cache $env:temp\dcos\package-cache
|
||||
dcos config set package.sources '[\"https://github.com/mesosphere/universe/archive/master.zip\"]'
|
||||
|
||||
dcos package update
|
||||
58
bin/install/install-dcos-cli.sh
Executable file
58
bin/install/install-dcos-cli.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit -o pipefail
|
||||
|
||||
usage()
|
||||
{ # Show usage information.
|
||||
echo "$(basename "$(test -L "$0" && readlink "$0" || echo "$0")") <installation_path> <marathon_host> [<marathon_port>]"
|
||||
}
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
usage;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
ARGS=( "$@" );
|
||||
|
||||
VIRTUAL_ENV_PATH=$(python -c "import os; print(os.path.realpath('"${ARGS[0]}"'))")
|
||||
MARATHON_HOST=${ARGS[1]}
|
||||
MARATHON_PORT=${ARGS[2]:-8080}
|
||||
|
||||
command -v virtualenv >/dev/null 2>&1 || { echo "Cannot find virtualenv. Aborting."; exit 1; }
|
||||
|
||||
VIRTUALENV_VERSION=$(virtualenv --version)
|
||||
VERSION_REGEX="s#[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)#\1#"
|
||||
|
||||
eval MAJOR=`echo $VIRTUALENV_VERSION | sed -e $VERSION_REGEX`
|
||||
if [ $MAJOR -lt 12 ];
|
||||
then echo "Virtualenv version must be 12 or greater. Aborting.";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "Installing DCOS CLI from PyPI...";
|
||||
echo "";
|
||||
|
||||
# Let's first setup a virtualenv: we are assuming that the path is absolute
|
||||
mkdir -p "$VIRTUAL_ENV_PATH"
|
||||
virtualenv "$VIRTUAL_ENV_PATH"
|
||||
|
||||
# Install the DCOS CLI package, using version if set
|
||||
if [ -z "$DCOS_CLI_VERSION" ]; then
|
||||
"$VIRTUAL_ENV_PATH/bin/pip" install --quiet "dcoscli"
|
||||
else
|
||||
"$VIRTUAL_ENV_PATH/bin/pip" install --quiet "dcoscli==$DCOS_CLI_VERSION"
|
||||
fi
|
||||
|
||||
ENV_SETUP="$VIRTUAL_ENV_PATH/bin/env-setup"
|
||||
source "$ENV_SETUP"
|
||||
dcos config set core.reporting true
|
||||
dcos config set marathon.host $MARATHON_HOST
|
||||
dcos config set marathon.port $MARATHON_PORT
|
||||
dcos config set package.cache ~/.dcos/cache
|
||||
dcos config set package.sources '["https://github.com/mesosphere/universe/archive/master.zip"]'
|
||||
dcos package update
|
||||
|
||||
echo "Finished installing and configuring DCOS CLI."
|
||||
echo "Run the line below to set up the DCOS environment for the current shell:"
|
||||
echo "source $ENV_SETUP"
|
||||
echo "Once this is done, run 'dcos help' to get started."
|
||||
Reference in New Issue
Block a user