From 433515cff898168b204833941a6d32399152128b Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Thu, 17 Aug 2023 16:11:14 +0200 Subject: [PATCH] schutzbot: unregister test hosts --- .gitlab-ci.yml | 1 + schutzbot/unregister.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 schutzbot/unregister.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8673b514..650bcbe9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,7 @@ stages: - cat schutzbot/team_ssh_keys.txt | tee -a ~/.ssh/authorized_keys > /dev/null after_script: - schutzbot/ci_details.sh > ci-details-after-run + - schutzbot/unregister.sh - schutzbot/update_github_status.sh update tags: - terraform diff --git a/schutzbot/unregister.sh b/schutzbot/unregister.sh new file mode 100755 index 00000000..616678aa --- /dev/null +++ b/schutzbot/unregister.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Colorful output. +function greenprint { + echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" +} +function redprint { + echo -e "\033[1;31m[$(date -Isecond)] ${1}\033[0m" +} + +if ! hash subscription-manager; then + exit 0 +fi +if ! sudo subscription-manager status; then + exit 0 +fi +if sudo subscription-manager unregister; then + greenprint "Host unregistered." + exit 0 +fi +redprint "Failed to unregister" +exit 1