From 037182e2e050b964ffe6bc4b776be631e3e66147 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 28 Jan 2026 03:20:23 +0900 Subject: [PATCH] =?UTF-8?q?backup.sh:=20sjekk=20at=20verkt=C3=B8y=20er=20p?= =?UTF-8?q?=C3=A5=20plass=20f=C3=B8r=20vi=20kj=C3=B8rer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backup.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/backup.sh b/backup.sh index df742a3..10e29ae 100755 --- a/backup.sh +++ b/backup.sh @@ -16,6 +16,35 @@ #ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsCm6f5JOlKDbZMiQ6rXvU35QU4Gs/WKKlZymXtFxPhK5jBoZskQjNhfsr+peuhnZ1y+04L9qEBkN3jN0ThROaRaKSFVWfnMnij7pEB0bmJRxDmkQsHL7YsAm6tPn8116tt9m9ASPYE5RpnaDGtxTP7uXa42URvwXdvWY618tdX4z39JG9f85KYexhwRbhaBMLnSPH6JKCKu1tTBwr7oEbuhLFrFXQwqWRip/oN/6/eSxnIrwaey1GM+CdNfeGh/0OeQJ4XIUas2WbgiQRw6Dkxo32FeFS5LVaOYWRys6W3Znw9a9yOYImjJ8WUmiwSeN2bksUizNBNA1HBhoKGM5b root@alphys # +declare -ra required_tools=( + rsync + ssh + zfs + zpool + awk +) +for tool in "${required_tools[@]}"; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "Mangler påkrevd verktøy: $tool" + exit 1 + fi +done + +if [ "$(id -u)" -ne 0 ]; then + echo "Må kjøres som root!" + exit 1 +fi + +# 5.1 er minimum pga. wait '-p' flagget. +declare -r minimum_bash_major_version="5" +declare -r minimum_bash_minor_version="1" +if [ \ + "${BASH_VERSINFO[0]}" -lt "$minimum_bash_major_version" ] || \ + { [ "${BASH_VERSINFO[0]}" -eq "$minimum_bash_major_version" ] && \ + [ "${BASH_VERSINFO[1]}" -lt "$minimum_bash_minor_version" ]; }; then + echo "Må kjøres med bash versjon $minimum_bash_major_version eller nyere!" + exit 1 +fi echo "PVV; hjemmelaget backupscript (\$ git commit sha: $(cd /backupz && git rev-parse HEAD) \$)" echo