From 4b6bc5c0f017089bfb5a8cf61b3ad3d60b4b8532 Mon Sep 17 00:00:00 2001 From: David P Date: Thu, 17 May 2018 13:04:40 -0400 Subject: find-deprecated-pkgs: check if the system is connected to internet Signed-off-by: David P --- find-deprecated-pkgs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'find-deprecated-pkgs') diff --git a/find-deprecated-pkgs b/find-deprecated-pkgs index 3be7b0f..35ebd56 100755 --- a/find-deprecated-pkgs +++ b/find-deprecated-pkgs @@ -87,6 +87,14 @@ mkpkglist() { esac } +err() { + printf '%sError:%s %s\n' \ + "$(tput setaf 1)" \ + "$(tput sgr0)" \ + "$1" + false +} + check(){ mkpkglist $1 case $1 in @@ -100,11 +108,7 @@ check(){ grep ^$p $arch_pkgs &> /dev/null || printf '%s was not found\n' "$p" done ;; - *) printf '%sError:%s %s is not a valid argument\n' \ - "$(tput setaf 1)" \ - "$(tput sgr0)" \ - "$1" - false + *) err "$1 is not a valid argument" ;; esac } @@ -112,5 +116,6 @@ check(){ if [ -s $1 ]; then usage else - check $1 || STATUS=$? usage + ping -q -w 1 -c 1 `ip r | grep ^default | awk '{print $3}'` &> /dev/null || err 'You are not connected to internet' + check $1 || STATUS=$? usage fi -- cgit v1.2.2