Files
snigdhaos-system-config/usr/local/bin/snigdhaos-fix-pacman-conf
2024-11-19 09:21:57 +05:30

59 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
echo
echo "Downloading Latest pacman.conf..."
echo
Online=0
file_boolean=0
function check_connectivity() {
local test_ip
local test_count
test_ip="8.8.8.8"
test_count=1
if ping -c ${test_count} ${test_ip} > /dev/null; then
echo "System Online!"
Online=1
else
echo "System Offline!"
Online=0
fi
}
function check_file() {
file="/usr/local/share/snigdhaos/pacman.conf"
if [[ -f $file ]];then
echo $file " Found."
file_boolean=1
else
echo $file " Not Found!"
file_boolean=0
fi
}
check_connectivity
check_file
if [ $Online -eq 1 ] ; then
echo "Downloading pacman.conf..."
# shellcheck disable=SC2154
# shellcheck disable=SC2086
sudo wget https://raw.githubusercontent.com/Snigdha-OS/snigdhaos-updater/master/pacman.conf -O $workdir/etc/pacman.conf
fi
if [ $Online -eq 0 ] && [ $file_boolean -eq 1 ] ; then
sudo cp /usr/local/share/snigdhaos/pacman.conf /etc/pacman.conf
echo "Copied pacman.conf..."
fi
if [ $Online -eq 0 ] && [ $file_boolean -eq 0 ] ; then
echo "Run this script once you are back online!"
fi
echo
echo "Task Completed!"
echo