Subversion Repositories slis

Compare Revisions

Ignore whitespace Rev 5904 → Rev 5905

/slim/sources/trunk/slis-slim/scripts/ZDKS/make.php
114,8 → 114,7
$link_destdir .= "/output/{$slim_user->login}";
 
if (!file_exists($destdir."/.htaccess")) {
$htaccess="<LIMIT GET POST>\nrequire user
{$slim_user->login}\n</LIMIT>";
$htaccess="<LIMIT GET POST>\nrequire user {$slim_user->login}\n</LIMIT>";
$file = fopen($destdir."/.htaccess","w");
fputs($file,$htaccess);
fclose($file);
131,8 → 130,7
$dir=$download_dir ."/v". $dks_version;
}
if ( ! is_dir("$dir/$name") && ! mkdir("$dir/$name",0755,true) ) {
html_error("Error making setup disk for %s: Unable to create %s
directory !",$name,"$dir/$name");
html_error("Error making setup disk for %s: Unable to create %s directory !",$name,"$dir/$name");
}
}
 
146,11 → 144,8
}
}
 
function
do_slis_dks_generations(&$sliss,&$slim_user,&$download_dir,&$link_destdir)
{
lock_or_exit("/tmp/slim_make_dks.lock",1800,"Someone is already making DKS,
retry later...");
function do_slis_dks_generations(&$sliss,&$slim_user,&$download_dir,&$link_destdir) {
lock_or_exit("/tmp/slim_make_dks.lock",1800,"Someone is already making DKS, retry later...");
 
 
$destdir="";
198,25 → 193,21
update_slis_version(&$slis,&$dks_version);
 
if (!file_exists("$dir/MATRIX")) {
html_error("Error making setup disk for %s: Directory %s/MATRIX/
does not exists!",$name,$dir);
html_error("Error making setup disk for %s: Directory %s/MATRIX/ does not exists!",$name,$dir);
}
 
print "version = '".$slis->version ."'\n";
switch($slis->version) {
case "4.1":
$script .=
do_slis41_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script);
$script .= do_slis41_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script);
break;
default:
$script .=
do_slis3x_and_slis40_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script);
$script .= do_slis3x_and_slis40_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script);
 
break;
}
 
$script .=
do_finalize_dks(&$slis,&$dir,&$destdir,&$link_destdir,&$links,&$script);
$script .= do_finalize_dks(&$slis,&$dir,&$destdir,&$link_destdir,&$links,&$script);
}
 
$script .= addCustomScript(&$slis,&$download_dir);
230,9 → 221,7
unlink("/tmp/slim_make_dks.lock");
}
 
