mode silent with -q to hide non error messages #1
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)/"
|
export PKG_PATH="${INSTALLURL}/$(uname -r)/packages-stable/$(machine)/"
|
||||||
|
|
||||||
CACHE_DIR=/var/cache/pkgupdate/
|
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://
|
# curl can only be used for http:// , it's quite complicated with https://
|
||||||
# due to the way pkg_add calls $FETCH_CMD
|
# due to the way pkg_add calls $FETCH_CMD
|
||||||
def_curl() {
|
def_curl() {
|
||||||
|
@ -38,7 +47,7 @@ check_cache() {
|
||||||
if cmp ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous
|
if cmp ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous
|
||||||
then
|
then
|
||||||
rm ${CACHE_DIR}/index.now
|
rm ${CACHE_DIR}/index.now
|
||||||
echo "No changes on the mirror."
|
silent "No changes on the mirror."
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
mv ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous
|
mv ${CACHE_DIR}/index.now ${CACHE_DIR}/index.previous
|
||||||
|
@ -51,7 +60,7 @@ check_cache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
do_http() {
|
do_http() {
|
||||||
echo "Updating using $1 protocol"
|
silent "Updating using $1 protocol"
|
||||||
check_cache
|
check_cache
|
||||||
def_curl
|
def_curl
|
||||||
pkg_add -u 2>&1 | grep -v "^Couldn't find updates for "
|
pkg_add -u 2>&1 | grep -v "^Couldn't find updates for "
|
||||||
|
@ -86,6 +95,11 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "-q" ]
|
||||||
|
then
|
||||||
|
SILENT=1
|
||||||
|
fi
|
||||||
|
|
||||||
case "$INSTALLURL" in
|
case "$INSTALLURL" in
|
||||||
http://*) do_http "http://"
|
http://*) do_http "http://"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue