From 3a859cfc6fa2047675e60b6440b4883c7b742189 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sun, 15 May 2022 01:24:37 +0100
Subject: [PATCH] delete old nomad job files

---
 jobs/nomad-both/common.sh          | 63 ------------------------------
 jobs/nomad-both/nomad-both.job     | 22 -----------
 jobs/nomad-client/nomad-client.job | 21 ----------
 3 files changed, 106 deletions(-)
 delete mode 100755 jobs/nomad-both/common.sh
 delete mode 100755 jobs/nomad-both/nomad-both.job
 delete mode 100755 jobs/nomad-client/nomad-client.job

diff --git a/jobs/nomad-both/common.sh b/jobs/nomad-both/common.sh
deleted file mode 100755
index 5d420fb..0000000
--- a/jobs/nomad-both/common.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-
-log_msg() {
-	echo -e "[ ${HOSTNAME} ] [ $(date -u +"%Y-%m-%dT%H:%M:%SZ") ] $*" >&2;
-}
-
-
-log_msg "Installing nomad";
-sudo apt-get update;
-sudo apt-get install --yes hashicorp-nomad;
-
-log_msg "nomad installed successfully. Version:";
-nomad --version;
-
-log_msg "Creating directories";
-if [[ ! -d "/etc/nomad" ]]; then
-	sudo mkdir /etc/nomad;
-	sudo chown root:root /etc/nomad;
-fi
-
-if [[ ! -d "/srv/nomad" ]]; then
-	sudo mkdir /srv/nomad;
-	sudo chown root:root /srv/nomad;
-	sudo chmod 0750 /srv/nomad;
-fi
-
-check_cgroups_memory() {
-	log_msg "Checking memory cgroups";
-	
-	cgroups_enabled="$(awk '/memory/ { print $2 }' < /proc/cgroups)";
-	
-	if [[ "${cgroups_enabled}" -ne 0 ]]; then
-		log_msg "memory cgroups already enabled";
-		return 0;
-	fi
-	
-	
-	filepath_cmdline="/boot/cmdline.txt";
-	if [[ ! -e "${filepath_cmdline}" ]]; then
-		filepath_cmdline="/boot/firmware/cmdline.txt";
-	fi
-	if [[ ! -e "${filepath_cmdline}" ]]; then
-		log_msg "Failed to find cmdline.txt; can't check for cgroups";
-		return 1;
-	fi
-	
-	if grep -q cgroup_enable=memory /boot/cmdline.txt; then
-		log_msg "memory cgroups already present in cmdline.txt, a reboot is required to apply the update";
-		return 0;
-	fi
-	
-	log_msg "memory cgroups not present in cmdline.txt, enabling....";
-	(tr -d '\n' <"${filepath_cmdline}" && echo " cgroup_enable=memory cgroup_memory=1") | sudo tee "${filepath_cmdline}.new";
-	
-	sudo mv "${filepath_cmdline}" "${filepath_cmdline}.old-$(date +"%Y-%m-%d")";
-	sudo mv "${filepath_cmdline}.new" "${filepath_cmdline}";
-	
-	log_msg "New contents of cmdline.txt:";
-	cat "${filepath_cmdline}";
-	log_msg "A reboot is required to apply the changes.";
-}
-
-check_cgroups_memory;
diff --git a/jobs/nomad-both/nomad-both.job b/jobs/nomad-both/nomad-both.job
deleted file mode 100755
index 0d7c9f1..0000000
--- a/jobs/nomad-both/nomad-both.job
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT "${JOBFILE_DIR}/common.sh";
-
-COPY "../nomad/both.hcl" "/tmp/both.hcl"
-
-RUN "sudo mv /tmp/both.hcl /etc/nomad/both.hcl";
-RUN "sudo chown root:root /etc/nomad/both.hcl";
-
-RUN "sudo apt-get install --yes hashicorp-nomad-systemd-both";
-
-
-# Commented out since we're now running over wgoverlay & allowing all traffic on that interface because dynamic ports
-# RUN "sudo ufw allow 4646/tcp comment nomad-http";
-# RUN "sudo ufw allow 4647/tcp comment nomad-rpc";
-# RUN "sudo ufw allow 4648/tcp comment nomad-serf";
-RUN "sudo ufw delete allow 4646/tcp comment nomad-http";
-RUN "sudo ufw delete allow 4647/tcp comment nomad-rpc";
-RUN "sudo ufw delete allow 4648/tcp comment nomad-serf";
-
-RUN "sudo systemctl enable nomad.service";
-RUN "sudo systemctl restart nomad.service";
diff --git a/jobs/nomad-client/nomad-client.job b/jobs/nomad-client/nomad-client.job
deleted file mode 100755
index 6e1af52..0000000
--- a/jobs/nomad-client/nomad-client.job
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT "jobs/nomad-both/common.sh";
-
-COPY "../nomad/client.hcl" "/tmp/client.hcl"
-
-RUN "sudo mv /tmp/client.hcl /etc/nomad/client.hcl";
-RUN "sudo chown root:root /etc/nomad/client.hcl";
-
-RUN "sudo apt-get install --yes hashicorp-nomad-systemd-client";
-
-# Commented out since we're now running over wgoverlay & allowing all traffic on that interface because dynamic ports
-# RUN "sudo ufw allow 4646/tcp comment nomad-http";
-# RUN "sudo ufw allow 4647/tcp comment nomad-rpc";
-# RUN "sudo ufw allow 4648/tcp comment nomad-serf";
-RUN "sudo ufw delete allow 4646/tcp comment nomad-http";
-RUN "sudo ufw delete allow 4647/tcp comment nomad-rpc";
-RUN "sudo ufw delete allow 4648/tcp comment nomad-serf";
-
-RUN "sudo systemctl enable nomad.service";
-RUN "sudo systemctl restart nomad.service";