function
display_information($c,&$sliss,&$links,&$vtuncfg,&$local_host_names,&$download_dir)
{
function display_information($c,&$sliss,&$links,&$vtuncfg,&$local_host_names,&$download_dir) {
global $Slis,$slim_user;
// Print the links and server confs
if ($c==0) {
249,8 → 238,7
 
// VTUND CONFIG
if ($vtuncfg != "") {
$conf_report .= "## Append this to your vtund server config
file:<BR>\n";
$conf_report .= "## Append this to your vtund server config file:<BR>\n";
$conf_report .= "<PRE>\n$vtuncfg\n</PRE>\n";
$file=fopen("$download_dir/CONFS/vtund.conf","w");
fputs($file,$vtuncfg);
258,8 → 246,7
}
 
// LOCALHOSTNAMES (sendmail config)
$conf_report .= "<BR>\n## Append this to your
/etc/mail/local-host-names if necessary:<BR><PRE>\n";
$conf_report .= "<BR>\n## Append this to your /etc/mail/local-host-names if necessary:<BR><PRE>\n";
$conf_report .= $local_host_names ."\n</PRE>";
$file=fopen("$download_dir/CONFS/local-host-names","w");
fputs($file,$local_host_names);
267,8 → 254,7
 
 
// If the user has the right, print the confs on the screen
if ($slim_user->login == "admin" ||
$slim_user->has_right("make_server_configs")) {
if ($slim_user->login == "admin" || $slim_user->has_right("make_server_configs")) {
print $conf_report;
print "##################\n\n";
 
276,8 → 262,7
// Else, send the confs to the admin by email
else {
if ($conf_required) {
$header="From: Automatic SLIM mail ". $slim_user->name ." <".
$slim_user->email .">\nX-Mailer: PHP/";
$header="From: Automatic SLIM mail ". $slim_user->name ." <". $slim_user->email .">\nX-Mailer: PHP/";
$subject="SLIS configs required from ". $slim_user->name;
$data=$conf_report;
mail($mail_admin,$subject,$data,$header);
287,8 → 272,7
}
 
 
function
do_finalize_dks(&$slis,&$dir,&$destdir,&$link_destdir,&$links,&$script) {
function do_finalize_dks(&$slis,&$dir,&$destdir,&$link_destdir,&$links,&$script) {
// zip & gzip file creation
 
$name=$slis->name;
312,10 → 296,7
$script .= "mv -f $name $destdir\n";
 
 
$links .= "<LI><A
HREF=$link_destdir/$name-$subdir.zip>$name-$subdir.zip</A> or <A
HREF=$link_destdir/$name-$subdir.tar.gz>$name-$subdir.tar.gz</A> - <A
HREF=$link_destdir/$name.txt>$name.txt</A>\n";
$links .= "<LI><A HREF=$link_destdir/$name-$subdir.zip>$name-$subdir.zip</A> or <A HREF=$link_destdir/$name-$subdir.tar.gz>$name-$subdir.tar.gz</A> - <A HREF=$link_destdir/$name.txt>$name.txt</A>\n";
 
}
 
341,17 → 322,13
print "\nDone.\n";
}
 
function do_slis41_dks_generation(&$slis,
&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script) {
function do_slis41_dks_generation(&$slis, &$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script) {
// Needed to access to the object factories
global
$Pop,$Site,$Tunel,$Route,$Slis,$SlisGroup,$FileDefvalue,$HAdminUser,$IPAddress;
global $Pop,$Site,$Tunel,$Route,$Slis,$SlisGroup,$FileDefvalue,$HAdminUser,$IPAddress;
 
$def = new FileDefvalue();
$slis_defaults = $FileDefvalue->var_select("distinct
variable","file='slis41_slis.conf'","");
$lcs_defaults = $FileDefvalue->var_select("distinct
variable","file='slis41_lcs.conf'","");
$slis_defaults = $FileDefvalue->var_select("distinct variable","file='slis41_slis.conf'","");
$lcs_defaults = $FileDefvalue->var_select("distinct variable","file='slis41_lcs.conf'","");
 
$name = $slis->name;
 
372,8 → 349,7
$script .= "echo \"lcs-squirrelmail\">> ./$name/lcs.packages\n";
$script .= "echo \"lcs-web\">> ./$name/lcs.packages\n";
 
$script .= "echo \"# monitoring (activated in config)\">>
./$name/lcs.packages\n";
$script .= "echo \"# monitoring (activated in config)\">> ./$name/lcs.packages\n";
$script .= "echo \"slis-slim-node\">> ./$name/lcs.packages\n";
 
$script .= "echo \"# cyberschool package \">> ./$name/lcs.packages\n";
409,22 → 385,16
"%slis_version%" => $slis->version,
"%slis_gateway%" => $slis->ip_gateway,
"%slis_is_isdn%" => $slis->is_isdn,
"%slis_wan_ip%" => ( $slis->is_isdn == 't' ? $slis->ip_lan :
$slis->ip_wan),
"%slis_wan_netmask%" => ( $slis->is_isdn == 't' ?
$slis->netmask_lan : $slis->netmask_wan),
"%slis_wan_network%" => ( $slis->is_isdn == 't' ? $network_lan :
$network_wan),
"%slis_wan_cidr%" => ( $slis->is_isdn == 't' ? $cidr_lan :
$cidr_wan),
"%slis_wan_ip%" => ( $slis->is_isdn == 't' ? $slis->ip_lan : $slis->ip_wan),
"%slis_wan_netmask%" => ( $slis->is_isdn == 't' ? $slis->netmask_lan : $slis->netmask_wan),
"%slis_wan_network%" => ( $slis->is_isdn == 't' ? $network_lan : $network_wan),
"%slis_wan_cidr%" => ( $slis->is_isdn == 't' ? $cidr_lan : $cidr_wan),
"%slis_lan_ip%" => $slis->ip_lan,
"%slis_lan_netmask%" => $slis->netmask_lan,
"%slis_lan_network%" => $network_lan,
"%slis_lan_cidr%" => $cidr_lan,
"%is_cyberschool%" => ( $slis->is_cyber_school != 't' ? '0' :
'1'),
"%samba%" => ( $slis->is_cyber_school != 't' ? '0' :
'1'),
"%is_cyberschool%" => ( $slis->is_cyber_school != 't' ? '0' : '1'),
"%samba%" => ( $slis->is_cyber_school != 't' ? '0' : '1'),
"%fetchmail%" => ($slis->is_fetchmail != 't' ? '0' : '1' ),
"%gateway_type%" => $slis->gateway_type,
"%gateway_user%" => $slis->gateway_user,
436,28 → 406,21
$script .= "> $name/users\n";
$groups = & $SlisGroup->select("slis_name='$name'");
foreach ($groups as $slis_group) {
$users = & $HAdminUser->select("group_id='". $slis_group->group_id
."'");
$users = & $HAdminUser->select("group_id='". $slis_group->group_id ."'");
foreach ($users as $user) {
$script .= "htpasswd -b $name/users ". $user->login ." ".
$user->password ."\n";
$script .= "htpasswd -b $name/users ". $user->login ." ". $user->password ."\n";
$n_users++;
}
}
$users = & $HAdminUser->select("slis_name='$name'");
foreach ($users as $user) {
$script .= "htpasswd -b $name/users ". $user->login ." ".
$user->password ."\n";
$script .= "htpasswd -b $name/users ". $user->login ." ". $user->password ."\n";
$n_users++;
if ($user->login == 'admin') {
$varlist += array(
"%slis_admin_pass%" => $user->password
);
$varlist += array("%slis_admin_pass%" => $user->password);
}
}
$varlist += array(
"%slis_admin_pass%" => ""
);
$varlist += array("%slis_admin_pass%" => "");
 
if ($n_users == 0) {
print "WARNING: no admin user for slis $name!\n";
474,18 → 437,14
$mailhost=$pop->get_mailhost_name();
$varlist += array( "%pop_name%" => $pop->name,
"%dns_primary%" => ($pdns ? $pdns : ""),
"%dns_primary_ip%" => ($pdns ?
$IPAddress->get_router_ip_from_router_name($pdns) : ""),
"%dns_primary_ip%" => ($pdns ? $IPAddress->get_router_ip_from_router_name($pdns) : ""),
"%dns_secondary%" => ($sdns ? $sdns : ""),
"%dns_secondary_ip%" => ($sdns ?
$IPAddress->get_router_ip_from_router_name($sdns) : ""),
"%dns_secondary_ip%" => ($sdns ? $IPAddress->get_router_ip_from_router_name($sdns) : ""),
"%proxy%" => $proxy,
"%smtp_relay%" => ($smtp ? $smtp : ""),
"%smtp_relay_ip%" => ($smtp ?
$IPAddress->get_router_ip_from_router_name($smtp) : ""),
"%smtp_relay_ip%" => ($smtp ? $IPAddress->get_router_ip_from_router_name($smtp) : ""),
"%mailhost%" => ($mailhost ? $mailhost : ""),
"%mailhost_ip%" => ($mailhost ?
$IPAddress->get_router_ip_from_router_name($mailhost) : "")
"%mailhost_ip%" => ($mailhost ? $IPAddress->get_router_ip_from_router_name($mailhost) : "")
);
} else {
print "WARNING: Pop $pop_id not found for $name\n";
573,18 → 532,21
$script .= "\n# Tunel routes\n";
$script .= "> $name/routes.tun\n";
$tunnel=$tunnels[0];
$routes=& $Route->select("tunel_id='". $tunnel->id ."'"); if
($tunnel->type == "vtun") { $dev="tun0"; } elseif ($tunnel->type ==
"ipsec") { $dev="ipsec0"; } else { $dev="tun0"; }
$routes=& $Route->select("tunel_id='". $tunnel->id ."'");
if ($tunnel->type == "vtun") {
$dev="tun0";
} elseif ($tunnel->type == "ipsec") {
$dev="ipsec0";
} else {
$dev="tun0";
}
foreach ($routes as $route) {
$net=$route->network_name;
list($addr,$mask)=explode("/",$net);
if ($mask == "32") {
$script .= "echo \"/sbin/route add -host $addr $dev\" >>
$name/routes.tun\n";
$script .= "echo \"/sbin/route add -host $addr $dev\" >> $name/routes.tun\n";
} else {
$script .= "echo \"/sbin/route add -net $net $dev\" >>
$name/routes.tun\n";
$script .= "echo \"/sbin/route add -net $net $dev\" >> $name/routes.tun\n";
}
}
}
602,10 → 564,16
$script .= "# End of custom script\n\n";
}
 
if ($pop) { $numbers=& $pop->get_lines();
if ($numbers) { $number=$numbers[0]->number; $numip=substr($number,1);}
else { $number="PPP NUMBER NOT FOUND INTO SLIM"; $numip=$number;}
} else { $number="PPP NUMBER NOT FOUND INTO SLIM"; }
if ($pop) {
$numbers=& $pop->get_lines();
if ($numbers) {
$number=$numbers[0]->number; $numip=substr($number,1);
} else {
$number="PPP NUMBER NOT FOUND INTO SLIM"; $numip=$number;
}
} else {
$number="PPP NUMBER NOT FOUND INTO SLIM";
}
 
$varlist = array("XXXIPADDRXXX" => $slis->ip_gateway,
"XXXSLISIPXXX" => $slis->ip_wan,
637,16 → 605,12
fclose ($file);
}
 
function
do_slis3x_and_slis40_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script)
{
function do_slis3x_and_slis40_dks_generation(&$slis,&$dir,&$download_dir,&$local_host_names,&$vtuncfg,&$script) {
// Needed to access to the object factories
global
$Pop,$Site,$Tunel,$Route,$Slis,$SlisGroup,$FileDefvalue,$HAdminUser,$IPAddress;
global $Pop,$Site,$Tunel,$Route,$Slis,$SlisGroup,$FileDefvalue,$HAdminUser,$IPAddress;
 
$def=new FileDefvalue();
$file_defaults=$FileDefvalue->var_select("distinct
variable","file='setup.data'","");
$file_defaults=$FileDefvalue->var_select("distinct variable","file='setup.data'","");
 
// Prepare some variables we'll use later
$name=$slis->name;
736,15 → 700,12
if ($smtp) {
$script .= " SMTP_OUT::\"$smtp\" \\\n";
$script .= " RELAY_HOST::\"$smtp\" \\\n";
$script .= " SMTP_OUT_IP::\"".
$IPAddress->get_router_ip_from_router_name($smtp) ."\" \\\n";
$script .= " SMTP_OUT_IP::\"". $IPAddress->get_router_ip_from_router_name($smtp) ."\" \\\n";
}
$mailhost=$pop->get_mailhost_name();
if ($mailhost) {
$script .= " SMART_HOST::\"$mailhost\" \\\n";
$script .= " SMART_HOST_IP::\"".
$IPAddress->get_router_ip_from_router_name($mailhost) ."\"
\\\n";
$script .= " SMART_HOST_IP::\"". $IPAddress->get_router_ip_from_router_name($mailhost) ."\" \\\n";
}
}
else {
772,10 → 733,8
$vtuncfg .= " encr yes;\n";
$vtuncfg .= " keepalive no;\n";
$vtuncfg .= " up {\n";
$vtuncfg .= " programm /usr/local/sbin/killtun \"".
$tun->login ." ". $tun->tun_slis_ip ." %d\" wait;\n";
$vtuncfg .= " ifconfig \"%% ". $tun->tun_svr_ip ."
pointopoint ". $tun->tun_slis_ip ." mtu 1350\";\n";
$vtuncfg .= " programm /usr/local/sbin/killtun \"". $tun->login ." ". $tun->tun_slis_ip ." %d\" wait;\n";
$vtuncfg .= " ifconfig \"%% ". $tun->tun_svr_ip ." pointopoint ". $tun->tun_slis_ip ." mtu 1350\";\n";
$vtuncfg .= " };\n";
$vtuncfg .= "}\n\n";
}
783,7 → 742,8
$script .= " IPSEC::\"1\" \\\n";
$script .= " IPSEC_SERVER::\"". $tun->server_ip ."\" \\\n";
$script .= " IPSEC_SLIS_ID::\"". $tun->login ."\" \\\n";
$script .= " IPSEC_PUBKEY::\"". $tun->password ."\" \\\n"; }
$script .= " IPSEC_PUBKEY::\"". $tun->password ."\" \\\n";
}
}
 
// Default customized variables (file_default table)
833,18 → 793,15
$script .= "> $name/users\n";
$groups = & $SlisGroup->select("slis_name='$name'");
foreach ($groups as $slis_group) {
$users = & $HAdminUser->select("group_id='". $slis_group->group_id
."'");
$users = & $HAdminUser->select("group_id='". $slis_group->group_id ."'");
foreach ($users as $user) {
$script .= "htpasswd -b $name/users ". $user->login ." ".
$user->password ."\n";
$script .= "htpasswd -b $name/users ". $user->login ." ". $user->password ."\n";
$n_users++;
}
}
$users = & $HAdminUser->select("slis_name='$name'");
foreach ($users as $user) {
$script .= "htpasswd -b $name/users ". $user->login ." ".
$user->password ."\n";
$script .= "htpasswd -b $name/users ". $user->login ." ". $user->password ."\n";
$n_users++;
}
if ($n_users == 0) {
857,18 → 814,21
$script .= "\n# Tunel routes\n";
$script .= "> $name/routes.tun\n";
$tunnel=$tunnels[0];
$routes=& $Route->select("tunel_id='". $tunnel->id ."'"); if
($tunnel->type == "vtun") { $dev="tun0"; } elseif ($tunnel->type ==
"ipsec") { $dev="ipsec0"; } else { $dev="tun0"; }
$routes=& $Route->select("tunel_id='". $tunnel->id ."'");
if ($tunnel->type == "vtun") {
$dev="tun0";
} elseif ($tunnel->type == "ipsec") {
$dev="ipsec0";
} else {
$dev="tun0";
}
foreach ($routes as $route) {
$net=$route->network_name;
list($addr,$mask)=explode("/",$net);
if ($mask == "32") {
$script .= "echo \"/sbin/route add -host $addr $dev\" >>
$name/routes.tun\n";
$script .= "echo \"/sbin/route add -host $addr $dev\" >> $name/routes.tun\n";
} else {
$script .= "echo \"/sbin/route add -net $net $dev\" >>
$name/routes.tun\n";
$script .= "echo \"/sbin/route add -net $net $dev\" >> $name/routes.tun\n";
}
}
}
888,10 → 848,16
//$sliss =& $Slis->select($cond,"name");
//$Slis->applyRestriction(&$sliss, "make_dks");
 
if ($pop) { $numbers=& $pop->get_lines();
if ($numbers) { $number=$numbers[0]->number; $numip=substr($number,1);}
else { $number="PPP NUMBER NOT FOUND INTO SLIM"; $numip=$number;}
} else { $number="PPP NUMBER NOT FOUND INTO SLIM"; }
if ($pop) {
$numbers=& $pop->get_lines();
if ($numbers) {
$number=$numbers[0]->number; $numip=substr($number,1);
} else {
$number="PPP NUMBER NOT FOUND INTO SLIM"; $numip=$number;
}
} else {
$number="PPP NUMBER NOT FOUND INTO SLIM";
}
 
$varlist = array("XXXIPADDRXXX" => $slis->ip_gateway,
"XXXSLISIPXXX" => $slis->ip_wan,
932,10 → 898,8
$vtuncfg .= " encr yes;\n";
$vtuncfg .= " keepalive no;\n";
$vtuncfg .= " up {\n";
$vtuncfg .= " programm /usr/local/sbin/killtun \"". $tun->login
." ". $tun->tun_slis_ip ." %d\" wait;\n";
$vtuncfg .= " ifconfig \"%% ". $tun->tun_svr_ip ." pointopoint ".
$tun->tun_slis_ip ." mtu 1350\";\n";
$vtuncfg .= " programm /usr/local/sbin/killtun \"". $tun->login ." ". $tun->tun_slis_ip ." %d\" wait;\n";
$vtuncfg .= " ifconfig \"%% ". $tun->tun_svr_ip ." pointopoint ". $tun->tun_slis_ip ." mtu 1350\";\n";
$vtuncfg .= " };\n";
$vtuncfg .= "}\n\n";
}
949,12 → 913,10
$form = new Form();
$form->set_title("Selection des SLIS a generer");
if ($_POST['history_date']){
$form->add_field(new
HiddenField("history_date",$_POST['$history_date'],"Date"));
$form->add_field(new HiddenField("history_date",$_POST['$history_date'],"Date"));
$form->add_field(new HiddenField("slis_name",$slis->name,"Nom"));
} else {
$form->add_field(new FormField("slis_name", "Nom", $_POST['slis_name'],
0));
$form->add_field(new FormField("slis_name", "Nom", $_POST['slis_name'], 0));
}
$fi = new CheckboxField("strict_s", "Strict", $_POST['strict_s']);
if ($history_date){
966,25 → 928,18
// $form->add_field(new CheckboxField("strict_s", "Strict",
// $strict_s),$preview == "auto");
 
$form->add_field(new OptionField("status_id", "Status",
$Status->get_status_list(), $_POST['status_id'], 0));
$form->add_field(new OptionField("type", "Type", $Slis->get_types(),
$_POST['type'], 0));
$form->add_field(new OptionField("pop_id", "Pop", $Pop->get_pop_list(),
$_POST['pop_id'], 0));
$form->add_field(new OptionField("installer", "Installateur",
$Installer->get_installer_list(), $_POST['installer'], 0));
$form->add_field(new OptionField("status_id", "Status", $Status->get_status_list(), $_POST['status_id'], 0));
$form->add_field(new OptionField("type", "Type", $Slis->get_types(), $_POST['type'], 0));
$form->add_field(new OptionField("pop_id", "Pop", $Pop->get_pop_list(), $_POST['pop_id'], 0));
$form->add_field(new OptionField("installer", "Installateur", $Installer->get_installer_list(), $_POST['installer'], 0));
if ($_POST['date']) { $today=$_POST['date']; }
#else { $today=date("Y-m-d"); }
$form->add_field(new FormField("date", "Date de creation posterieure a",
"$today", 0));
$form->add_field(new TextField("request", "Requete avancee",
$_POST['request'],4,20,1));
$form->add_field(new FormField("date", "Date de creation posterieure a", "$today", 0));
$form->add_field(new TextField("request", "Requete avancee", $_POST['request'],4,20,1));
# $form->add_field(new CheckboxField("conf_required", "Envoyer requete de
# conf a l'administrateur du domaine", "0"));
$form->add_field(new LineField());
$form->add_field(new OptionField("dks_version", "Version to use",
$dks_version_list, $_POST['dks_version'], 0));
$form->add_field(new OptionField("dks_version", "Version to use", $dks_version_list, $_POST['dks_version'], 0));
$form->add_button(new Button("Preview", "preview"));
$form->add_button(new Button("Make", "ok"));
print $form->build_code();
1051,8 → 1006,7
if ($handle = opendir($download_dir)) {
while (false !== ($file = readdir($handle))) {
// print ($file."<br>");
if ($file != "." && $file != ".." &&
is_dir($download_dir."/".$file)) {
if ($file != "." && $file != ".." && is_dir($download_dir."/".$file)) {
if (strpos($file,"v")==0 && strpos($file,"dks")>-1)
$retval[substr($file,1)] = $file ; //substr($file,1);
}