I tried changing some things in my code and still it doesn't work :S
#!/bin/bash
function auto_net() {
welcome
}
function welcome() {
echo "Will your net include a server?"
read choice
if [ $choice -eq "Yes" ]; then
interface Server;
elif [ $choice -eq "No" ];
then
interface Default;
fi
}
function user_input() {
declare -a devices=("${!1}")
for((i=1; i <= $2; ++i)); do
device=$3
device="$device$i"
devices+=("$device")
done
for i in ${devices[@]}; do
echo $i
done
}
function interface() {
if[ "$1" -eq "Server" ];
then
set_up Server;
set_up Router;
set_up Switch;
set_up Host;
elif[ "$1" -eq "Default" ]; then
set_up Router;
set_up Switch;
set_up Host;
fi
}
function set_up (){
local routers=()
local hosts=()
local switches=()
if [ "$1" -eq "Router" ];
then
echo "How many routers are you going to configure?"
read router_number
user_input routers[@] router_number R
elif [ "$1" -eq "Switch" ];
then
echo "How many switches are there?"
read switch_number
user_input switches[@] switch_number S
elif [ $1 -eq "Host" ];
then
echo "How many hosts per switch? Type it in order"
read host_number
user_input hosts[@] host_number H
fi
}
auto_net
echo $?