From dc4300c32ec98092c66be341e0a024ea9028e2c1 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Tue, 19 Nov 2024 10:06:22 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(improve):=20better=20?= =?UTF-8?q?error=20handling=20and=20concise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/local/bin/snigdhaos-prober | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/usr/local/bin/snigdhaos-prober b/usr/local/bin/snigdhaos-prober index cc1f786..5ab89b5 100755 --- a/usr/local/bin/snigdhaos-prober +++ b/usr/local/bin/snigdhaos-prober @@ -1 +1,44 @@ -#!/bin/bash \ No newline at end of file +#!/bin/bash + +# Function to check internet connectivity +check_connectivity() { + local test_ip="8.8.8.8" + if ping -c 1 "$test_ip" &> /dev/null; then + echo "System Online! Proceeding with installation." + else + echo "Error: No internet connection. Please check your connection and try again." + exit 1 + fi +} + +# Function to check if the package is already installed +check_package_installed() { + if pacman -Q hw-probe &> /dev/null; then + echo "hw-probe is already installed." + exit 0 + fi +} + +echo +echo "Checking internet connectivity..." +check_connectivity + +echo +echo "Checking if hw-probe is already installed..." +check_package_installed + +echo +echo "Installing hw-probe..." +echo + +# Install the package +if sudo pacman -S --noconfirm --needed hw-probe; then + echo "hw-probe has been installed successfully!" +else + echo "Error: Failed to install hw-probe. Please check the output above." + exit 1 +fi + +echo +echo "Task Completed!" +echo