Skip to content

Commit e34676e

Browse files
Override containerd with warning.
1 parent 70a2880 commit e34676e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

setup.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -euo pipefail
44

55
export CONTAINERD_VERSION=1.3.4
6-
export CLEANUP_CONTAINERD=false
76

87
main() {
98
echo "INFO: Welcome! nomad-driver-containerd setup."
@@ -17,13 +16,22 @@ main() {
1716
# Save present working directory (pwd).
1817
curr_dir=$(echo $PWD)
1918

20-
# Skip installing containerd if already present.
21-
if ! systemctl -q is-active "containerd.service"; then
22-
CLEANUP_CONTAINERD=true
23-
setup_containerd
24-
else
25-
echo "INFO: Containerd detected on the system. Skip installing containerd."
19+
if systemctl -q is-active "containerd.service"; then
20+
echo "WARN: Containerd detected on the system."
21+
read -p "INFO: Backup existing containerd and deploy containerd-${CONTAINERD_VERSION} (Y/N)? Press Y to continue. " -n 1 -r
22+
echo
23+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
24+
echo "INFO: Aborting setup..."
25+
exit 0
26+
fi
27+
systemctl stop containerd
28+
if [ -f "/lib/systemd/system/containerd.service" ]; then
29+
echo "INFO: Backup containerd systemd unit /lib/systemd/system/containerd.service."
30+
mv /lib/systemd/system/containerd.service /lib/systemd/system/containerd.service.bkp
31+
echo "WARN: Backup file saved at: /lib/systemd/system/containerd.service.bkp"
32+
fi
2633
fi
34+
setup_containerd
2735

2836
read -p "INFO: Setup nomad server + nomad-driver-containerd (Y/N)? Press Y to continue. " -n 1 -r
2937
echo
@@ -55,7 +63,7 @@ main() {
5563
cleanup() {
5664
echo "INFO: Starting cleanup."
5765
pushd $curr_dir >/dev/null 2>&1
58-
if [ "$CLEANUP_CONTAINERD" = true ]; then
66+
if [ -f "/lib/systemd/system/containerd.service.bkp" ]; then
5967
if systemctl -q is-active "containerd.service"; then
6068
echo "INFO: Stopping containerd."
6169
systemctl stop containerd.service

0 commit comments

Comments
 (0)