-
Notifications
You must be signed in to change notification settings - Fork 21
/
dev_start.sh
executable file
·91 lines (79 loc) · 2.11 KB
/
dev_start.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
#!/bin/bash
CMDS="vagrant"
DEPS="vagrant"
VAGRANT_PLUGINS_REQUIRED=("vagrant-hostmanager" "vagrant-vbguest")
VERBOSE=0
for arg in "$@"; do
if [ "${arg}" = "-v" -o "${arg}" = "--verbose" ]; then
VERBOSE=1
echo "Verbose mode enabled"
fi
done
commands_exist () {
DEPS_MISSING=0
for cmd in $1; do
if ! type "${cmd}" &> /dev/null; then
DEPS_MISSING=1
echo "Dependency '${cmd}' is not installed."
fi
done
return $DEPS_MISSING
}
function_defined() {
type "$1" &> /dev/null;
}
please_install () {
if [ -f /etc/redhat-release ] ; then
PKMGR=$(which yum)
elif [ -f /etc/debian_version ] ; then
PKMGR=$(which apt-get)
fi
echo
echo "Before running this script, please run:"
echo "${PKMGR} install $1"
}
log () {
if [ $VERBOSE -eq 1 ]; then
echo "$1"
fi
}
SUDO=0
do_sudo () {
if [ $SUDO -eq 0 ]; then
echo "Your hosts file does not contain the required entries, will need"
echo "root privileges to set them.."
sudo ls &> /dev/null
SUDO=1
fi
sudo bash -c "$@"
}
if ! commands_exist "${CMDS}"; then
log "Missing one or more dependencies."
please_install "${DEPS}"
exit 1
fi
log "Checking for vagrant plugins.."
INSTALLED=$(vagrant plugin list | awk '{print $1;}' | xargs)
for PLUGIN in "${VAGRANT_PLUGINS_REQUIRED[@]}"; do
if [[ $INSTALLED != *$plugin* ]]; then
log "Installing vagrant plugin \"${PLUGIN}\""
vagrant plugin install "${PLUGIN}"
fi
done
if ! grep -Fxq "192.168.33.222 testsite.nl" /etc/hosts; then
do_sudo "echo '192.168.33.222 testsite.nl' >> /etc/hosts"
fi
log "Starting Boulder CA server instance.."
if vagrant up boulder; then
log "Starting LE HAProxy client vm.."
vagrant up lehaproxy
else
log "ERROR: Couldn't start boulder server!"
exit 1
fi
echo "You can now connect to the Vagrant instance:"
echo "vagrant ssh lehaproxy"
echo "After connecting please run:"
echo "cd /lehaproxy/; source /lehaproxy_venv/bin/activate"
echo "You can now run certbot with the HAProxy plugin installed:"
echo "certbot run"