Skip to content

Commit

Permalink
feat(): add install_required_packages function + fix /etc/best403unlo…
Browse files Browse the repository at this point in the history
…cker.conf url (#28)

* feat(): add install_required_packages function

* fix(): set correct /etc/best403unlocker.conf url

* feat(): add alpine support in install_required_packages()

* chore(): add touch file to .gitignore

* fix(): correct alpine and debain-based distributions installation

* chore(): remove touch from .gitignore

* fix(): correct alpine commands in install_required_packages()
  • Loading branch information
the-pesar authored Jul 14, 2024
1 parent f015e14 commit 5198e9d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode/settings.json
log.txt
log.txt
51 changes: 47 additions & 4 deletions best403unlocker
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,59 @@ if [ "$EUID" -ne 0 ]; then
exit 1
fi
}
install_required_packages(){
if [[ -f /etc/os-release ]]; then
source /etc/os-release

case $ID in
debian|ubuntu|mint|elementary)
apt update -y
apt install -y wget
;;
arch|manjaro|parch)
pacman -Sy --noconfirm wget
;;
fedora|rhel|centos|rocky|almalinux)
dnf install -y wget
;;
suse|opensuse)
zypper install -y wget
;;
alpine)
apk update
apk add --no-cache wget
;;
*)
echo "Unsupported OS. Please install wget manually." >& 2
exit 1
esac
else
echo "Unsupported OS. Please install wget manually." >& 2
exit 1
fi
}
check_required_packages_is_installed(){
if ! [ -x "$(command -v wget)" ]
then
echo "wget is not installed" >&2
exit 1
echo "wget is not installed"
read -p "Do you want to us install wget or cancel it? [Y/n]: " do_install

if [[ -z $do_install ||
$do_install == "Y" ||
$do_install == "y" ||
$do_install == "Yes" ||
$do_install == "yes"
]]; then
install_required_packages
else
echo "Please install wget manually" >& 2
exit 1
fi
fi
}
check_and_source_env() {
if [ ! -f /etc/best403unlocker.conf ]; then
wget -c https://raw.githubusercontent.com/ArmanTaheriGhaleTaki/best403unlocker/main/.env -O /etc/best403unlocker.conf
wget -c https://raw.githubusercontent.com/403unlocker/best403unlocker/main/best403unlocker.conf -O /etc/best403unlocker.conf
fi
source /etc/best403unlocker.conf
}
Expand Down Expand Up @@ -84,4 +127,4 @@ echo '*********************'
fi
loggin >> /var/log/best403unlocker.log
cat /etc/resolv.conf.bakup > /etc/resolv.conf
rm /etc/resolv.conf.bakup
rm /etc/resolv.conf.bakup

0 comments on commit 5198e9d

Please sign in to comment.