From a4ec82068ec18842e12b5698638f94d81b50d571 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 25 Nov 2021 23:27:02 +0000 Subject: [PATCH] Delete wrapper scripts --- execute | 172 --------------------------------------- hosts/clients-consul.txt | 2 - hosts/clients-nomad.txt | 2 - hosts/controller.txt | 1 - hosts/servers-consul.txt | 2 - hosts/servers-nomad.txt | 2 - hosts/servers-vault.txt | 1 - hosts/workers.txt | 4 - list-hostgroups | 5 -- list-jobs | 5 -- new-job | 18 ---- ssh-config | 46 ----------- 12 files changed, 260 deletions(-) delete mode 100755 execute delete mode 100644 hosts/clients-consul.txt delete mode 100644 hosts/clients-nomad.txt delete mode 100644 hosts/controller.txt delete mode 100644 hosts/servers-consul.txt delete mode 100644 hosts/servers-nomad.txt delete mode 100644 hosts/servers-vault.txt delete mode 100644 hosts/workers.txt delete mode 100755 list-hostgroups delete mode 100755 list-jobs delete mode 100755 new-job delete mode 100644 ssh-config diff --git a/execute b/execute deleted file mode 100755 index d6f257c..0000000 --- a/execute +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env bash -set -e; - -# Interesting chars: -# 🛰 - Satellite - looks very cool indeed in Firefox - -lantern_path="../lantern-build-engine"; -if [[ -z "${do_parallel}" ]]; then - do_parallel="true"; -fi - -############################################################################### - -# Make sure the current directory is the location of this script to simplify matters -cd "$(dirname "$(readlink -f "$0")")"; - -# Check out the lantern git submodule if needed -if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi - -#shellcheck disable=SC1090 -source "${lantern_path}/lantern.sh"; - -############################################################################### - -if [[ -z "${2}" ]]; then - echo "Usage:"; - echo " ./execute {{path/to/jobfile}} {{path/to/hostsfile_a}} {{path/to/hostsfile_n}}"; - exit 1; -fi - -job_filepath="$1"; -if [[ ! -f "${job_filepath}" ]]; then - job_filepath="jobs/${job_filepath}/${job_filepath}.job"; -fi - -shift; - -hosts=""; -while [[ ! -z "${1}" ]]; do - hosts_filename="${1}"; - if [[ ! -f "${hosts_filename}" ]]; then - hosts_filename="hosts/${hosts_filename}.txt"; - fi - - hosts="$(echo "${hosts}" && cat "${hosts_filename}")"; - shift; -done - -ssh_configfile="./ssh-config"; - -if [[ ! -x "${job_filepath}" ]]; then - echo -e "${FRED}Error: ${job_filepath} doesn't exist, or is not executable.${RS}" >&2; - exit 1; -fi - -log_msg() { - echo -e "[ $(date -u +"%Y-%m-%dT%H:%M:%SZ") ] $*" >&2; -} - -# $1 Command to execute -RUN_ONCE() { - command="${1}"; - hash="$(echo "${command}" | sha256sum | cut -d- -f1)"; - - if [[ -z "${EXECUTE_HOSTNAME}" ]]; then - task_end 1 "Oops! The hostname to execute on wasn't found. This is probably a bug."; - fi - - log_msg "️🛡️ ${HC}[ ${EXECUTE_HOSTNAME} ]${RS} ${FBLE}RUN_ONCE${RS} ${command}"; - - if [[ "${INTERACTIVE}" == "true" ]]; then - echo "Enabling interactive mode"; - SSH_FLAGS="-t "; - fi - - echo " -if [[ ! -d /etc/remote-exec ]]; then sudo mkdir /etc/remote-exec; fi -if [[ ! -f /etc/remote-exec/${hash} ]]; then - echo \"[ \${HOSTNAME} ] [ \$(date -u +\"%Y-%m-%dT%H:%M:%SZ\") ] Executing once\" - ${command} - sudo touch /etc/remote-exec/${hash}; -fi -" | ssh ${SSH_FLAGS} -F "${ssh_configfile}" "${EXECUTE_HOSTNAME}" bash; - -} - -# $1 Command to execute -RUN() { - command="${1}"; - - if [[ -z "${EXECUTE_HOSTNAME}" ]]; then - task_end 1 "Oops! The hostname to execute on wasn't found. This is probably a bug."; - fi - - log_msg "🚏 ${HC}[ ${EXECUTE_HOSTNAME} ]${RS} ${FBLE}RUN${RS} ${command}"; - - if [[ "${INTERACTIVE}" == "true" ]]; then - echo "Enabling interactive mode"; - SSH_FLAGS="-t "; - fi - - echo "${command}" | ssh ${SSH_FLAGS} -F "${ssh_configfile}" "${EXECUTE_HOSTNAME}" bash; -} - -# $1 Filepath to script to copy & execute -SCRIPT() { - script_filepath="${1}"; - - remote_filepath="/tmp/$(basename ${script_filepath})"; - - if [[ -z "${EXECUTE_HOSTNAME}" ]]; then - task_end 1 "Oops! The hostname to execute on wasn't found. This is probably a bug."; - fi - - log_msg "🚂 ${HC}[ ${EXECUTE_HOSTNAME} ]${RS} ${FMAG}SCRIPT${RS} ${command}"; - - scp -F "${ssh_configfile}" "${script_filepath}" "${EXECUTE_HOSTNAME}:${remote_filepath}"; - echo -e "${remote_filepath}\nrm ${remote_filepath}" | ssh -F "${ssh_configfile}" "${EXECUTE_HOSTNAME}" bash; - echo "" -} - -# $1 The filepath to copy -# $2 The location to copy it to on the remote host -COPY() { - filepath_local="${1}"; - filepath_remote="${2}"; - - log_msg "🚚 ${HC}[ ${EXECUTE_HOSTNAME} ]${RS} ${FMAG}COPY${RS} ${filepath_local} → ${filepath_remote}"; - - if [[ ! -f "${filepath_local}" ]]; then - task_end 1 "[ ${HC}COPY${RS} ] Error: Couldn't find ${filepath_local} on disk (CWD is ${PWD})."; - fi - - if [[ -z "${EXECUTE_HOSTNAME}" ]]; then - task_end 1 "[ ${HC}COPY${RS} ] Oops! The hostname to copy to wasn't found. This is probably a bug."; - fi - - - scp -F "${ssh_configfile}" "${filepath_local}" "${EXECUTE_HOSTNAME}:${filepath_remote}"; -} - -# $1 job filepath -# $2 hostname -__do_execute() { - job_filepath="${1}"; - hostname="${2}"; - log_msg "${FBLE}${HC}⌛${RS} Starting on ${HC}${hostname}${RS}"; - - export EXECUTE_HOSTNAME="${hostname}"; - export JOBFILE_DIR; JOBFILE_DIR="$(dirname "${job_filepath}")"; - - #shellcheck disable=SC1090 - source "${job_filepath}"; - - log_msg "${FGRN}${HC}✔${RS} Finished on ${HC}${hostname}${RS}"; -} - -task_begin "Executing ${job_filepath}"; - -while read -r hostname; do - if [[ -z "${hostname}" ]]; then - continue; - fi - - if [[ "${do_parallel}" == "true" ]]; then - __do_execute "${job_filepath}" "${hostname}" & - else - __do_execute "${job_filepath}" "${hostname}"; - fi -done < <(echo "${hosts}"); - -wait diff --git a/hosts/clients-consul.txt b/hosts/clients-consul.txt deleted file mode 100644 index e565d74..0000000 --- a/hosts/clients-consul.txt +++ /dev/null @@ -1,2 +0,0 @@ -cluster-balusha -cluster-silverleaf diff --git a/hosts/clients-nomad.txt b/hosts/clients-nomad.txt deleted file mode 100644 index 92e6683..0000000 --- a/hosts/clients-nomad.txt +++ /dev/null @@ -1,2 +0,0 @@ -cluster-sycadil -cluster-spatterling diff --git a/hosts/controller.txt b/hosts/controller.txt deleted file mode 100644 index 7c255f4..0000000 --- a/hosts/controller.txt +++ /dev/null @@ -1 +0,0 @@ -cluster-wopplefox diff --git a/hosts/servers-consul.txt b/hosts/servers-consul.txt deleted file mode 100644 index 92e6683..0000000 --- a/hosts/servers-consul.txt +++ /dev/null @@ -1,2 +0,0 @@ -cluster-sycadil -cluster-spatterling diff --git a/hosts/servers-nomad.txt b/hosts/servers-nomad.txt deleted file mode 100644 index e565d74..0000000 --- a/hosts/servers-nomad.txt +++ /dev/null @@ -1,2 +0,0 @@ -cluster-balusha -cluster-silverleaf diff --git a/hosts/servers-vault.txt b/hosts/servers-vault.txt deleted file mode 100644 index 87c1630..0000000 --- a/hosts/servers-vault.txt +++ /dev/null @@ -1 +0,0 @@ -cluster-balusha diff --git a/hosts/workers.txt b/hosts/workers.txt deleted file mode 100644 index af9c274..0000000 --- a/hosts/workers.txt +++ /dev/null @@ -1,4 +0,0 @@ -cluster-sycadil -cluster-spatterling -cluster-balusha -cluster-silverleaf diff --git a/list-hostgroups b/list-hostgroups deleted file mode 100755 index c56c2e8..0000000 --- a/list-hostgroups +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# Make sure the current directory is the location of this script to simplify matters -cd "$(dirname "$(readlink -f "$0")")"; - -find hosts -type f -iname '*.txt' | xargs -n1 basename --suffix=.txt | sort diff --git a/list-jobs b/list-jobs deleted file mode 100755 index 0375f58..0000000 --- a/list-jobs +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# Make sure the current directory is the location of this script to simplify matters -cd "$(dirname "$(readlink -f "$0")")"; - -ls ./jobs/ diff --git a/new-job b/new-job deleted file mode 100755 index 0143aa4..0000000 --- a/new-job +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# Make sure the current directory is the location of this script to simplify matters -cd "$(dirname "$(readlink -f "$0")")"; - -job_name="$1"; - -if [[ -z "${job_name}" ]]; then - echo "Usage:"; - echo " ./new-job {job_name}"; - exit; -fi - -job_filename="./jobs/${job_name}/${job_name}.job"; - -mkdir -p "$(dirname "${job_filename}")"; - -echo -e "#!/usr/bin/env bash\n" >"${job_filename}"; -chmod +x "${job_filename}"; diff --git a/ssh-config b/ssh-config deleted file mode 100644 index 1fad6e0..0000000 --- a/ssh-config +++ /dev/null @@ -1,46 +0,0 @@ -ServerAliveInterval 120 - -Host * - ControlMaster auto - ControlPath /tmp/%r@%h:%p - - -Host cluster-wopplefox - Hostname 172.16.230.100 - Port 22 - - User root - IdentityFile ~/.ssh/id_ed25519 - ForwardAgent yes -Host cluster-sycadil - Hostname 172.16.230.102 - Port 22 - - User dietpi - IdentityFile ~/.ssh/id_ed25519 - ForwardAgent yes -Host cluster-spatterling - Hostname 172.16.230.101 - Port 22 - - User dietpi - IdentityFile ~/.ssh/id_ed25519 - ForwardAgent yes -Host cluster-balusha - Hostname 172.16.230.103 - Port 22 - - User dietpi - IdentityFile ~/.ssh/id_ed25519 - ForwardAgent yes -Host cluster-silverleaf - # braskin - # toko - # *silverleaf* - # elligon: router - Hostname 172.16.230.104 - Port 22 - - User dietpi - IdentityFile ~/.ssh/id_ed25519 - ForwardAgent yes