From 17a2032a10d5b2df3789869718ac31eae889e983 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Wed, 1 Jun 2022 10:46:11 +0200 Subject: [PATCH] evolinux-base: add update-evobackup-canary script --- CHANGELOG.md | 1 + .../files/update-evobackup-canary.sh | 129 ++++++++++++++++++ evolinux-base/tasks/utils.yml | 17 ++- 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 evolinux-base/files/update-evobackup-canary.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index a080d0df..62cf1215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The **patch** part changes is incremented if multiple releases happen the same m ### Added certbot: add hapee (HAProxy Enterprise Edition) deploy hook +evolinux-base: add update-evobackup-canary script ### Changed diff --git a/evolinux-base/files/update-evobackup-canary.sh b/evolinux-base/files/update-evobackup-canary.sh new file mode 100644 index 00000000..20fc1a57 --- /dev/null +++ b/evolinux-base/files/update-evobackup-canary.sh @@ -0,0 +1,129 @@ +#!/bin/sh + +PROGNAME="update-evobackup-canary" +REPOSITORY="https://gitea.evolix.org/evolix/evobackup" + +VERSION="22.05" +readonly VERSION + +# base functions + +show_version() { + cat <, + Jérémy Lecour , + and others. + +${REPOSITORY} + +${PROGNAME} comes with ABSOLUTELY NO WARRANTY. This is free software, +and you are welcome to redistribute it under certain conditions. +See the GNU General Public License v3.0 for details. +END +} +show_help() { + cat <> "${canary_file}" +} + +# parse options +# based on https://gist.github.com/deshion/10d3cb5f88a21671e17a +while :; do + case $1 in + -h|-\?|--help) + show_help + exit 0 + ;; + -V|--version) + show_version + exit 0 + ;; + + -w|--who) + # with value separated by space + if [ -n "$2" ]; then + who=$2 + shift + else + printf 'ERROR: "-w|--who" requires a non-empty option argument.\n' >&2 + exit 1 + fi + ;; + --who=?*) + # with value speparated by = + who=${1#*=} + ;; + --who=) + # without value + printf 'ERROR: "--who" requires a non-empty option argument.\n' >&2 + exit 1 + ;; + + -f|--file) + # with value separated by space + if [ -n "$2" ]; then + canary_file=$2 + shift + else + printf 'ERROR: "-f|--file" requires a non-empty option argument.\n' >&2 + exit 1 + fi + ;; + --file=?*) + # with value speparated by = + canary_file=${1#*=} + ;; + --file=) + # without value + printf 'ERROR: "--file" requires a non-empty option argument.\n' >&2 + exit 1 + ;; + + --) + # End of all options. + shift + break + ;; + -?*) + # ignore unknown options + printf 'WARN: Unknown option : %s\n' "$1" >&2 + exit 1 + ;; + *) + # Default case: If no more options then break out of the loop. + break + ;; + esac + + shift +done + +export LC_ALL=C + +set -u + +main diff --git a/evolinux-base/tasks/utils.yml b/evolinux-base/tasks/utils.yml index 084f8b35..0dabc3dc 100644 --- a/evolinux-base/tasks/utils.yml +++ b/evolinux-base/tasks/utils.yml @@ -26,4 +26,19 @@ mode: "0700" owner: root group: root - force: no \ No newline at end of file + force: no + +- name: update-evobackup-canary script is present + copy: + src: "update-evobackup-canary.sh" + dest: /usr/local/bin/update-evobackup-canary + force: True + owner: root + group: root + mode: "0750" + +# TODO: delete when this has been run once on all our servers +- name: update-evobackup-canary is removed from sbin + file: + path: /usr/local/sbin/update-evobackup-canary + state: absent \ No newline at end of file