33set -euo pipefail
44
55export CONTAINERD_VERSION=1.3.4
6- export CLEANUP_CONTAINERD=false
76
87main () {
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() {
5563cleanup () {
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