Merge pull request 'mode silent with -q to hide non error messages' (#1) from silent_mode into hacker

Reviewed-on: #1
This commit is contained in:
solene 2021-08-29 10:11:39 +00:00
commit 14538a5409
1 changed files with 16 additions and 2 deletions

View File

@ -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://"
;;