From 43038d5bcd238138e76d56b27c2fea89cd9c3dfc Mon Sep 17 00:00:00 2001 From: Solene Rapenne Date: Sun, 29 Aug 2021 12:09:07 +0200 Subject: [PATCH] mode silent with -q to hide non error messages --- pkgupdate | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgupdate b/pkgupdate index 44e5a1d..49c1f7e 100755 --- a/pkgupdate +++ b/pkgupdate @@ -4,8 +4,17 @@ INSTALLURL=$(grep -v ^# /etc/installurl | head -n 1) export PKG_PATH="${INSTALLURL}/$(uname -r)/packages-stable/$(machine)/" CACHE_DIR=/var/cache/pkgupdate/ +SILENT=0 +# hide output if SILENT is activated +silent() { + if [ "$SILENT" -eq 0 ] + then + echo "$1" + fi +} + # curl can only be used for http:// , it's quite complicated with https:// # due to the way pkg_add calls $FETCH_CMD def_curl() { @@ -38,7 +47,7 @@ check_cache() { if cmp ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous then rm ${CACHE_DIR}/index.now - echo "No changes on the mirror." + silent "No changes on the mirror." exit 0 else mv ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous @@ -51,7 +60,7 @@ check_cache() { } do_http() { - echo "Updating using $1 protocol" + silent "Updating using $1 protocol" check_cache def_curl pkg_add -u 2>&1 | grep -v "^Couldn't find updates for " @@ -86,6 +95,11 @@ then exit 1 fi +if [ "$1" = "-q" ] +then + SILENT=1 +fi + case "$INSTALLURL" in http://*) do_http "http://" ;;