This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mahmood Ali
committed
Jan 26, 2019
1 parent
38791c4
commit cc6b2fd
Showing
7 changed files
with
242 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
# | ||
|
||
LINUX_BASE_BOX = "bento/ubuntu-16.04" | ||
|
||
Vagrant.configure(2) do |config| | ||
# Compilation and development boxes | ||
config.vm.define "linux", autostart: true, primary: true do |vmCfg| | ||
vmCfg.vm.box = LINUX_BASE_BOX | ||
vmCfg.vm.hostname = "linux" | ||
vmCfg = configureProviders vmCfg, | ||
cpus: suggestedCPUCores() | ||
|
||
vmCfg = configureLinuxProvisioners(vmCfg) | ||
|
||
vmCfg.vm.synced_folder '.', | ||
'/opt/gopath/src/github.com/hashicorp/nomad-driver-lxc' | ||
|
||
vmCfg.vm.provision "shell", | ||
privileged: false, | ||
path: './scripts/vagrant-linux-unpriv-bootstrap.sh' | ||
end | ||
end | ||
|
||
def configureLinuxProvisioners(vmCfg) | ||
vmCfg.vm.provision "shell", | ||
privileged: true, | ||
inline: 'rm -f /home/vagrant/linux.iso' | ||
|
||
vmCfg.vm.provision "shell", | ||
privileged: true, | ||
path: './scripts/vagrant-linux-priv-go.sh' | ||
|
||
vmCfg.vm.provision "shell", | ||
privileged: true, | ||
path: './scripts/vagrant-linux-priv-config.sh' | ||
|
||
return vmCfg | ||
end | ||
|
||
def configureProviders(vmCfg, cpus: "2", memory: "2048") | ||
vmCfg.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--cableconnected1", "on"] | ||
v.memory = memory | ||
v.cpus = cpus | ||
end | ||
|
||
["vmware_fusion", "vmware_workstation"].each do |p| | ||
vmCfg.vm.provider p do |v| | ||
v.enable_vmrun_ip_lookup = false | ||
v.vmx["memsize"] = memory | ||
v.vmx["numvcpus"] = cpus | ||
end | ||
end | ||
|
||
vmCfg.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--cableconnected1", "on"] | ||
v.memory = memory | ||
v.cpus = cpus | ||
end | ||
|
||
return vmCfg | ||
end | ||
|
||
def suggestedCPUCores() | ||
case RbConfig::CONFIG['host_os'] | ||
when /darwin/ | ||
Integer(`sysctl -n hw.ncpu`) / 2 | ||
when /linux/ | ||
Integer(`grep -c ^processor /proc/cpuinfo`) / 2 | ||
else | ||
2 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Get the version from the command line | ||
VERSION=$1 | ||
if [ -z "${VERSION}" ]; then | ||
echo "Please specify a version. (format: 0.4.0-rc1)" | ||
exit 1 | ||
fi | ||
|
||
# Get the parent directory of where this script is. | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" | ||
|
||
# Change into that dir because we expect that | ||
cd "${DIR}" | ||
|
||
# Generate the tag. | ||
if [ -z "${NOTAG}" ]; then | ||
echo "==> Tagging..." | ||
git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION" | ||
git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master | ||
fi | ||
|
||
# Zip all the files | ||
rm -rf ./pkg/dist | ||
mkdir -p ./pkg/dist | ||
|
||
#find ./pkg -mindepth 1 -maxdepth 1 -type f -exec cp ./pkg/{} ./pkg/dist/nomad-driver-lxc_"${VERSION}"_{} \; | ||
#for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do | ||
find ./pkg -mindepth 1 -maxdepth 1 -type f -print0 | while read -d '' -r FILENAME; do | ||
FILENAME=$(basename "$FILENAME") | ||
cp "./pkg/${FILENAME}" "./pkg/dist/nomad-driver-lxc_${VERSION}_${FILENAME}" | ||
done | ||
|
||
# Make the checksums | ||
pushd ./pkg/dist | ||
shasum -a256 ./* > "./nomad-driver-lxc_${VERSION}_SHA256SUMS" | ||
if [ -z "${NOSIGN}" ]; then | ||
echo "==> Signing..." | ||
gpg --default-key 348FFC4C --detach-sig "./nomad-driver-lxc_${VERSION}_SHA256SUMS" | ||
fi | ||
popd | ||
|
||
# Upload | ||
if [ -z "${HC_RELEASE}" ]; then | ||
hc-releases upload "${DIR}/pkg/dist" && hc-releases publish | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
|
||
# Update and ensure we have apt-add-repository | ||
apt-get update | ||
apt-get install -y software-properties-common | ||
|
||
apt-get update | ||
|
||
# Install Core build utilities for Linux | ||
apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
libc6-dev-i386 \ | ||
libpcre3-dev \ | ||
linux-libc-dev:i386 \ | ||
pkg-config \ | ||
zip | ||
|
||
# Install Development utilities | ||
apt-get install -y \ | ||
curl \ | ||
htop \ | ||
jq \ | ||
tree \ | ||
unzip \ | ||
vim | ||
|
||
# Install LXC tools | ||
apt-get install -y \ | ||
liblxc1 \ | ||
lxc-dev \ | ||
lxc \ | ||
lxc-templates | ||
|
||
# Ensure everything is up to date | ||
apt-get upgrade -y | ||
|
||
# Set hostname -> IP to make advertisement work as expected | ||
ip=$(ip route get 1 | awk '{print $NF; exit}') | ||
hostname=$(hostname) | ||
sed -i -e "s/.*nomad.*/${ip} ${hostname}/" /etc/hosts | ||
|
||
# Ensure we cd into the working directory on login | ||
if ! grep "cd /opt/gopath/src/github.com/hashicorp/nomad-driver-lxc" /home/vagrant/.profile ; then | ||
echo 'cd /opt/gopath/src/github.com/hashicorp/nomad-driver-lxc' >> /home/vagrant/.profile | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
function install_go() { | ||
local go_version=1.11.3 | ||
local download= | ||
|
||
download="https://storage.googleapis.com/golang/go${go_version}.linux-amd64.tar.gz" | ||
|
||
if [ -d /usr/local/go ] ; then | ||
return | ||
fi | ||
|
||
wget -q -O /tmp/go.tar.gz ${download} | ||
|
||
tar -C /tmp -xf /tmp/go.tar.gz | ||
sudo mv /tmp/go /usr/local | ||
sudo chown -R root:root /usr/local/go | ||
} | ||
|
||
install_go | ||
|
||
# Ensure that the GOPATH tree is owned by vagrant:vagrant | ||
mkdir -p /opt/gopath | ||
chown -R vagrant:vagrant /opt/gopath | ||
|
||
# Ensure Go is on PATH | ||
if [ ! -e /usr/bin/go ] ; then | ||
ln -s /usr/local/go/bin/go /usr/bin/go | ||
fi | ||
if [ ! -e /usr/bin/gofmt ] ; then | ||
ln -s /usr/local/go/bin/gofmt /usr/bin/gofmt | ||
fi | ||
|
||
|
||
# Ensure new sessions know about GOPATH | ||
if [ ! -f /etc/profile.d/gopath.sh ] ; then | ||
cat <<EOT > /etc/profile.d/gopath.sh | ||
export GOPATH="/opt/gopath" | ||
export PATH="/opt/gopath/bin:\$PATH" | ||
EOT | ||
chmod 755 /etc/profile.d/gopath.sh | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
cd /opt/gopath/src/github.com/hashicorp/nomad-driver-lxc && make bootstrap |