mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-18 21:24:28 +05:00
adding dependencie check on startup
checks for some packages installed which are necessary for the script to work properly. fixes some crashes when calling for wget or unzip while not having those packages already installed.
This commit is contained in:
31
kiauh.sh
31
kiauh.sh
@@ -87,6 +87,37 @@ check_euid(){
|
||||
fi
|
||||
}
|
||||
|
||||
### check for package dependencies
|
||||
dependency_check(){
|
||||
package=(curl wget virtualenv unzip git)
|
||||
|
||||
for pkg in "${package[@]}"; do
|
||||
if ! command -v $pkg >&/dev/null 2>&1
|
||||
then
|
||||
install+=($package)
|
||||
fi
|
||||
done
|
||||
|
||||
if ! [ ${#install[@]} -eq 0 ]
|
||||
then
|
||||
status_msg "The following packages are missing:"
|
||||
echo -e "${red}${install[@]}${default}"
|
||||
status_msg "They are necessary for this script to work."
|
||||
status_msg "Please install them now or do it manually!"
|
||||
echo
|
||||
while true; do
|
||||
read -p "Do you want to install them now? (Y/n): " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo; status_msg "Installing dependencies ..."
|
||||
sudo apt install ${install[@]} -y && echo && confirm_msg "Dependencies successfully installed!"; echo; break;;
|
||||
N|n|No|no) break;;
|
||||
*) warn_msg "Unknown parameter: $yn"; echo;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
### checking for existing installations on startup
|
||||
start_check(){
|
||||
check_files
|
||||
|
||||
Reference in New Issue
Block a user