From 8e59d066dc41da8eeef632f38aa41dd2e9d05a1a Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Sun, 4 Jun 2023 19:38:42 +0200 Subject: [PATCH] =?UTF-8?q?Remaniement=20:=20r=C3=A9-=C3=A9criture=20de=20?= =?UTF-8?q?updateall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/updateall | 42 +++++++++++++++++-------------- share/updateall/commands.d/apt | 1 + share/updateall/commands.d/docker | 2 +- share/updateall/commands.d/git | 1 + share/updateall/commands.d/yay | 1 + 5 files changed, 27 insertions(+), 20 deletions(-) mode change 100755 => 100644 bin/updateall diff --git a/bin/updateall b/bin/updateall old mode 100755 new mode 100644 index d358231..dc6569c --- a/bin/updateall +++ b/bin/updateall @@ -1,28 +1,32 @@ #!/bin/bash -# Variable -commands_d="${HOME}/.local/share/updateall/commands.d" +# Variables +realpath="$(readlink -f "$0")" -# Function -# Create a clear separator, adapts to the screen size -function separator { - local separator="" +# cd +cd "$(dirname "$realpath")/../share/$(basename "$realpath")" || exit +unset realpath - local name="$1" ; shift - local char="${1:-=}"; shift - (( cols = $(tput cols) / 3 )) - - while [[ ${#separator} -le "$cols" ]]; do - separator+="$char" +# Fonction pour fabriquer une ligne de la longueur d'un tiers du terminal +makeline() { + local cols line + cols="$(($(tput cols) / 3))" + while [ "${#line}" -lt "$cols" ]; do + line="${line}${1}" done - - printf '\n%s\n\t%s\n%s\n' "$separator" "$name" "$separator" + printf %s "$line" } -# Loop -for pm in "${commands_d}/"*; do - separator "$(basename "$pm")" - # shellcheck source=/dev/null - source "$pm" +# Fonction pour afficher un séparateur +separator() { + local line + line="$(makeline '=')" + printf '\n%s\n\t%s\n%s\n' "$line" "$*" "$line" +} + +# Procédure principale +for i in ./commands.d/*; do + separator "$(basename "$i")" + "$i" done diff --git a/share/updateall/commands.d/apt b/share/updateall/commands.d/apt index a5ee70a..15b71d2 100644 --- a/share/updateall/commands.d/apt +++ b/share/updateall/commands.d/apt @@ -1,3 +1,4 @@ +#!/bin/sh sudo apt-get update sudo apt-get upgrade sudo apt-get autoremove diff --git a/share/updateall/commands.d/docker b/share/updateall/commands.d/docker index 13f6841..ca047a9 100644 --- a/share/updateall/commands.d/docker +++ b/share/updateall/commands.d/docker @@ -1,3 +1,3 @@ +#!/bin/sh sudo docker images --format '{{.Repository}}' | xargs -L 1 sudo docker pull -sudo docker image prune diff --git a/share/updateall/commands.d/git b/share/updateall/commands.d/git index f9281e1..b50afb7 100644 --- a/share/updateall/commands.d/git +++ b/share/updateall/commands.d/git @@ -1,3 +1,4 @@ +#!/bin/sh if pushd ~/Git; then for repo in *; do pushd "$repo" diff --git a/share/updateall/commands.d/yay b/share/updateall/commands.d/yay index 2a4ec99..0a3b2f0 100644 --- a/share/updateall/commands.d/yay +++ b/share/updateall/commands.d/yay @@ -1,2 +1,3 @@ +#!/bin/sh yay -Fy yay