From 78ef75019ec2b08ab432e3f5b8588694fc414a29 Mon Sep 17 00:00:00 2001 From: jorge-aceves Date: Mon, 8 Apr 2019 10:30:48 -0500 Subject: [PATCH] Check if there is internet before starting --- bin/check_sites | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/check_sites b/bin/check_sites index 35357bf..850c1f0 100755 --- a/bin/check_sites +++ b/bin/check_sites @@ -3,6 +3,17 @@ fail_hooks = Dir.glob('hooks/fail/*.*') okay_hooks = Dir.glob('hooks/okay/*.*') +reliable_website = 'www.google.com' + +check_internet_command = "ping #{reliable_website} -c 1 &>/dev/null" + +internet_is_ok = system(check_internet_command) + +unless internet_is_ok + puts 'Computer is offline. Will not check sites' + exit 1 +end + Dir.glob('sites/*').each do |site_file| prefix = "#{site_file.rjust(30, ' ')}"