#! /bin/bash
# Depends: aircrack-ng, xterm|urxvt|gnome-terminal, awk, macchanger, grep, bash >= 4
# Recommends: mdk3, wlandecrypter, jazzteldecrypter

# Copyright (C) 2008 Daouid
# Copyright (C) 2009, 2010 David Francos Cuartero
# See Authors for a more detailed authors spec.
#        This program is free software; you can redistribute it and/or
#        modify it under the terms of the GNU General Public License
#        as published by the Free Software Foundation; either version 2
#        of the License, or (at your option) any later version.

#        This program is distributed in the hope that it will be useful,
#        but WITHOUT ANY WARRANTY; without even the implied warranty of
#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#        GNU General Public License for more details.

#        You should have received a copy of the GNU General Public License
#        Along with this program; if not, write to the Free Software
#        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

declare -a enabled_plugins
declare -a p_menu

_source(){
    for cfile in $1; do
        if [ -f $cfile ] && [ -O $cfile ]; then source $cfile; echo "Loading $cfile";
        else if [ "$debug" == 1 ]; then echo "Could not load $cfile"; sleep 0.2 ;fi; fi
    done
}

# We preload functions, configs and themes in a cool way.
_source "./airoscript-ng.conf.devel ~/.airoscript-ng/airoscript-ng.conf /etc/airoscript-ng.conf /usr/local/etc/airoscript-ng.conf"
_source "$path/_internal $path/menu $path/interface" 
_source  "$path/themes/$theme" || default_theme
_source ${enabled_plugins[@]};

# For locale debugging
_debug "Text domain dir is $TEXTDOMAINDIR and textdomain is $TEXTDOMAIN"

# Whoah, this looks chaotic. I like it ^^
setaircrackpaths
rootwarn
setps
setargs $@
check_cardctl
#debug
warn "$mark Welcome to airoscript, have a nice day"
reso
temporary_switch_clear
setinterface "start"
temporary_switch_clear

[[ "$noscan" != 1 ]] && autoscan
mainmenu
