"bsp040", "PROC" => "68k");
else
$trans = Array("KERNEL" => "bspppc", "PROC" => "ppc");
}
/******************************************
* Get the IP address if it is not known
*
*******************************************/
if (!isset($ip))
{
echo "\n";
?>
\n";
echo "
\n";
echo "\n";
echo "\n";
echo "{${$parameter}["select_ip"]} ";
echo " \n";
echo "\n";
echo "\n";
if (isset($bssid))
{
$tmpIp=bssid2ip($bssid);
echo "$tmpIp \n";
}
else
{
echo " \n";
echo "172.18.128.100 \n";
echo "172.18.128.101 \n";
echo "172.18.128.102 \n";
echo "172.18.128.103 \n";
echo "172.18.128.104 \n";
echo "172.18.128.105 \n";
echo "172.18.128.106 \n";
echo "172.18.128.107 \n";
echo "172.18.128.108 \n";
echo "172.18.128.109 \n";
echo "172.18.128.110 \n";
echo "172.18.128.111 \n";
}
echo " \n";
echo " \n";
echo " \n";
echo "\n";
echo "\n";
echo "{${$parameter}["system_type"]} ";
echo " \n";
echo "\n";
echo "\n";
echo " \n";
echo "BSC \n";
echo "BS Plus \n";
echo " \n";
echo " \n";
echo "
\n";
echo " ";
echo "{${$parameter}["swversion"]}: $version ";
echo " \n";
echo " \n";
echo " \n";
if (isset($bssid))
echo " ";
echo "\n";
echo "\n";
return;
}
/******************************************
* Mount the BSC /hd0 to /tmp/$$ directory
*******************************************/
$tmpdir = sprintf("%.3f",time()/1000);
$iwbox = ip2name($ip);
$path_prefix = "/tmp";
$cpu_type="iwp";
$url_temp=$_SERVER["REQUEST_URI"];
echo "This page URL:$url_temp ";
echo "$path_prefix/$iwbox ";
echo "version=$version ";
exit();
/***************************************************************************************
* PHP state machine
*
* Rename original build and create directory
* Format: it is a 2D array
* Array(
* Array('function','description','next state if != 0','next state if == 0'
* )
****************************************************************************************/
$cmdlist = Array(
's00' => Array ('system("/bin/ping -q -c 1 $ip >> /dev/null", $retval);return($retval);',
"{${$parameter}["ping"]} $iwbox ($ip) ...",
"kickout","s01"),
's01' => Array ('return(is_dir("$path_prefix/$iwbox"));',
"{${$parameter}["checkexist"]} $path_prefix/$iwbox",
"s03","s02"),
's02' => Array ('return(mkdir("$path_prefix/$iwbox",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox",
"s03","halt"),
's03' => Array ('system("/bin/umount $path_prefix/$iwbox", $retval);return($retval);',
"",
//"{${$parameter}["umounting"]} $path_prefix/$iwbox",
"s04","s03"),
's04' => Array ('system("/bin/mount $path_prefix/$iwbox", $retval);return($retval);',
"{${$parameter}["mounting"]} $path_prefix/$iwbox",
"halt","s10"),
's10' => Array ('return(is_dir(sprintf("$path_prefix/$iwbox/%s",strtoupper($version))));',
sprintf("{${$parameter}["checkexist"]} $path_prefix/$iwbox/%s",strtoupper($version)),
"s11","s20"),
's11' => Array ('return(rename(sprintf("$path_prefix/$iwbox/%s",strtoupper($version)),"$path_prefix/$iwbox/$tmpdir"));',
sprintf("{${$parameter}["rename"]} $path_prefix/$iwbox/%s --> $path_prefix/$iwbox/$tmpdir",strtoupper($version)),
"s20","halt"),
's20' => Array ('return(is_file("$path_prefix/$iwbox/BSCSTART"));',
sprintf("{${$parameter}["checkexist"]} $path_prefix/$iwbox/BSCSTART"),
"s21","s30"),
's21' => Array ('return(rename("$path_prefix/$iwbox/BSCSTART","$path_prefix/$iwbox/BSCSTART.OLD"));',
"{${$parameter}["rename"]} $path_prefix/$iwbox/BSCSTART --> $path_prefix/$iwbox/BSCSTART.OLD",
"s30","halt"),
's30' => Array ('return(is_file("$path_prefix/$iwbox/VXWORKS"));',
sprintf("{${$parameter}["checkexist"]} $path_prefix/$iwbox/VXWORKS"),
"s31","s40"),
's31' => Array ('return(rename("$path_prefix/$iwbox/VXWORKS","$path_prefix/$iwbox/VXWORKS"));',
"{${$parameter}["rename"]} $path_prefix/$iwbox/VXWORKS --> $path_prefix/$iwbox/VXWORKS",
"s40","halt"),
's40' => Array ('return(mkdir("$path_prefix/$iwbox/$version",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version",
"s41","halt"),
's41' => Array ('return(mkdir("$path_prefix/$iwbox/$version/compile",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/compile",
"s50","halt"),
's50' => Array ('return(mkdir("$path_prefix/$iwbox/$version/compile/68k",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/compile/68k",
"s60","halt"),
's60' => Array ('return(mkdir("$path_prefix/$iwbox/$version/compile/cfg",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/compile/cfg",
"s70","halt"),
's70' => Array ('return(mkdir("$path_prefix/$iwbox/$version/btskern",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/btskern",
"s80","halt"),
's80' => Array ('return(mkdir("$path_prefix/$iwbox/$version/trxxil",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/trxxil",
"s90","halt"),
's90' => Array ('return(mkdir("$path_prefix/$iwbox/$version/trxdsp",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/trxdsp",
"s100","halt"),
's100' => Array ('return(mkdir("$path_prefix/$iwbox/$version/mtdspb",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/mtdspb",
"s101","halt"),
's101' => Array ('return($version[3]>5);',
"{${$parameter}["check_version"]}",
"s110","s180"),
's110' => Array ('system("/bin/bin/strings /tmp/$iwbox/VXWORKS|grep -i \"interWAVE IWP\"", $retval);return($retval);',
"{${$parameter}["check_cpu_board"]}",
"s111","s112"),
// CPU board is ICP rather than IWP
's111' => Array ('assign_cpu_type("iwp");return(0);',
"{${$parameter}["processor"]}: IWP",
"halt","s120"),
's112' => Array ('assign_cpu_type("icp");return(0);',
"{${$parameter}["processor"]}: ICP",
"halt","s120"),
's120' => Array ('return(mkdir("$path_prefix/$iwbox/$version/isr",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/isr",
"s130","halt"),
's130' => Array ('return(mkdir("$path_prefix/$iwbox/$version/iwlib",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/iwlib",
"s140","halt"),
's140' => Array ('return(mkdir("$path_prefix/$iwbox/$version/iwlib/platform",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/iwlib/platform",
"s150","halt"),
's150' => Array ('return(mkdir("$path_prefix/$iwbox/$version/iwlib/platform/bspppc",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/iwlib/platform/bspppc",
"s160","halt"),
's160' => Array ('return(mkdir("$path_prefix/$iwbox/$version/iwlib/platform/bsp040",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/iwlib/platform/bsp040",
"s170","halt"),
's170' => Array ('return(mkdir("$path_prefix/$iwbox/$version/compile/ppc",0700));',
"{${$parameter}["create_dir"]} $path_prefix/$iwbox/$version/compile/ppc",
"s180","halt"),
's180' => Array ('return(1);',
"*** {${$parameter}["remind"]} ***",
"s200","halt")
);
/*********************************************
* Get the array of BSS software filenames
*********************************************/
$index = 200;
$output = get_sw_filenames($version,"/home/build", $iwbox_type);
if ($debug)
{
echo " ";
foreach ($output as $files) echo "{${$parameter}["copy"]} $files[0] --> ./$files[1] ";
echo " ";
return;
}
foreach ($output as $files)
{
$tmp_array = Array(
"return(copy(\"" . strtr($files[0],$trans) . "\",\"/tmp/$iwbox/" . strtr($files[1],$trans) . "\"));",
"{${$parameter}["copy"]} $files[0] --> ./$files[1]",
sprintf("s%d",$index + 1),"halt"
);
$cmdlist = array_merge($cmdlist,Array("s$index" => $tmp_array));
$index++;
}
$cmdlist = array_merge($cmdlist, Array(
"s$index" => Array ('return(1);',
"*** {${$parameter}["cleanup"]} ***",
"cleanup","halt"),
"cleanup" => Array('return(is_dir("$path_prefix/$iwbox"));',
"{${$parameter}["checkexist"]} $path_prefix/$iwbox",
"umount","getout"),
"umount" => Array('system("/bin/umount $path_prefix/$iwbox", $retval);return($retval);',
"{${$parameter}["umounting"]} $path_prefix/$iwbox",
"rmdir","rmdir"),
"rmdir" => Array('return(rmdir("$path_prefix/$iwbox"));',
"{${$parameter}["rmdir"]} $path_prefix/$iwbox",
"getout","getout")
)
);
if (isset($debug))
{
foreach ($cmdlist as $key => $value)
{
echo "$key,$value[0],$value[1],$value[2],$value[3] ";
}
}
/*********************************************
* Execute the state machine here
*********************************************/
echo "{${$parameter}["heading"]} ";
echo "";
for ($state="s00" ; ; )
{
if (isset($debug))
echo strtr("{$cmdlist[$state][0]}\n$state: ",$trans);
echo strtr(${cmdlist}[$state][1],$trans);
flush();
$command = strtr(${cmdlist}[$state][0],$trans);
if (@eval($command))
$state = $cmdlist[$state][2];
else
$state = $cmdlist[$state][3];
if ($state == "getout")
{
echo " ... {${$parameter}["ok"]}\n";
break;
}
else if ($state == "kickout")
{
echo " ... {${$parameter}["not_ok"]}\n";
echo " ... {${$parameter}["failed"]} ";
echo "";
break;
}
else if ($state == "halt")
{
echo " ... {${$parameter}["not_ok"]}\n";
echo " ... {${$parameter}["failed"]} ";
echo "";
$state = "cleanup";
}
else
{
if (${cmdlist}[$state][1] != "")
echo " ... {${$parameter}["ok"]}\n";
}
}
echo " ... {${$parameter}["done"]} ";
?>