Skip to content

Commit 96bc4ac

Browse files
committed
Optimizes Node Install Scripts
- Optimizes node install scripts to ensure that if we run vagrant provision after the lab is up and running we do not experience errors/failures. - These fixes should help minimize these errors by adding a bit of logic to our scripting. - Resolves #12
1 parent cfdc7ea commit 96bc4ac

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

node-install-a.sh

100644100755
+32-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
sudo apt-get update -y
44
sudo apt-get install unzip curl vim jq -y
55
# make an archive folder to move old binaries into
6-
sudo mkdir /tmp/archive/
6+
if [ ! -d /tmp/archive ]; then
7+
sudo mkdir /tmp/archive/
8+
fi
79

810
# Install Docker Community Edition
911
echo "Docker Install Beginning..."
@@ -27,8 +29,15 @@ echo "Nomad Install Beginning..."
2729
NOMAD_VERSION=0.9.5
2830
cd /tmp/
2931
sudo curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
30-
sudo unzip nomad.zip
31-
sudo install nomad /usr/bin/nomad
32+
if [ ! -d nomad ]; then
33+
sudo unzip nomad.zip
34+
fi
35+
if [ ! -f /usr/bin/nomad ]; then
36+
sudo install nomad /usr/bin/nomad
37+
fi
38+
if [ -f /tmp/archive/nomad ]; then
39+
sudo rm /tmp/archive/nomad
40+
fi
3241
sudo mv /tmp/nomad /tmp/archive/nomad
3342
sudo mkdir -p /etc/nomad.d
3443
sudo chmod a+w /etc/nomad.d
@@ -40,8 +49,15 @@ echo "Consul Install Beginning..."
4049
CONSUL_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/consul | jq -r ".current_version")
4150
#CONSUL_VERSION=1.4.0
4251
sudo curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
43-
sudo unzip /tmp/consul.zip
44-
sudo install consul /usr/bin/consul
52+
if [ ! -d consul ]; then
53+
sudo unzip /tmp/consul.zip
54+
fi
55+
if [ ! -f /usr/bin/consul ]; then
56+
sudo install consul /usr/bin/consul
57+
fi
58+
if [ -f /tmp/archive/consul ]; then
59+
sudo rm /tmp/archive/consul
60+
fi
4561
sudo mv /tmp/consul /tmp/archive/consul
4662
sudo mkdir -p /etc/consul.d
4763
sudo chmod a+w /etc/consul.d
@@ -50,7 +66,15 @@ sudo cp /vagrant/consul-config/consul-server-east.hcl /etc/consul.d/
5066
for bin in cfssl cfssl-certinfo cfssljson
5167
do
5268
echo "$bin Install Beginning..."
53-
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
54-
sudo install /tmp/${bin} /usr/local/bin/${bin}
69+
if [ ! -f /tmp/${bin} ]; then
70+
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
71+
fi
72+
if [ ! -f /usr/local/bin/${bin} ]; then
73+
sudo install /tmp/${bin} /usr/local/bin/${bin}
74+
fi
5575
done
56-
nomad -autocomplete-install
76+
cat /root/.bashrc | grep "complete -C /usr/bin/nomad nomad"
77+
retval=$?
78+
if [ $retval -eq 1 ]; then
79+
nomad -autocomplete-install
80+
fi

node-install-b.sh

100644100755
+32-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
sudo apt-get update -y
44
sudo apt-get install unzip curl vim jq -y
55
# make an archive folder to move old binaries into
6-
sudo mkdir /tmp/archive/
6+
if [ ! -d /tmp/archive ]; then
7+
sudo mkdir /tmp/archive/
8+
fi
79

810
# Install Docker Community Edition
911
echo "Docker Install Beginning..."
@@ -27,8 +29,15 @@ echo "Nomad Install Beginning..."
2729
NOMAD_VERSION=0.9.5
2830
cd /tmp/
2931
sudo curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
30-
sudo unzip nomad.zip
31-
sudo install nomad /usr/bin/nomad
32+
if [ ! -d nomad ]; then
33+
sudo unzip nomad.zip
34+
fi
35+
if [ ! -f /usr/bin/nomad ]; then
36+
sudo install nomad /usr/bin/nomad
37+
fi
38+
if [ -f /tmp/archive/nomad ]; then
39+
sudo rm /tmp/archive/nomad
40+
fi
3241
sudo mv /tmp/nomad /tmp/archive/nomad
3342
sudo mkdir -p /etc/nomad.d
3443
sudo chmod a+w /etc/nomad.d
@@ -40,8 +49,15 @@ echo "Consul Install Beginning..."
4049
CONSUL_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/consul | jq -r ".current_version")
4150
#CONSUL_VERSION=1.4.0
4251
sudo curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
43-
sudo unzip /tmp/consul.zip
44-
sudo install consul /usr/bin/consul
52+
if [ ! -d consul ]; then
53+
sudo unzip /tmp/consul.zip
54+
fi
55+
if [ ! -f /usr/bin/consul ]; then
56+
sudo install consul /usr/bin/consul
57+
fi
58+
if [ -f /tmp/archive/consul ]; then
59+
sudo rm /tmp/archive/consul
60+
fi
4561
sudo mv /tmp/consul /tmp/archive/consul
4662
sudo mkdir -p /etc/consul.d
4763
sudo chmod a+w /etc/consul.d
@@ -50,7 +66,15 @@ sudo cp /vagrant/consul-config/consul-server-west.hcl /etc/consul.d/
5066
for bin in cfssl cfssl-certinfo cfssljson
5167
do
5268
echo "$bin Install Beginning..."
53-
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
54-
sudo install /tmp/${bin} /usr/local/bin/${bin}
69+
if [ ! -f /tmp/${bin} ]; then
70+
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
71+
fi
72+
if [ ! -f /usr/local/bin/${bin} ]; then
73+
sudo install /tmp/${bin} /usr/local/bin/${bin}
74+
fi
5575
done
56-
nomad -autocomplete-install
76+
cat /root/.bashrc | grep "complete -C /usr/bin/nomad nomad"
77+
retval=$?
78+
if [ $retval -eq 1 ]; then
79+
nomad -autocomplete-install
80+
fi

0 commit comments

Comments
 (0)