Setup.sh: more fixes.

This commit is contained in:
Shishir Mahajan 2020-07-09 16:28:40 -07:00
parent 63ce81e7ec
commit bf8a2df980
No known key found for this signature in database
GPG Key ID: D41782E7688DEC4A

View File

@ -11,6 +11,42 @@ main() {
check_os
check_nomad
check_golang
# Skip installing containerd if already present.
if ! systemctl -q is-active "containerd.service"; then
setup_containerd
else
echo "INFO: Containerd detected on the system. Skip installing containerd."
fi
read -p "INFO: Setup nomad server + nomad-driver-containerd (Y/N)? Press Y to continue. " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting setup..."
exit 0
fi
echo "INFO: Cleanup any old binaries."
make clean >/dev/null 2>&1
echo "INFO: Build nomad-driver-containerd binary: containerd-driver."
make build >/dev/null 2>&1
echo "INFO: Create plugin-dir for containerd-driver: /tmp/nomad-driver-containerd."
mkdir -p /tmp/nomad-driver-containerd
echo "INFO: Move containerd-driver to /tmp/nomad-driver-containerd."
mv containerd-driver /tmp/nomad-driver-containerd
local curr_dir=$(echo $PWD)
drop_nomad_unit_file $curr_dir
echo "INFO: Reload nomad.service systemd unit."
systemctl daemon-reload
echo "INFO: Starting nomad server + nomad-driver-containerd."
systemctl start nomad
if ! systemctl -q is-active "nomad.service"; then
echo "ERROR: nomad.service didn't come up. journalctl -u nomad.service for more info."
exit 1
fi
echo "INFO: Setup finished successfully."
}
setup_containerd() {
read -p "INFO: Download containerd (Y/N)? Press Y to continue. " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
@ -33,27 +69,10 @@ main() {
echo "INFO: Starting containerd daemon."
systemctl start containerd
popd >/dev/null 2>&1
read -p "INFO: Setup nomad server + nomad-driver-containerd (Y/N)? Press Y to continue. " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting setup..."
exit 0
if ! systemctl -q is-active "containerd.service"; then
echo "ERROR: containerd.service didn't come up. journalctl -u containerd.service for more info."
exit 1
fi
echo "INFO: Cleanup any old binaries."
make clean >/dev/null 2>&1
echo "INFO: Build nomad-driver-containerd binary: containerd-driver."
make build >/dev/null 2>&1
echo "INFO: Create plugin-dir for containerd-driver: /tmp/nomad-driver-containerd."
mkdir -p /tmp/nomad-driver-containerd
echo "INFO: Move containerd-driver to /tmp/nomad-driver-containerd."
mv containerd-driver /tmp/nomad-driver-containerd
local curr_dir=$(echo $PWD)
drop_nomad_unit_file $curr_dir
echo "INFO: Reload nomad.service systemd unit."
systemctl daemon-reload
echo "INFO: Starting nomad server + nomad-driver-containerd."
systemctl start nomad
echo "INFO: Setup finished successfully."
}
drop_nomad_unit_file() {