Skip to content
Permalink
Browse files

Added Vagrant file and installation script for Mac OS X

  • Loading branch information...
Duco
Duco committed Feb 24, 2019
1 parent aeeac37 commit fcbab536b8c000d1fe44b03d064aeda34e138d0d
Showing with 65 additions and 0 deletions.
  1. +51 −0 scripts/install-mac.sh
  2. +14 −0 vagrant/mac/Vagrantfile
@@ -0,0 +1,51 @@
#!/bin/bash
set -e
set -u

# This is added to ensure that the whole script is downloaded before running it.
{
echo "Attempting to download and install HttPlaceholder"

JQ_URL="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64"
JQ_PATH="/tmp/jq"
if [ ! -f $JQ_PATH ]; then
echo "Attempting to download JQ from URL $JQ_URL to $JQ_PATH"
curl -J -L $JQ_URL --output $JQ_PATH
fi

chmod 755 $JQ_PATH

RELEASES_URL="https://api.github.com/repos/dukeofharen/httplaceholder/releases"
RELEASES_JSON=$(curl $RELEASES_URL)
TAG=$(echo "$RELEASES_JSON" | $JQ_PATH -r '.[0] | .tag_name')
echo "Latest version is $TAG"

DOWNLOAD_URL=$(echo "$RELEASES_JSON" | eval $JQ_PATH "-r '.[0] | .assets | .[] | select(.name | contains(\"osx\")) | .browser_download_url'")
echo "Download binaries from $DOWNLOAD_URL"
TAR_PATH="/tmp/httplaceholder.tar.gz"
curl -J -L $DOWNLOAD_URL --output $TAR_PATH

if [ ! -d "/usr/local/bin" ]; then
echo "Creating directory /usr/local/bin"
mkdir /usr/local/bin
fi

TAR_EXTRACT_LOCATION="/usr/local/bin/httplaceholder-stub"
echo "Extracting $TAR_PATH to $TAR_EXTRACT_LOCATION"
if [ -d "$TAR_EXTRACT_LOCATION" ]; then
echo "Deleting $TAR_EXTRACT_LOCATION"
rm -R $TAR_EXTRACT_LOCATION
fi

echo "Creating $TAR_EXTRACT_LOCATION"
mkdir $TAR_EXTRACT_LOCATION

tar -xvzf $TAR_PATH -C $TAR_EXTRACT_LOCATION

LN_PATH="/usr/local/bin/httplaceholder"
HTTPLACEHOLDER_BIN_PATH="$TAR_EXTRACT_LOCATION/HttPlaceholder"
echo "Creating symlink from $HTTPLACEHOLDER_BIN_PATH to $LN_PATH"
ln -s -f $HTTPLACEHOLDER_BIN_PATH $LN_PATH

echo "HttPlaceholder version $TAG is installed. Start application by running 'httplaceholder'."
}
@@ -0,0 +1,14 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.synced_folder "./../..", "/vagrant", type: "nfs"
config.vm.box = "jhcook/macos-sierra"
config.vm.network :forwarded_port, guest: 5000, host: 4567

config.vm.provider "virtualbox" do |vb, override|
vb.name = "vagrant-httplaceholder-mac"
vb.memory = "4096"
vb.cpus = 2
vb.gui = true
end
end

0 comments on commit fcbab53

Please sign in to comment.
You can’t perform that action at this time.