Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Add installation options to etcd_install.sh #79

Merged
merged 1 commit into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language:
- java
before_install:
- ./src/main/bash/etcd_install.sh ./etcd-dist
- ./src/main/bash/etcd_install.sh -p ./etcd-dist
script:
- ./src/main/bash/etcd_run.sh ./etcd-dist
- ./gradlew build
Expand Down
87 changes: 59 additions & 28 deletions src/main/bash/etcd_install.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,63 @@
#!/usr/bin/env bash

if [ $# -eq 1 ]; then

ETCD_PATH=$1
ETCD_URL="https://github.com/coreos/etcd/releases/download"
ETCD_VER="v2.2.4"
ETCD_ARC="linux-amd64"

# cleanup
rm -rf ${ETCD_PATH}/etcd-${ETCD_VER}-${ETCD_ARC}.tar.gz
rm -rf ${ETCD_PATH}/etcd-${ETCD_VER}-${ETCD_ARC}
rm -rf ${ETCD_PATH}/etcd
rm -rf ${ETCD_PATH}/default.etcd

if [ ! -d ${ETCD_PATH} ]; then
mkdir ${ETCD_PATH}
fi

# install etcd
curl -L ${ETCD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-${ETCD_ARC}.tar.gz \
| tar xzf - \
--directory ${ETCD_PATH} \
--strip-components=1

# check
${ETCD_PATH}/etcd --version
else
echo "Installation path is missing"
exit -1
DEFAULT_ETCD_VERSION="2.2.4"

function usage {
cat <<-END >&2
USAGE: $0 [-p ETCD_PATH] [-v ETCD_VERSION]
-p ETCD_PATH # Etcd installation path
-v ETCD_VERSION # Etcd version, default ${DEFAULT_ETCD_VERSION}
-h # this usage message
END
exit
}

################################################################################
#
################################################################################

while getopts p:v:h opt
do
case $opt in
p) export ETCD_PATH=$OPTARG ;;
v) export ETCD_VERSION=$OPTARG ;;
h|?) usage ;;
esac
done

shift $(( $OPTIND - 1 ))

if [[ ! $ETCD_PATH ]]; then
echo "Warning, ETCD_PATH is required"
usage
fi

if [[ ! $ETCD_VERSION ]]; then
ETCD_VERSION=${DEFAULT_ETCD_VERSION}
fi

################################################################################
#
################################################################################

ETCD_URL="https://github.com/coreos/etcd/releases/download"
ETCD_ARC="linux-amd64"

# cleanup
rm -rf ${ETCD_PATH}/etcd-v${ETCD_VERSION}-${ETCD_ARC}.tar.gz
rm -rf ${ETCD_PATH}/etcd-v${ETCD_VERSION}-${ETCD_ARC}
rm -rf ${ETCD_PATH}/etcd
rm -rf ${ETCD_PATH}/default.etcd

if [ ! -d ${ETCD_PATH} ]; then
mkdir ${ETCD_PATH}
fi

# install etcd
curl -L ${ETCD_URL}/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${ETCD_ARC}.tar.gz \
| tar xzf - \
--directory ${ETCD_PATH} \
--strip-components=1

# check
${ETCD_PATH}/etcd --version