@@ -94,15 +94,42 @@ generate_ascii_art "CodePerfectPlus" "yellow"
9494
9595# function to check for required dependencies
9696check_dependencies () {
97- local dependencies=(git curl wget unzip figlet locust iptables)
97+ # List of required dependencies
98+ local dependencies=(git curl wget unzip iptables)
99+
100+ # Check if `apt-get` is available
101+ if ! command -v apt-get & > /dev/null; then
102+ log " ERROR" " This script requires apt-get but it is not available."
103+ exit 1
104+ fi
105+
106+ # Array to keep track of missing dependencies
107+ local missing_dependencies=()
108+
109+ # Check each dependency
98110 for cmd in " ${dependencies[@]} " ; do
99- if ! command -v $cmd & > /dev/null; then
100- log " CRITICAL" " $cmd is required but not installed. Please install it and try again.\nsudo apt install $cmd "
101- exit 1
111+ if ! command -v " $cmd " & > /dev/null; then
112+ missing_dependencies+=(" $cmd " )
102113 fi
103114 done
115+
116+ # If there are missing dependencies, prompt the user for installation
117+ if [ ${# missing_dependencies[@]} -gt 0 ]; then
118+ log " The following dependencies are missing: ${missing_dependencies[*]} "
119+ echo " Do you want to install them now? (y/n)"
120+ read -r choice
121+ if [ " $choice " == " y" ]; then
122+ sudo apt-get install -y " ${missing_dependencies[@]} "
123+ else
124+ log " Please install the required dependencies and run the script again."
125+ exit 1
126+ fi
127+ else
128+ log " All required dependencies are already installed."
129+ fi
104130}
105- check_dependencies
131+
132+
106133
107134# Function to set systemguard_auto_update variable permanently
108135set_auto_update () {
@@ -579,6 +606,7 @@ display_credentials() {
579606
580607# Install function
581608install () {
609+ check_dependencies
582610 log " Starting installation of $APP_NAME ..."
583611 create_and_own_dir " $EXTRACT_DIR "
584612 echo " "
0 commit comments