From ea7a1cd171ac6d937cb488a143b3794879779e7a Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 19:56:26 +0100 Subject: [PATCH 01/21] Added selfupdating Added a selfupdating function. Fixed a forgotten variable (compose-array). --- dockcheck.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- errorCheck.sh | 0 2 files changed, 47 insertions(+), 4 deletions(-) mode change 100644 => 100755 errorCheck.sh diff --git a/dockcheck.sh b/dockcheck.sh index 9e2f442..0e8e2a2 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,10 +1,17 @@ #!/usr/bin/env bash -VERSION="v0.2.2-URGENT" +VERSION="v0.2.3" Github="https://github.com/mag37/dockcheck" +RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" ### Check if there's a new release of the script: -LatestRelease="$(curl -s -r 0-50 https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" -[ "$VERSION" != "$LatestRelease" ] && printf "New version available! Latest: %s - Local: %s \nGrab it here: %s \n\n" "$LatestRelease" "$VERSION" "$Github" +LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" + +### Variables for self updating +ScriptBranch="main" +ScriptArgs=( "$@" ) +ScriptPath="$(readlink -f "$0")" +ScriptName="$(basename "$ScriptPath")" +ScriptWorkDir="$(dirname "$ScriptPath")" ### Help Function: Help() { @@ -32,6 +39,42 @@ while getopts "aynprhe:" options; do done shift "$((OPTIND-1))" +self_update_git() { + cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } + [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } + git fetch + [ -n "$(git diff --name-only "origin/$ScriptBranch" "$ScriptName")" ] && { + printf "%s\n" "Pulling the latest version." + git pull --force + git checkout "$ScriptBranch" + git pull --force + echo "Running the new version..." + cd - || { printf "Path error.\n" ; return ; } + exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments + exit 1 # exit the old instance + } + echo "Local is already latest." +} +self_update_curl() { + cp "$ScriptPath" "$ScriptPath".bak + if [[ $(builtin type -P curl) ]]; then + curl -L $RawUrl > "$ScriptPath" ; chmod +x "$ScriptPath" + printf "%s\n" "--- starting over with the updated version ---" + exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments + exit 1 # exit the old instance + else + printf "curl not available - download the update manually: %s \n" "$RawUrl" + fi +} +if [ "$VERSION" != "$LatestRelease" ] ; then + printf "New version available! Local: %s - Latest: %s \n" "$VERSION" "$LatestRelease" + read -r -p "Choose update procedure (or do it manually) - git/curl/[no]: " SelfUpQ + if [[ "$SelfUpQ" == "git" ]]; then self_update_git ; + elif [[ "$SelfUpQ" == "curl" ]]; then self_update_curl ; + else printf "Download it manually from the repo: %s \n\n" "$Github" + fi +fi + ### Set $1 to a variable for name filtering later. SearchName="$1" ### Create array of excludes @@ -184,7 +227,7 @@ if [ -n "$GotUpdates" ] ; then cd "$ContPath" || { echo "Path error - skipping $i" ; continue ; } docker pull "$ContImage" ### Reformat for multi-compose: - IFS=',' read -r -a Confs <<< "$ContConfigFile" ; unset IFS + IFS=',' read -r -a Confs <<< "$ComposeFile" ; unset IFS for conf in "${Confs[@]}"; do CompleteConfs+="-f $conf " ; done ### Check if the container got an environment file set, use it if so: diff --git a/errorCheck.sh b/errorCheck.sh old mode 100644 new mode 100755 From ac77470dee7150c71f0599baf949384ab4f111cf Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:00:20 +0100 Subject: [PATCH 02/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 0e8e2a2..c02132d 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.3" +VERSION="v0.2.31" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" From 0d4eb4365c3cba45c83b1022bf18db421a20752b Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:02:30 +0100 Subject: [PATCH 03/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index c02132d..20b03b7 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -7,7 +7,7 @@ RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" ### Variables for self updating -ScriptBranch="main" +ScriptBranch="selfupdate" ScriptArgs=( "$@" ) ScriptPath="$(readlink -f "$0")" ScriptName="$(basename "$ScriptPath")" From 9094bedfd3ac4741103dcea8b04f90367ba688e2 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:05:27 +0100 Subject: [PATCH 04/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 20b03b7..68c1d1b 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.31" +VERSION="v0.2.32" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" From 13549c2018b12de6d2895d4bd8b87c885edf1bb7 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:06:08 +0100 Subject: [PATCH 05/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 68c1d1b..ef7b298 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash VERSION="v0.2.32" Github="https://github.com/mag37/dockcheck" -RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh" +RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" ### Check if there's a new release of the script: LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" From 062c62d07184baf58c35aad7d60963dc40cef96c Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:06:41 +0100 Subject: [PATCH 06/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index ef7b298..57a0171 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.32" +VERSION="v0.2.33" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From 08ae7a8d235628b2dd9f7ba3f03d02fe3c2e4dee Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:21:31 +0100 Subject: [PATCH 07/21] Update dockcheck.sh --- dockcheck.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 57a0171..63cf2fd 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.33" +VERSION="v0.2.34" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" @@ -7,7 +7,7 @@ RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.s LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" ### Variables for self updating -ScriptBranch="selfupdate" +ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) ScriptArgs=( "$@" ) ScriptPath="$(readlink -f "$0")" ScriptName="$(basename "$ScriptPath")" @@ -43,10 +43,9 @@ self_update_git() { cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } git fetch - [ -n "$(git diff --name-only "origin/$ScriptBranch" "$ScriptName")" ] && { + [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." - git pull --force - git checkout "$ScriptBranch" + git checkout "$ScriptUpstream" git pull --force echo "Running the new version..." cd - || { printf "Path error.\n" ; return ; } From 6cd90e45975994e785e90b5178ee25bc354f32bd Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:27:13 +0100 Subject: [PATCH 08/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 63cf2fd..6495a2e 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.34" +VERSION="v0.2.35" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From 76337ee32695dbcb61ca14bdef98597066514467 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:31:20 +0100 Subject: [PATCH 09/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 6495a2e..2fa3e60 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -45,7 +45,7 @@ self_update_git() { git fetch [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." - git checkout "$ScriptUpstream" + # git checkout "$ScriptUpstream" git pull --force echo "Running the new version..." cd - || { printf "Path error.\n" ; return ; } From d366d4680cbf939a5476c3f32d39224d6a11c293 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 20:31:38 +0100 Subject: [PATCH 10/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 2fa3e60..674f82e 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.35" +VERSION="v0.2.36" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From e677d8513b610648ca6fc4ff7552521392ed084d Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 21:25:32 +0100 Subject: [PATCH 11/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 674f82e..3fabe3f 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.36" +VERSION="v0.2.37" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From e4cf54c16634e6a1b2b501c86d6db84cbc60a929 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 21:27:18 +0100 Subject: [PATCH 12/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 3fabe3f..7cacd22 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -7,7 +7,6 @@ RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.s LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" ### Variables for self updating -ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) ScriptArgs=( "$@" ) ScriptPath="$(readlink -f "$0")" ScriptName="$(basename "$ScriptPath")" @@ -42,6 +41,7 @@ shift "$((OPTIND-1))" self_update_git() { cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } + ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) git fetch [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." From 0fb95ea616b3fe8f8aca6b604293bf93d049e5cd Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 21:28:25 +0100 Subject: [PATCH 13/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 7cacd22..4688a44 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.37" +VERSION="v0.2.38" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From fd67e0dff1254402399d7a3b5a314341636a339d Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 4 Mar 2023 21:35:47 +0100 Subject: [PATCH 14/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index 4688a44..063d82d 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -41,7 +41,7 @@ shift "$((OPTIND-1))" self_update_git() { cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } - ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) + ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) || { printf "Script not in cloned directory, skipping update.\n" ; return ; } git fetch [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." From 4a2bc2dded8d365e04179f6dfb764430c0f06fa6 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 13:50:28 +0100 Subject: [PATCH 15/21] Cleaning Quoted a variable, reformatted a message --- dockcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 063d82d..f3dae47 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -41,13 +41,13 @@ shift "$((OPTIND-1))" self_update_git() { cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } - ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{upstream}) || { printf "Script not in cloned directory, skipping update.\n" ; return ; } + ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}") || { printf "Script not in cloned directory, skipping update.\n" ; return ; } git fetch [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." # git checkout "$ScriptUpstream" git pull --force - echo "Running the new version..." + printf "%s\n" "--- starting over with the updated version ---" cd - || { printf "Path error.\n" ; return ; } exec "$ScriptPath" "${ScriptArgs[@]}" # run the new script with old arguments exit 1 # exit the old instance From bcc0c63413a65932fe1c80bc4d5d5ef9ae390636 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 14:08:56 +0100 Subject: [PATCH 16/21] rearranged functions Moved up choosecontainer-function to the rest of the functions. Cleaning. --- dockcheck.sh | 60 +++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index f3dae47..64768ed 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.38" +VERSION="v0.2.39" Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" @@ -65,14 +65,41 @@ self_update_curl() { printf "curl not available - download the update manually: %s \n" "$RawUrl" fi } -if [ "$VERSION" != "$LatestRelease" ] ; then - printf "New version available! Local: %s - Latest: %s \n" "$VERSION" "$LatestRelease" +self_update_select() { read -r -p "Choose update procedure (or do it manually) - git/curl/[no]: " SelfUpQ if [[ "$SelfUpQ" == "git" ]]; then self_update_git ; elif [[ "$SelfUpQ" == "curl" ]]; then self_update_curl ; else printf "Download it manually from the repo: %s \n\n" "$Github" fi -fi +} + +### Choose from list -function: +choosecontainers() { + while [[ -z "$ChoiceClean" ]]; do + read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice + if [[ "$Choice" =~ [qQnN] ]] ; then + exit 0 + elif [[ "$Choice" =~ [aAyY] ]] ; then + SelectedUpdates=( "${GotUpdates[@]}" ) + ChoiceClean=${Choice//[,.:;]/ } + else + ChoiceClean=${Choice//[,.:;]/ } + for CC in $ChoiceClean ; do + if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds + echo "Number not in list: $CC" ; unset ChoiceClean ; break 1 + else + SelectedUpdates+=( "${GotUpdates[$CC-1]}" ) + fi + done + fi + done + printf "\nUpdating containers:\n" + printf "%s\n" "${SelectedUpdates[@]}" + printf "\n" +} + +### Version check & initiate self update +[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n" "$VERSION" "$LatestRelease" ; self_update_select ; } ### Set $1 to a variable for name filtering later. SearchName="$1" @@ -127,31 +154,6 @@ for i in "${GotUpdates[@]}"; do done } -### Choose from list -function: -choosecontainers() { - while [[ -z "$ChoiceClean" ]]; do - read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice - if [[ "$Choice" =~ [qQnN] ]] ; then - exit 0 - elif [[ "$Choice" =~ [aAyY] ]] ; then - SelectedUpdates=( "${GotUpdates[@]}" ) - ChoiceClean=${Choice//[,.:;]/ } - else - ChoiceClean=${Choice//[,.:;]/ } - for CC in $ChoiceClean ; do - if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]] ; then # reset choice if out of bounds - echo "Number not in list: $CC" ; unset ChoiceClean ; break 1 - else - SelectedUpdates+=( "${GotUpdates[$CC-1]}" ) - fi - done - fi - done - printf "\nUpdating containers:\n" - printf "%s\n" "${SelectedUpdates[@]}" - printf "\n" -} - ### Check the image-hash of every running container VS the registry for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do [[ " ${Excludes[*]} " =~ ${i} ]] && continue; # Skip if the container is excluded From 1decbd77b5a19ca7dd8670e2156692067f45b28d Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 14:18:57 +0100 Subject: [PATCH 17/21] cleaning Just minor cleaning, rearranging --- dockcheck.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 64768ed..62d2b25 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -133,10 +133,8 @@ fi $regbin version &> /dev/null || { printf "%s\n" "regctl is not working - try to remove it and re-download it, exiting."; exit 1; } ### Check docker compose binary: -if docker compose version &> /dev/null ; then - DockerBin="docker compose" -elif docker-compose -v &> /dev/null; then - DockerBin="docker-compose" +if docker compose version &> /dev/null ; then DockerBin="docker compose" ; +elif docker-compose -v &> /dev/null; then DockerBin="docker-compose" ; elif docker -v &> /dev/null; then printf "%s\n" "No docker compose binary available, using plain docker (Not recommended!)" printf "%s\n" "'docker run' will ONLY update images, not the container itself." From 3d7340c91c6e0606640600cc6f59229108cee184 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 20:44:05 +0100 Subject: [PATCH 18/21] added changenotes Addded a dirty way to write out latest changes. Will try to improve on this later. --- dockcheck.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 62d2b25..c512493 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,17 +1,19 @@ #!/usr/bin/env bash -VERSION="v0.2.39" +VERSION="v0.2.30" +### ChangeNotes: Nothing fancy, just testing Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" -### Check if there's a new release of the script: -LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" - ### Variables for self updating ScriptArgs=( "$@" ) ScriptPath="$(readlink -f "$0")" ScriptName="$(basename "$ScriptPath")" ScriptWorkDir="$(dirname "$ScriptPath")" +### Check if there's a new release of the script: +LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')" +LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")" + ### Help Function: Help() { echo "Syntax: dockcheck.sh [OPTION] [part of name to filter]" @@ -41,7 +43,7 @@ shift "$((OPTIND-1))" self_update_git() { cd "$ScriptWorkDir" || { printf "Path error, skipping update.\n" ; return ; } [[ $(builtin type -P git) ]] || { printf "Git not installed, skipping update.\n" ; return ; } - ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}") || { printf "Script not in cloned directory, skipping update.\n" ; return ; } + ScriptUpstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}") || { printf "Script not in git directory, skipping update.\n" ; return ; } git fetch [ -n "$(git diff --name-only "$ScriptUpstream" "$ScriptName")" ] && { printf "%s\n" "Pulling the latest version." @@ -99,7 +101,7 @@ choosecontainers() { } ### Version check & initiate self update -[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n" "$VERSION" "$LatestRelease" ; self_update_select ; } +[[ "$VERSION" != "$LatestRelease" ]] && { printf "New version available! Local: %s - Latest: %s \n Change Notes: %s \n" "$VERSION" "$LatestRelease" "$LatestChanges" ; self_update_select ; } ### Set $1 to a variable for name filtering later. SearchName="$1" From 5e58abd8e9b4380a622f2b7e50e7af0c592e728f Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 20:45:43 +0100 Subject: [PATCH 19/21] Update dockcheck.sh --- dockcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockcheck.sh b/dockcheck.sh index c512493..f1fc36e 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -VERSION="v0.2.30" +VERSION="v0.2.31" ### ChangeNotes: Nothing fancy, just testing Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh" From 9b6396f6dee2ae62dccf55b480616b4f08c0b223 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 21:13:23 +0100 Subject: [PATCH 20/21] cleaning quoting, added env-file check. --- errorCheck.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/errorCheck.sh b/errorCheck.sh index 13c632a..30ebe52 100755 --- a/errorCheck.sh +++ b/errorCheck.sh @@ -18,9 +18,10 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do echo -e "Service name:\t\t$ContName" echo -e "Project working dir:\t$ContPath" echo -e "Compose files:\t\t$ComposeFile" + echo -e "Environment files:\t$ContEnv" echo -e "Container image:\t$ContImage" echo echo "Mounts:" - docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' $i + docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }}{{ printf "\n" }}{{ end }}' "$i" echo done From afe97c9de5c98827868177a0d0c29579c4ab8048 Mon Sep 17 00:00:00 2001 From: mag37 Date: Sun, 5 Mar 2023 21:19:54 +0100 Subject: [PATCH 21/21] rdy for main All in all: - Added a self update function, calling either a curl or a git function to update the script. - Added a dirty changenote-message, will look into improvements later to not curl twice. --- dockcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index f1fc36e..cd634d9 100755 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="v0.2.31" -### ChangeNotes: Nothing fancy, just testing +VERSION="v0.2.3" +### ChangeNotes: Added self-updating git/curl-function and a dirty changenote. Github="https://github.com/mag37/dockcheck" RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/selfupdate/dockcheck.sh"