#!/usr/bin/env bash

#checks if a command exists
function command_exists
{
    if [[ ! -a $(which $1) ]]; then 
	echo " no";
	echo "    Warning, you don't have the command \"$1\"";
    else
	echo " yes";
    fi;
}

#check for commands
function check_commands
{
    for a in $@;
    do
      echo -n "Checking for \"$a\" command..."
      command_exists $a;
    done;
}

#main script starts here :

echo
echo "Configuring Network-config :"
echo

#root check
if [ "$(id -u)" != "0" ]; then
   echo "    Warning, this script must be run as root !"
   echo;
fi;

commands=(perl echo cat grep sort ifconfig iwconfig iwlist route \
iptables wpa_supplicant modprobe modinfo)

check_commands ${commands[@]}

echo
echo "Type \"make\" and after that \"make install\"."
echo