-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovision.sh
executable file
·96 lines (68 loc) · 1.86 KB
/
provision.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
# This script is used to confiure our Linux instance.
# It is built to be idempotent, which means it can be run as many times as is needed.
#
# Errors are fatal
set -e
UPDATE_FILE=/var/run/apt-update-last-run
echo "# Making sure apt is up to date..."
#
# Check to see if apt update was run within the last day.
#
FOUND=$(find /var/run/apt-update-last-run -mtime -1 || true)
if test "${FOUND}"
then
echo "# Oh, apt update was run within the last day, skipping!"
else
apt update
touch $UPDATE_FILE
fi
echo "# Installing ZFS..."
FOUND=$(dpkg -l | grep zfsutils || true)
if test ! "${FOUND}"
then
apt install -y zfsutils-linux
else
echo "# Oh, ZFS is already installed! Let's move on..."
fi
echo "# Updating \$PATH for vagrant user..."
FOUND=$( grep "/vagrant/bin" /home/vagrant/.bashrc || true)
if test "${FOUND}"
then
echo "# Oh, \$PATH is already updated..."
else
echo "" >> /home/vagrant/.bashrc
echo 'PATH=$PATH:/vagrant/bin' >> /home/vagrant/.bashrc
fi
echo "# Disabling dynamic MOTD if not done already..."
FOUND=$(grep "^session.*motd=/run/motd.dynamic" /etc/pam.d/login || true)
if test "${FOUND}"
then
echo "# Disabling dynamic MOTD from /etc/pam.d/login..."
sed -i '/^session.*motd=\/run\/motd.dynamic/s/^/### /' /etc/pam.d/login
fi
FOUND=$(grep "^session.*motd=/run/motd.dynamic" /etc/pam.d/sshd || true)
if test "${FOUND}"
then
echo "# Disabling dynamic MOTD from /etc/pam.d/sshd..."
sed -i '/^session.*motd=\/run\/motd.dynamic/s/^/### /' /etc/pam.d/sshd
fi
cp /vagrant/motd /etc/motd
if test ! -d /disks
then
echo "Making /disks to hold fake disks."
mkdir /disks
fi
#
# Create a number of virtual disks.
# Since devices are files in UNIX systems, this works GREAT for testing purposes!
#
NUM_DISKS=10
SIZE_MB=1024
for I in $(seq 0 $(( ${NUM_DISKS} - 1 )) )
do
FILE="disk${I}"
/vagrant/bin/zfs-add-disk-file ${FILE} 1024
done
echo "# Done!"