mode silent with -q to hide non error messages
This commit is contained in:
parent
7bedf65ff7
commit
43038d5bcd
18
pkgupdate
18
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://"
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue