From 0458abb41900904d96d3a2d82f516296aa8509ae Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Tue, 15 Nov 2022 11:58:22 +0100 Subject: [PATCH] Kontroly prerekvizit do knihovny --- make/deploy | 13 ++----------- make/deploy_prod | 13 ++----------- make/lib.sh | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/make/deploy b/make/deploy index d25df6ce..4e93d5e1 100755 --- a/make/deploy +++ b/make/deploy @@ -3,17 +3,8 @@ set -exuo pipefail . make/lib.sh -if test "$USER" != "mam-web"; -then - echo >&2 "Nasadit web smí jen uživatel mam-web" - exit 1 -fi - -if test "$(readlink -f .)" != "$TESTWEB"; -then - echo >&2 "Nasadit testweb lze jen v jeho složce" - exit 1 -fi +gimli_only +only_in_directory "$TESTWEB" CURRENT_BRANCH="$(git branch --show-current)" BRANCH="${1:-$CURRENT_BRANCH}" diff --git a/make/deploy_prod b/make/deploy_prod index 8e006938..0c10219d 100755 --- a/make/deploy_prod +++ b/make/deploy_prod @@ -3,17 +3,8 @@ set -exuo pipefail . make/lib.sh -if test "$USER" != "mam-web" -then - echo >&2 "Nasadit web smí jen uživatel mam-web" - exit 1 -fi - -if test "$(readlink -f .)" != "$PRODWEB" -then - echo >&2 "Nasadit testweb lze jen v jeho složce" - exit 1 -fi +gimli_only +only_in_directory "$PRODWEB" CURRENT_BRANCH="$(git branch --show-current)" BRANCH="${1:-$CURRENT_BRANCH}" diff --git a/make/lib.sh b/make/lib.sh index 8ae08e1f..20329d3f 100644 --- a/make/lib.sh +++ b/make/lib.sh @@ -26,6 +26,24 @@ function ensure_venv { . "$VENV_PATH/bin/activate" } +function gimli_only { + # Rovnou zkontrolujeme i uživatele + if test "$HOSTNAME" != gimli -o "$USER" != mam-web + then + echo "Tento příkaz se má spouštět na gimlim, chceš pokračovat? Pokud ne, sestřel tento skript." + read + fi +} + +function only_in_directory { + DIR="$1" + CURRENT="$(readlink -f .)" + if test "$CURRENT" != "$DIR" + then + echo "Tento příkaz se má spouštět ve složce $DIR, chceš pokračovat? Pokud ne, sestřel tento skript." + read + fi +} function safe_checkout_branch { if "$#" -ne 2