Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
[#97969662] Fix install script for Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmm80 committed Jul 1, 2015
1 parent f69d58d commit b7bf8f7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
_site
.vagrant
Vagrantfile
git
pkg/*
provider/provider
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vagrant
_site
Godeps/_workspace/src/github.com/jstemmer/
test.rb
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Note that summon is still in **early stages**, we are looking for feedback and c
## Install

If you're on Linux or OSX, use the install script. This will install the latest
version of summon.
version of summon. The script requires sudo to place summon in `/usr/local/bin`.

```
curl -sSL https://raw.githubusercontent.com/conjurinc/summon/master/install.sh | sudo bash
curl -sSL https://raw.githubusercontent.com/conjurinc/summon/master/install.sh | bash
```

Otherwise, download the [latest release](https://github.com/conjurinc/summon/releases/latest) and unzip it to a location on your PATH.
Expand Down
3 changes: 3 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
end
44 changes: 39 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -e

if [[ ! $(type -t unzip) ]]; then
echo "unzip is not installed, please install to continue"
exit 1
fi

ARCH=`uname -m`

if [ "${ARCH}" != "x86_64" ]; then
Expand All @@ -18,16 +23,45 @@ if [ "${DISTRO}" != "linux" ] && [ "${DISTRO}" != "darwin" ]; then
exit 1
fi

LATEST_VERSION=`curl -sSL https://raw.githubusercontent.com/conjurinc/summon/master/version.go | grep -o -e "\d.\d.\d"`
if test "x$TMPDIR" = "x"; then
tmp="/tmp"
else
tmp=$TMPDIR
fi
# secure-ish temp dir creation without having mktemp available (DDoS-able but not expliotable)
tmp_dir="$tmp/install.sh.$$"
(umask 077 && mkdir $tmp_dir) || exit 1

# do_download URL DIR
function do_download(){
echo "Downloading $1"
if [[ $(type -t wget) ]]; then wget -q -c -O "$2" "$1" >/dev/null
elif [[ $(type -t curl) ]]; then curl -sSL -C -o "$2" "$1"
else
error "Could not find wget or curl"
return 1
fi
}

# get_latest_version URL
get_latest_version() {
versionloc=${tmp_dir}/summon.version
versionfile=$(do_download ${1} ${versionloc})
local version=$(cat ${versionloc} | grep -o -e "[[:digit:]].[[:digit:]]*.[[:digit:]]*")
echo "${version}"
}

LATEST_VERSION=$(get_latest_version 'https://raw.githubusercontent.com/conjurinc/summon/master/version.go')
BASEURL="https://github.com/conjurinc/summon/releases/download/"
URL=${BASEURL}"v${LATEST_VERSION}/summon_v${LATEST_VERSION}_${DISTRO}_amd64.zip"

echo "Installing summon v${LATEST_VERSION} into /usr/local/bin"

ZIP_PATH="/tmp/summon.zip"
curl -sSL $URL -o ${ZIP_PATH}
ZIP_PATH="${tmp_dir}/summon.zip"
do_download ${URL} ${ZIP_PATH}

echo "Installing summon v${LATEST_VERSION} into /usr/local/bin"

unzip -q -o ${ZIP_PATH} -d /usr/local/bin
sudo unzip -q -o ${ZIP_PATH} -d /usr/local/bin

echo "Success!"
echo "Run summon -h for usage"

0 comments on commit b7bf8f7

Please sign in to comment.