diff options
author | Bill Marquette <bill.marquette@gmail.com> | 2009-02-06 19:18:00 -0600 |
---|---|---|
committer | Bill Marquette <bill.marquette@gmail.com> | 2009-02-06 19:18:00 -0600 |
commit | 55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1 (patch) | |
tree | ba4783bab1dd65f1ceef2dfac9fdbd515531d18b /config/freenas/www | |
parent | 67780cc9d469288742aea5bc378c29a54edd5ec5 (diff) | |
download | pfsense-packages-55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1.tar.gz pfsense-packages-55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1.tar.bz2 pfsense-packages-55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1.zip |
mv packages to config dir to match web layout
Diffstat (limited to 'config/freenas/www')
59 files changed, 13601 insertions, 0 deletions
diff --git a/config/freenas/www/diag_ad_infos.php b/config/freenas/www/diag_ad_infos.php new file mode 100644 index 00000000..e9882a70 --- /dev/null +++ b/config/freenas/www/diag_ad_infos.php @@ -0,0 +1,159 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_ad_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("Active Directory Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_ad_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), true, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + if (! isset($freenas_config['ad']['enable'])) { + echo "<strong>AD Authentication disable</strong><br />"; + } else { + echo "<pre style=\"font-size: medium;\">"; + echo "<strong>Accessiblity test to MS domain:</strong><br />"; + echo htmlspecialchars("Results for net rpc testjoin:") . "<br />"; + exec("/usr/local/bin/net rpc testjoin",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($rawdata); + echo "<br />"; + echo htmlspecialchars("Ping winbindd to see if it is alive:") . "<br />"; + exec("/usr/local/bin/wbinfo -p",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($rawdata); + echo "<br />"; + echo htmlspecialchars("Check shared secret:") . "<br />"; + exec("/usr/local/bin/wbinfo -t",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($rawdata); + echo "<br>"; + echo "</pre>"; + } + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_ataidle_infos.php b/config/freenas/www/diag_ataidle_infos.php new file mode 100644 index 00000000..7ba6c737 --- /dev/null +++ b/config/freenas/www/diag_ataidle_infos.php @@ -0,0 +1,149 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_ataidle_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("ATAidle Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_ataidle_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), true, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + $disklist=get_ata_disks_list(); + echo "<strong>List of Advanced ATA capabilities on all ATA disk:</strong><br />"; + foreach ($disklist as $disknamek => $disknamev) + { + /* Found the channel and device number from the /dev name */ + /* Divise the number by 2, the interger is the channel number, the rest is the device */ + echo htmlspecialchars("Results for $disknamek:") . "<br />"; + $value=trim($disknamek,'ad'); + $value=intval($value); + $channel = $value/2; + $device=$value % 2; + $channel=intval($channel); + exec("/usr/local/sbin/ataidle $channel $device",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($rawdata); + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_disk_infos.php b/config/freenas/www/diag_disk_infos.php new file mode 100644 index 00000000..31419040 --- /dev/null +++ b/config/freenas/www/diag_disk_infos.php @@ -0,0 +1,143 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_ataidle_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("Disk Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_disk_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), true, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + exec("/sbin/atacontrol list",$iderawdata); + echo "<pre style=\"font-size: medium;\">"; + echo "<strong>List of detected ATA disks:</strong><br />"; + foreach ($iderawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + exec("/sbin/camcontrol devlist",$scsirawdata); + echo "<strong>List of detected SCSI disks:</strong><br />"; + foreach ($scsirawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_daemon.php b/config/freenas/www/diag_fn_logs_daemon.php new file mode 100644 index 00000000..1eaa1f0f --- /dev/null +++ b/config/freenas/www/diag_fn_logs_daemon.php @@ -0,0 +1,119 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_daemon.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("Daemon")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) + $nentries = 50; + +if ($_POST['clear']) +{ + exec("/usr/sbin/clog -i -s 262144 /var/log/daemon.log"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_daemon.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_daemon.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), true, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> Daemon log entries + </td> + </tr> + <?php dump_clog("/var/log/daemon.log", $nentries); ?> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_ftp.php b/config/freenas/www/diag_fn_logs_ftp.php new file mode 100644 index 00000000..21d8cfb2 --- /dev/null +++ b/config/freenas/www/diag_fn_logs_ftp.php @@ -0,0 +1,118 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_ftp.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("FTP")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) { $nentries = 50; } + +if ($_POST['clear']) +{ + exec("/usr/sbin/clog -i -s 262144 /var/log/ftp.log"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_ftp.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_ftp.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), true, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> FTP log entries + </td> + </tr> + <?php dump_clog("/var/log/ftp.log", $nentries); ?> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_rsyncd.php b/config/freenas/www/diag_fn_logs_rsyncd.php new file mode 100644 index 00000000..44ab3d85 --- /dev/null +++ b/config/freenas/www/diag_fn_logs_rsyncd.php @@ -0,0 +1,117 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_rsyncd.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("RSYNCD")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) { $nentries = 50; } + +if ($_POST['clear']) { + exec("/usr/sbin/clog -i -s 262144 /var/log/rsyncd.log"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_rsyncd.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_rsyncd.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), true, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> RSYNCD log entries + </td> + </tr> + <?php dump_clog("/var/log/rsyncd.log", $nentries); ?> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_samba.php b/config/freenas/www/diag_fn_logs_samba.php new file mode 100644 index 00000000..436de12d --- /dev/null +++ b/config/freenas/www/diag_fn_logs_samba.php @@ -0,0 +1,174 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_samba.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("Samba")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) { $nentries = 50; } + +if ($_POST['clear']) { + exec("/bin/cp /dev/null /var/log/samba/log.nmbd"); + exec("/bin/cp /dev/null /var/log/samba/log.smbd"); + exec("/bin/cp /dev/null /var/log/samba/log.winbindd"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_samba.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_samba.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), true, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> nmbd service log entries + </td> + </tr> + <?php + if (file_exists("/var/log/samba/log.nmbd")) { + exec("cat /var/log/samba/log.nmbd", $rawlog); + } else { + $rawlog=array("No logs"); + } + ?> + <?php foreach ($rawlog as $log) { ?> + <tr> + <td class="listr" nowrap> + <pre><?php echo htmlspecialchars($log); } ?></pre> + </td> + </tr> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <?php unset ($rawlog); ?> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> smbd service log entries + </td> + </tr> + <?php + if (file_exists("/var/log/samba/log.smbd")) { + exec("cat /var/log/samba/log.smbd", $rawlog); + } else { + $rawlog=array("No logs"); + } + ?> + <?php foreach ($rawlog as $log) { ?> + <tr> + <td class="listr" nowrap> + <pre><?php echo htmlspecialchars($log); } ?></pre> + </td> + </tr> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> winbindd service log entries + </td> + </tr> + <?php + if (file_exists("/var/log/samba/log.winbindd")) { + exec("cat /var/log/samba/log.winbindd", $rawlog); + } else { + $rawlog=array("No logs"); + } + ?> + <?php foreach ($rawlog as $log) { ?> + <tr> + <td class="listr" nowrap> + <pre><?php echo htmlspecialchars($log); } ?></pre> + </td> + </tr> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_settings.php b/config/freenas/www/diag_fn_logs_settings.php new file mode 100644 index 00000000..a51e8479 --- /dev/null +++ b/config/freenas/www/diag_fn_logs_settings.php @@ -0,0 +1,310 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_settings.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("Settings")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$pconfig['reverse'] = isset($config['syslog']['reverse']); +$pconfig['nentries'] = $config['syslog']['nentries']; +$pconfig['remoteserver'] = $config['syslog']['remoteserver']; +$pconfig['filter'] = isset($config['syslog']['filter']); +$pconfig['dhcp'] = isset($config['syslog']['dhcp']); +$pconfig['portalauth'] = isset($config['syslog']['portalauth']); +$pconfig['vpn'] = isset($config['syslog']['vpn']); +$pconfig['system'] = isset($config['syslog']['system']); +$pconfig['enable'] = isset($config['syslog']['enable']); +$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']); +$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']); +$pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']); +$pconfig['webservlogs'] = isset($config['syslog']['webservlogs']); + +$pconfig['sshd'] = isset($config['syslog']['sshd']); +$pconfig['ftp'] = isset($config['syslog']['ftp']); +$pconfig['rsyncd'] = isset($config['syslog']['rsyncd']); +$pconfig['smartd'] = isset($config['syslog']['smartd']); +$pconfig['daemon'] = isset($config['syslog']['daemon']); + +if (!$pconfig['nentries']) { $pconfig['nentries'] = 50; } + +if ($_POST) { + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) { + $input_errors[] = gettext("A valid IP address must be specified."); + } + if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) { + $input_errors[] = gettext("Number of log entries to show must be between 5 and 2000."); + } + + if (!$input_errors) { + $config['syslog']['reverse'] = $_POST['reverse'] ? true : false; + $config['syslog']['nentries'] = (int)$_POST['nentries']; + $config['syslog']['remoteserver'] = $_POST['remoteserver']; + $config['syslog']['filter'] = $_POST['filter'] ? true : false; + $config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false; + $config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false; + $config['syslog']['vpn'] = $_POST['vpn'] ? true : false; + $config['syslog']['system'] = $_POST['system'] ? true : false; + $config['syslog']['disablelocallogging'] = $_POST['disablelocallogging'] ? true : false; + $config['syslog']['enable'] = $_POST['enable'] ? true : false; + $oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']); + $config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true; + $config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false; + $config['syslog']['webservlogs'] = $_POST['webservlogs'] ? true : false; + $config['syslog']['sshd'] = $_POST['sshd'] ? true : false; + $config['syslog']['ftp'] = $_POST['ftp'] ? true : false; + $config['syslog']['rsyncd'] = $_POST['rsyncd'] ? true : false; + $config['syslog']['smartd'] = $_POST['smartd'] ? true : false; + $config['syslog']['daemon'] = $_POST['daemon'] ? true : false; + if($config['syslog']['enable'] == false) + unset($config['syslog']['remoteserver']); + + write_config(); + + $retval = 0; + config_lock(); + $retval = system_syslogd_start(); + if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock'])) + $retval |= filter_configure(); + config_unlock(); + $savemsg = get_std_save_message($retval); + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script language="JavaScript" type="text/javascript"> +<!-- +function enable_change(enable_over) { + endis = !(document.iform.enable.checked || enable_over); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + if (document.iform.enable.checked || enable_over) { + document.iform.remoteserver.disabled = 0; + document.iform.filter.disabled = 0; + document.iform.dhcp.disabled = 0; + document.iform.portalauth.disabled = 0; + document.iform.vpn.disabled = 0; + document.iform.system.disabled = 0; + document.iform.webservlogs.disabled = 0; + document.iform.sshd.disabled = 0; + document.iform.ftp.disabled = 0; + document.iform.rsyncd.disabled = 0; + document.iform.smartd.disabled = 0; + document.iform.daemon.disabled = 0; + + } else { + document.iform.remoteserver.disabled = 1; + document.iform.filter.disabled = 1; + document.iform.dhcp.disabled = 1; + document.iform.portalauth.disabled = 1; + document.iform.vpn.disabled = 1; + document.iform.system.disabled = 1; + document.iform.webservlogs.disabled = 1; + document.iform.sshd.disabled = 1; + document.iform.ftp.disabled = 1; + document.iform.rsyncd.disabled = 1; + document.iform.smartd.disabled = 1; + document.iform.daemon.disabled = 1; + } + + /* color adjustments */ + document.iform.remoteserver.style.backgrounColor = color; + document.iform.filter.style.backgrounColor = color; + document.iform.dhcp.style.backgrounColor = color; + document.iform.portalauth.style.backgrounColor = color; + document.iform.vpn.style.backgrounColor = color; + document.iform.system.style.backgrounColor = color; + document.iform.webservlogs.style.backgrounColor = color; + document.iform.sshd.style.backgrounColor = color; + document.iform.ftp.style.backgrounColor = color; + document.iform.rsyncd.style.backgrounColor = color; + document.iform.smartd.style.backgrounColor = color; + document.iform.daemon.style.backgrounColor = color; +} +// --> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_settings.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), true, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vtable"> </td> + <td width="78%" class="vtable"> <input name="reverse" class="formfld" type="checkbox" id="reverse" value="yes" <?php if ($pconfig['reverse']) echo "checked"; ?> /> + <strong><?=gettext("Show log entries in reverse order (newest entries on top)");?></strong> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"> </td> + <td width="78%" class="vtable"><?=gettext("Number of log entries to show");?>: + <input name="nentries" id="nentries" type="text" class="formfld unknown" size="4" value="<?=htmlspecialchars($pconfig['nentries']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vtable"> </td> + <td class="vtable"> <input name="logdefaultblock" class="formfld" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked"; ?> /> + <strong><?=gettext("Log packets blocked by the default rule");?></strong><br /> + <?=gettext("Hint: packets that are blocked by the + implicit default block rule will not be logged anymore + if you uncheck this option. Per-rule logging options are not affected.");?> + </td> + </tr> + <tr> + <td valign="top" class="vtable"> </td> + <td class="vtable"> <input name="rawfilter" class="formfld" type="checkbox" id="rawfilter" value="yes" <?php if ($pconfig['rawfilter']) echo "checked"; ?> /> + <strong><?=gettext("Show raw filter logs");?></strong><br /> + <?=gettext("Hint: If this is checked, filter logs are shown as generated by the packet filter, without any formatting. This will reveal more detailed information.");?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"> </td> + <td width="78%" class="vtable"> <input name="disablelocallogging" class="formfld" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked"; ?> onclick="enable_change(false)" /> + <strong><?=gettext("Disable writing log files to the local disk");?></strong> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vtable"> </td> + <td width="78%" class="vtable"> <input name="enable" class="formfld" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onclick="enable_change(false)" /> + <strong><?=gettext("Enable syslog'ing to remote syslog server");?></strong> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Remote syslog server</td> + <td width="78%" class="vtable"> + <input name="remoteserver" id="remoteserver" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remoteserver']);?>" /> + <br /><?=gettext("IP address of remote syslog server");?> + <br /><br /> + <input name="system" id="system" class="formfld" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked=\"checked\""; ?> /> + <?=gettext("system events");?><br /> + <input name="filter" id="filter" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['filter']) echo "checked=\"checked\""; ?> /> + <?=gettext("firewall events");?><br /> + <input name="dhcp" id="dhcp" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['dhcp']) echo "checked=\"checked\""; ?> /> + <?=gettext("DHCP service events");?><br /> + <input name="portalauth" id="portalauth" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['portalauth']) echo "checked=\"checked\""; ?> /> + <?=gettext("Portal Auth");?><br /> + <input name="vpn" id="vpn" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['vpn']) echo "checked=\"checked\""; ?> /> + <?=gettext("PPTP VPN events");?><br /> + <input name="webservlogs" id="webservlogs" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['webservlogs']) echo "checked=\"checked\""; ?> /> + <?=gettext("webConfigurator Logs");?><br /> + <input name="sshd" id="sshd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['sshd']) echo "checked=\"checked\""; ?> /> + <?=gettext("SSHD events");?><br /> + <input name="ftp" id="ftp" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['ftp']) echo "checked=\"checked\""; ?> /> + <?=gettext("FTP events");?><br /> + <input name="rsyncd" id="rsyncd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['rsyncd']) echo "checked=\"checked\""; ?> /> + <?=gettext("RSYNCD events");?><br /> + <input name="smartd" id="smartd" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['smartd']) echo "checked=\"checked\""; ?> /> + <?=gettext("SMARTD events");?><br /> + <input name="daemon" id="daemon" class="formfld" type="checkbox" value="yes" <?php if ($pconfig['daemon']) echo "checked=\"checked\""; ?> /> + <?=gettext("Daemon events");?><br /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)" /> + </td> + </tr> + <tr> + <td width="22%" height="53" valign="top"> </td> + <td width="78%"><strong><span class="red"><?=gettext("Note");?>:</span></strong><br /> + <?=gettext(" + syslog sends UDP datagrams to port 514 on the specified + remote syslog server. Be sure to set syslogd on the + remote server to accept syslog messages from {$g['product_name']}. + ");?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<script language="JavaScript" type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_smartd.php b/config/freenas/www/diag_fn_logs_smartd.php new file mode 100644 index 00000000..7e57d543 --- /dev/null +++ b/config/freenas/www/diag_fn_logs_smartd.php @@ -0,0 +1,118 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_smartd.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("SMARTD")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) { $nentries = 50; } + +if ($_POST['clear']) +{ + exec("/usr/sbin/clog -i -s 262144 /var/log/smartd.log"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_smartd.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_smartd.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), false, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), true, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> SmartD log entries + </td> + </tr> + <?php dump_clog("/var/log/smartd.log", $nentries); ?> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_fn_logs_sshd.php b/config/freenas/www/diag_fn_logs_sshd.php new file mode 100644 index 00000000..bc61d57f --- /dev/null +++ b/config/freenas/www/diag_fn_logs_sshd.php @@ -0,0 +1,117 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_fn_logs_sshd.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("System logs"), + gettext("SSHD")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$nentries = $config['syslog']['nentries']; +if (!$nentries) { $nentries = 50; } + +if ($_POST['clear']) { + exec("/usr/sbin/clog -i -s 262144 /var/log/sshd.log"); + /* redirect to avoid reposting form data on refresh */ + pfSenseHeader("diag_fn_logs_sshd.php"); + exit; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<form action="diag_fn_logs_sshd.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Samba"), false, "diag_fn_logs_samba.php"); + $tab_array[] = array(gettext("FTP"), false, "diag_fn_logs_ftp.php"); + $tab_array[] = array(gettext("RSYNCD"), false, "diag_fn_logs_rsyncd.php"); + $tab_array[] = array(gettext("SSHD"), true, "diag_fn_logs_sshd.php"); + $tab_array[] = array(gettext("SMARTD"), false, "diag_fn_logs_smartd.php"); + $tab_array[] = array(gettext("Daemon"), false, "diag_fn_logs_daemon.php"); + $tab_array[] = array(gettext("Settings"), false, "diag_fn_logs_settings.php"); + display_top_tabs($tab_array);?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td class="listtopic"> + Last <?=$nentries;?> SSHD log entries + </td> + </tr> + <?php dump_clog("/var/log/sshd.log", $nentries); ?> + <tr> + <td align="left" valign="top" height="12"> </td> + </tr> + <tr> + <td align="left" valign="top"> + <input name="clear" type="submit" class="formbtn" value="Clear log" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_iscsi_infos.php b/config/freenas/www/diag_iscsi_infos.php new file mode 100644 index 00000000..05c136e8 --- /dev/null +++ b/config/freenas/www/diag_iscsi_infos.php @@ -0,0 +1,142 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_iscsi_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("iSCSI Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_iscsi_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), true, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + if (! isset($freenas_config['iscsi']['enable'])) { + echo "<strong>iSCSI initiator disabled</strong><br />"; + } else { + echo "<pre style=\"font-size: medium;\">"; + echo "<strong>Show the list of available target Name on the iSCSI target</strong><br>"; + + exec("/usr/local/sbin/iscontrol -d targetaddress={$freenas_config['iscsi']['targetaddress']}",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br>"; + } + unset ($rawdata); + echo "</pre>"; + } + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_mounts_infos.php b/config/freenas/www/diag_mounts_infos.php new file mode 100644 index 00000000..29eb49f5 --- /dev/null +++ b/config/freenas/www/diag_mounts_infos.php @@ -0,0 +1,137 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_mounts_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("Mount Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_mounts_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), true, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + echo "<strong>List of mounted point:</strong><br />"; + exec("/sbin/mount",$mountrawdata); + foreach ($mountrawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_part_infos.php b/config/freenas/www/diag_part_infos.php new file mode 100644 index 00000000..011a771c --- /dev/null +++ b/config/freenas/www/diag_part_infos.php @@ -0,0 +1,141 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_part_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("Partition Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_part_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), true, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + $disklist = get_physical_disks_list(); + echo "<strong>List of partition on all detected disk:</strong><br />"; + foreach ($disklist as $disknamek => $disknamev) + { + exec("/sbin/fdisk $disknamek",$fdiskrawdata); + foreach ($fdiskrawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($fdiskrawdata); + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_raid_infos.php b/config/freenas/www/diag_raid_infos.php new file mode 100644 index 00000000..ad1621c1 --- /dev/null +++ b/config/freenas/www/diag_raid_infos.php @@ -0,0 +1,163 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_raid_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("RAID Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_raid_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), true, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + echo "<strong>" . gettext("Software RAID") . " - " . gettext("Geom Mirror") . ":</strong><br /><br />"; + exec("/sbin/gmirror list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + unset ($rawdata); + echo "<strong>" . gettext("Software RAID") . " - " . gettext("Geom Vinum") . ":</strong><br /><br />"; + exec("/sbin/gvinum list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + unset ($rawdata); + echo "<strong>" . gettext("Software RAID") . " - " . gettext("Geom Concat") . ":</strong><br /><br />"; + exec("/sbin/gconcat list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + unset ($rawdata); + echo "<strong>" . gettext("Software RAID") . " - " . gettext("Geom Stripe") . ":</strong><br /><br />"; + exec("/sbin/gstripe list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "<br />"; + } + unset ($line); + unset ($rawdata); + echo "<strong>" . gettext("Software RAID") . " - " . gettext("Geom Raid5") . ":</strong><br /><br />"; + exec("/sbin/graid5 list",$rawdata); + foreach ($rawdata as $line) { + echo htmlspecialchars($line) . "<br />"; + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_smart_infos.php b/config/freenas/www/diag_smart_infos.php new file mode 100644 index 00000000..d265d1b7 --- /dev/null +++ b/config/freenas/www/diag_smart_infos.php @@ -0,0 +1,141 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_smart_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("SMART Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_smart_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), true, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), false, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + $disklist = get_physical_disks_list(); + echo "<strong>List of SMART capabilities on all detected disk:</strong><br />"; + foreach ($disklist as $disknamek => $disknamev) + { + exec("/usr/local/sbin/smartctl -a /dev/$disknamek",$fdiskrawdata); + foreach ($fdiskrawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + unset ($fdiskrawdata); + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/diag_space_infos.php b/config/freenas/www/diag_space_infos.php new file mode 100644 index 00000000..e0726b07 --- /dev/null +++ b/config/freenas/www/diag_space_infos.php @@ -0,0 +1,136 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + diag_space_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Diagnostics"), + gettext("Space Infos")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="diag_space_infos.php" method="post" name="iform" id="iform"> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Disks"), false, "diag_disks_infos.php"); + $tab_array[1] = array(gettext("Partitions"), false, "diag_part_infos.php"); + $tab_array[2] = array(gettext("SMART"), false, "diag_smart_infos.php"); + $tab_array[3] = array(gettext("ataidle"), false, "diag_ataidle_infos.php"); + $tab_array[4] = array(gettext("Space used"), true, "diag_space_infos.php"); + $tab_array[5] = array(gettext("Mounts"), false, "diag_mounts_infos.php"); + $tab_array[6] = array(gettext("Software RAID"), false, "diag_raid_infos.php"); + $tab_array[7] = array(gettext("iSCSI"), false, "diag_iscsi_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("MS Domain"), false, "diag_ad_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td align="left" valign="top"> + <?php + echo "<pre style=\"font-size: medium;\">"; + exec("/bin/df -h",$rawdata); + echo "<strong>Free Space:</strong><br />"; + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br />"; + } + echo "</pre>"; + ?> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_manage.php b/config/freenas/www/disks_manage.php new file mode 100644 index 00000000..b6dece05 --- /dev/null +++ b/config/freenas/www/disks_manage.php @@ -0,0 +1,208 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_manage.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Management")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +$a_disk_conf = &$freenas_config['disks']['disk']; + +if ($_POST) { + unset($input_errors); + + /* input validation */ + + if ($_POST['apply']) { + $retval = 0; + if (! file_exists($d_sysrebootreqd_path)) { + config_lock(); + /* reload all components that mount disk */ + // disks_mount_all(); + /* Is formated?: If not create FS */ + /* $retval = disk_disks_create_ufs(); */ + + config_unlock(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_diskdirty_path)) { + unlink($d_diskdirty_path); + } + } + } + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($input_errors)) { + input_errors2Ajax($input_errors); + exit; + } + + if (!$input_errors) { + /* No errors detected, so update the config */ + } +} + +if ($_GET['act'] == "del") { + if ($a_disk_conf[$_GET['id']]) { + unset($a_disk_conf[$_GET['id']]); + write_config(); + touch($d_diskdirty_path); + pfSenseHeader("disks_manage.php"); + exit; + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_manage.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The disk list has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), true, "disks_manage.php"); + $tab_array[1] = array(gettext("Format"), false, "disks_manage_init.php"); + $tab_array[2] = array(gettext("Tools"), false, "disks_manage_tools.php"); + $tab_array[3] = array(gettext("iSCSI Initiator"), false, "disks_manage_iscsi.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Disk");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Description");?></td> + <td class="listhdrr"><?=gettext("Standby time");?></td> + <td class="listhdrr"><?=gettext("File system");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_disk_conf as $disk): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($disk['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($disk['size']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($disk['desc']);?> + </td> + <td valign="middle" class="listr"> + <?php + if ($disk['harddiskstandby']) { + $value = $disk['harddiskstandby']; + //htmlspecialchars($value); + echo $value; + } else { + echo "Always on"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?= ($disk['fstype']) ? $disk['fstype']: gettext("unknown or unformatted"); ?> + </td> + <td valign="middle" class="listr"> + <?php + $stat = disks_status($disk); + echo $stat; + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_manage_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit disk");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_manage.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="6"></td> + <td class="list" nowrap> + <a href="disks_manage_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_manage_edit.php b/config/freenas/www/disks_manage_edit.php new file mode 100644 index 00000000..80e11ef3 --- /dev/null +++ b/config/freenas/www/disks_manage_edit.php @@ -0,0 +1,275 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_manage_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Management"), + gettext("Edit")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +/* get disk list (without CDROM) */ +$disklist = get_physical_disks_list(); + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +$a_disk = &$freenas_config['disks']['disk']; + +if (isset($id) && $a_disk[$id]) +{ + $pconfig['name'] = $a_disk[$id]['name']; + $pconfig['harddiskstandby'] = $a_disk[$id]['harddiskstandby']; + $pconfig['acoustic'] = $a_disk[$id]['acoustic']; + $pconfig['fstype'] = $a_disk[$id]['fstype']; + $pconfig['apm'] = $a_disk[$id]['apm']; + $pconfig['udma'] = $a_disk[$id]['udma']; + $pconfig['fullname'] = $a_disk[$id]['fullname']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = split(" ", "name"); + $reqdfieldsn = split(",", "Name"); + + do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); + $pconfig = $_POST; + + /* check for name conflicts */ + foreach ($a_disk as $disk) + { + if (isset($id) && ($a_disk[$id]) && ($a_disk[$id] === $disk)) { continue; } + + if ($disk['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This disk already exists in the disk list."), + "field" => "name"); + break; + } + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $disks = array(); + + $devname = $_POST['name']; + $devharddiskstandby = $_POST['harddiskstandby']; + $harddiskacoustic = $_POST['acoustic']; + $harddiskapm = $_POST['apm']; + $harddiskudma = $_POST['udma']; + $harddiskfstype = $_POST['fstype']; + + $disks['name'] = $devname; + $disks['fullname'] = "/dev/$devname"; + $disks['harddiskstandby'] = $devharddiskstandby ; + $disks['acoustic'] = $harddiskacoustic ; + if ($harddiskfstype) { $disks['fstype'] = $harddiskfstype; } + $disks['apm'] = $harddiskapm ; + $disks['udma'] = $harddiskudma ; + $disks['type'] = $disklist[$devname]['type']; + $disks['desc'] = $disklist[$devname]['desc']; + $disks['size'] = $disklist[$devname]['size']; + + if (isset($id) && $a_disk[$id]) { + $a_disk[$id] = $disks; + } else { + $a_disk[] = $disks; + } + + touch($d_diskdirty_path); + + disks_set_ataidle(); + write_config(); + + pfSenseHeader("disks_manage.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="disks_manage_edit.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td> + <td width="78%" class="vtable"> + <select name="name" class="formselect" id="name"> + <?php foreach ($disklist as $diski => $diskv): ?> + <option value="<?=$diski;?>" <?php if ($diski == $pconfig['name']) echo "selected=\"selected\"";?>> + <?php echo htmlspecialchars($diski . ": " .$diskv['size'] . " (" . $diskv['desc'] . ")");?> + </option> + <?php endforeach; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("UDMA mode");?></td> + <td width="78%" class="vtable"> + <select name="udma" class="formselect" id="udma"> + <?php + $types = explode(",", "Auto,UDMA-33,UDMA-66,UDMA-100,UDMA-133"); + $vals = explode(" ", "auto UDMA2 UDMA4 UDMA5 UDMA6"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['udma']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + <br /> + <?= gettext("You can force UDMA mode if you have \"UDMA_ERROR.... LBA\" message with your hard drive."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Hard disk standby time");?></td> + <td width="78%" class="vtable"> + <select name="harddiskstandby" class="formselect"> + <?php + $sbvals = array(0=>"Always on",5=>"5 minutes",10=>"10 minutes",20=>"20 minutes",30=>"30 minutes",60=>"60 minutes"); + ?> + <?php foreach ($sbvals as $sbval => $sbname): ?> + <option value="<?=$sbval;?>" <?php if($pconfig['harddiskstandby'] == $sbval) echo 'selected="selected"';?>><?=htmlspecialchars($sbname);?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("Puts the hard disk into standby mode when the selected amount of time after the last + access has elapsed. <em>Do not set this for CF cards.</em>"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Advanced Power Management");?></td> + <td width="78%" class="vtable"> + <select name="apm" class="formselect"> + <?php + $apmvals = array(0=>"Disabled",1=>"Minimum power usage with Standby",64=>"Medium power usage with Standby",128=>"Minimum power usage without Standby",192=>"Medium power usage without Standby",254=>"Maximum performance, maximum power usage"); + ?> + <?php foreach ($apmvals as $apmval => $apmname): ?> + <option value="<?=$apmval;?>" <?php if($pconfig['apm'] == $apmval) echo 'selected="selected"';?>><?=htmlspecialchars($apmname);?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("This allows you to lower the power consumption of the drive, at the expense of performance.<em>Do not set this for CF cards.</em>"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("acoustic level");?></td> + <td width="78%" class="vtable"> + <select name="acoustic" class="formselect"> + <?php + $acvals = array(0=>"Disabled",1=>"Minimum performance, Minimum acoustic output",64=>"Medium acoustic output",127=>"Maximum performance, maximum acoustic output"); + ?> + <?php foreach ($acvals as $acval => $acname): ?> + <option value="<?=$acval;?>" <?php if($pconfig['acoustic'] == $acval) echo 'selected';?>><?=htmlspecialchars($acname);?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("This allows you to set how loud the drive is while it\'s operating.<em>Do not set this for CF cards.</em>"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("preformated FS");?></td> + <td width="78%" class="vtable"> + <select name="fstype" class="formselect"> + <?php $fstlist = get_fstype_list(); ?> + <?php foreach ($fstlist as $fstval => $fstname): ?> + <option value="<?=$fstval;?>" <?php if($pconfig['fstype'] == $fstval) echo 'selected';?>><?=htmlspecialchars($fstname);?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("This allows you to set FS type for preformated disk with data.<br /> + <em>Leave \"unformated\" for unformated disk and then use Format menu.</em>"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + <?php if (isset($id) && $a_disk[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <?php endif; ?> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/disks_manage_init.php b/config/freenas/www/disks_manage_init.php new file mode 100644 index 00000000..e8d939d3 --- /dev/null +++ b/config/freenas/www/disks_manage_init.php @@ -0,0 +1,511 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_manage_init.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Initialize")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +define("DISK_DETAILS_PARA", " + <p style='font-size: small;'> + <strong>Disk initialization details</strong> (use the toggle icon to unveil detailed infos): + </p> + "); + +function create_format_output($disk, $type, $notinitmbr) { + $ddetails = DISK_DETAILS_PARA; + + ob_end_flush(); + + $retvalue =<<<EOD +{$ddetails} + +EOD; + + // Erase MBR if not checked + if (!$notinitmbr) { + $button = create_toggle_button("Erasing MBR and all paritions", "mbr_out"); + $cmd = "dd if=/dev/zero of=" . escapeshellarg($disk) . " bs=32k count=640"; + $out = create_cmdout_container("mbr_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + } else { + $diskinit_str = "Keeping the MBR and all partitions"; + $retvalue .=<<<EOD + <div id="mbr_out" style="font-family: Courier, monospace; font-size: small;"> + <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> + </div> + +EOD; + } // end if + + switch ($type) { + case "ufs": + $button = create_toggle_button("Creating one partition", "ufs_fdisk_out"); + /* Initialize disk */ + $cmd = "/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk); + $out = create_cmdout_container("ufs_fdisk_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Initializing partition", "ufs_dd_out"); + /* Initialise the partition (optional) */ + $cmd = "/bin/dd if=/dev/zero of=" . escapeshellarg($disk) . "s1 bs=32k count=16"; + $out = create_cmdout_container("ufs_dd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating BSD label", "ufs_label_out"); + /* Create s1 label */ + $cmd = "/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto"; + $out = create_cmdout_container("ufs_label_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating Filesystem", "ufs_newfs_out"); + /* Create filesystem */ + $cmd = "/sbin/newfs -U " . escapeshellarg($disk) . "s1"; + $out = create_cmdout_container("ufs_newfs_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + break; // end case "ufs": + case "ufs_no_su": + $button = create_toggle_button("Creating one partition", "ufsn_fdisk_out"); + /* Initialize disk */ + $cmd = "/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk); + $out = create_cmdout_container("ufsn_fdisk_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Initializing partition", "ufsn_dd_out"); + /* Initialise the partition (optional) */ + $cmd = "/bin/dd if=/dev/zero of=" . escapeshellarg($disk) . "s1 bs=32k count=16"; + $out = create_cmdout_container("ufsn_dd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating BSD label", "ufsn_label_out"); + /* Create s1 label */ + $cmd = "/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto"; + $out = create_cmdout_container("ufsn_label_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating Filesystem", "ufsn_newfs_out"); + /* Create filesystem */ + $cmd = "/sbin/newfs -m 0 " . escapeshellarg($disk) . "s1"; + $out = create_cmdout_container("ufsn_newfs_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + break; // end ufs_no_su + case "ufsgpt": + $button = create_toggle_button("Destroying old GTP information", "ufsg_gptd_out"); + /* Destroy GPT partition table */ + $cmd = "/sbin/gpt destroy " . escapeshellarg($disk); + $out = create_cmdout_container("ufsg_gptd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating GPT partition", "ufsg_gptc_out"); + /* Create GPT partition table */ + $cmd = array("/sbin/gpt create -f " . escapeshellarg($disk), + "/sbin/gpt add -t ufs " . escapeshellarg($disk)); + $out = create_cmdout_container("ufsg_gptc_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating Filesystem with Soft Updates", "ufsg_newfs_out"); + /* Create filesystem */ + $cmd = "/sbin/newfs -U " . escapeshellarg($disk) . "p1"; + $out = create_cmdout_container("ufsg_newfs_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + break; // end case "ufsgpt": + case "ufsgpt_no_su": + $button = create_toggle_button("Destroying old GTP information", "ufsgn_gpt_out"); + /* Destroy GPT partition table */ + $cmd = "/sbin/gpt destroy " . escapeshellarg($disk); + $out = create_cmdout_container("ufsgn_gpt_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating GPT partition", "ufsgn_gptc_out"); + /* Create GPT partition table */ + $cmd = array("/sbin/gpt create -f " . escapeshellarg($disk), + "/sbin/gpt add -t ufs " . escapeshellarg($disk)); + $out = create_cmdout_container("ufsgn_gptc_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating Filesystem without Soft Updates", "ufsgn_newfs_out"); + /* Create filesystem */ + $cmd = "/sbin/newfs -m 0 " . escapeshellarg($disk) . "p1"; + $out = create_cmdout_container("ufsgn_newfs_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + break; // end case "ufsgpt_no_su": + case "softraid": + $button = create_toggle_button("Initializing disk", "softr_fdisk_out"); + /* Initialize disk */ + $cmd = "/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk); + $out = create_cmdout_container("softr_fdisk_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Initializing partition", "softr_dd_out"); + /* Initialise the partition (optional) */ + $cmd = "/bin/dd if=/dev/zero of=" . escapeshellarg($disk) . "s1 bs=32k count=16"; + $out = create_cmdout_container("softr_dd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Delete old gmirror information", "softr_dd_out"); + /* Delete old gmirror information */ + $cmd = "/sbin/gmirror clear " . escapeshellarg($disk); + $out = create_cmdout_container("softr_dd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + break; // end case "softraid": + case "msdos": + $button = create_toggle_button("Initialize disk", "dos_fdisk_out"); + /* Initialize disk */ + $cmd = "/sbin/fdisk -I -b /boot/mbr " . escapeshellarg($disk); + $out = create_cmdout_container("dos_fdisk_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Initialize partion", "dos_dd_out"); + /* Initialise the partition (optional) */ + $cmd = "/bin/dd if=/dev/zero of=" . escapeshellarg($disk) . "s1 bs=32k count=16"; + $out = create_cmdout_container("dos_dd_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating BSD label", "dos_label_out"); + /* Initialise the partition (optional) */ + $cmd = "/sbin/bsdlabel -w " . escapeshellarg($disk) . "s1 auto"; + $out = create_cmdout_container("dos_label_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + + $button = create_toggle_button("Creating Filesystem", "dos_newfs_out"); + /* Initialise the partition (optional) */ + $a_out = "/sbin/newfs_msdos -F 32 " . escapeshellarg($disk) . "s1"; + $out = create_cmdout_container("dos_newfs_out", $cmd); + $retvalue .= assemble_cmdout($button, $out, true); + + break; // end case "msdos": + } // end switch + + return $retvalue; +} + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +if (!is_array($freenas_config['gconcat']['vdisk'])) + $freenas_config['gconcat']['vdisk'] = array(); + +gconcat_sort(); + +if (!is_array($freenas_config['gmirror']['vdisk'])) + $freenas_config['gmirror']['vdisk'] = array(); + +gmirror_sort(); + +if (!is_array($freenas_config['graid5']['vdisk'])) + $freenas_config['graid5']['vdisk'] = array(); + +graid5_sort(); + +if (!is_array($freenas_config['gstripe']['vdisk'])) + $freenas_config['gstripe']['vdisk'] = array(); + +gstripe_sort(); + +if (!is_array($freenas_config['gvinum']['vdisk'])) + $freenas_config['gvinum']['vdisk'] = array(); + +gvinum_sort(); + +// Get all fstype supported by FreeNAS +$a_fst = get_fstype_list(); +// Remove NTFS: can't format on NTFS under FreeNAS +unset($a_fst['ntfs']); +// Remove the first blank line 'unknown' +$a_fst = array_slice($a_fst, 1); + +$a_disk = &$freenas_config['disks']['disk']; +$a_gconcat = &$freenas_config['gconcat']['vdisk']; +$a_gmirror = &$freenas_config['gmirror']['vdisk']; +$a_gstripe = &$freenas_config['gstripe']['vdisk']; +$a_graid5 = &$freenas_config['graid5']['vdisk']; +$a_gvinum = &$freenas_config['gvinum']['vdisk']; + $a_alldisk = array_merge($a_disk, + $a_gconcat, + $a_gmirror, + $a_gstripe, + $a_graid5, + $a_gvinum); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_format); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = explode(" ", "disk type"); + $reqdfieldsn = explode(",", "Disk,Type"); + + do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $do_format = true; + $disk = $_POST['disk']; + $type = $_POST['type']; + $notinitmbr= $_POST['notinitmbr']; + + /* Check if disk is mounted. */ + if(isAjax() && disks_check_mount_fullname($disk)) { + $statustxt = sprintf(gettext("The disk is currently mounted! <a href=%s>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); + + $divcontents = "<div style='background:#990000'><table>"; + $divcontents .= "<tr><td>"; + $divcontents .= "<img src='/themes/{$g['theme']}/images/icons/icon_error.gif' width='28' height='32'>"; + $divcontents .= "</td><td><font color='white'><br> The following errors have occured:<p><ul>"; + $divcontents .= "<font color='white'><li> " . $statustxt . "</li>"; + $divcontents .= "</ul></td></table></div><br />"; + + header("HTTP/1.0 500 Internal Server Error"); + header("Status: 500 Internal Server Error. {$statustxt}"); + echo $divcontents; + exit; + } else if (disks_check_mount_fullname($disk)) { + $errormsg = sprintf(gettext("The disk is currently mounted! <a href=%s>Unmount</a> this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); + $do_format = false; + } + + if($do_format) { + /* Get the id of the disk array entry. */ + $NotFound = 1; + $id = array_search_ex($disk, $a_disk, "fullname"); + + if ($id) { + /* Set new filesystem type. */ + $a_disk[$id]['fstype'] = $type; + $NotFound = 0; + } + else { + $id = array_search_ex($disk, $a_gmirror, "fullname"); + } + if (($id !== false) && $NotFound) { + /* Set new filesystem type. */ + $a_gmirror[$id]['fstype'] = $type; + $NotFound = 0; + } + else { + $id = array_search_ex($disk, $a_gstripe, "fullname"); + } + if (($id !== false) && $NotFound) { + /* Set new filesystem type. */ + $a_gstripe[$id]['fstype'] = $type; + $NotFound = 0; + } + else { + $id = array_search_ex($disk, $a_gconcat, "fullname"); + } + if (($id !== false) && $NotFound) { + /* Set new filesystem type. */ + $a_gconcat[$id]['fstype'] = $type; + $NotFound = 0; + } + else { + $id = array_search_ex($disk, $a_graid5, "fullname"); + } + if (($id !== false) && $NotFound) { + /* Set new filesystem type. */ + $a_graid5[$id]['fstype'] = $type; + $NotFound = 0; + } + else { + $id = array_search_ex($disk, $a_gvinum, "fullname"); + } + if (($id !== false) && $NotFound) { + /* Set new filesystem type. */ + $a_gvinum[$id]['fstype'] = $type; + $NotFound = 0; + } + + write_config(); + + echo create_format_output($disk, $type, $notinitmbr); + exit; // cause of Ajax + } + } +} + +if (!isset($do_format)) +{ + $do_format = false; + $disk = ''; + $type = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +$pfSenseHead->setCloseHead(false); +echo $pfSenseHead->getHTML(); + +?> +<script type="text/javascript"> +<!-- +function disk_change() { + switch(document.iform.disk.value) + { + <?php foreach ($a_alldisk as $diskv): ?> + case "<?=$diskv['fullname'];?>": + <?php $i = 0;?> + <?php foreach ($a_fst as $fstval => $fstname): ?> + document.iform.type.options[<?=$i++;?>].selected = <?php if($diskv['fstype'] == $fstval){echo "true";}else{echo "false";};?>; + <?php endforeach; ?> + break; + <?php endforeach; ?> + } +} + +<?= CMDOUT_TOGGLE_FUNC ?> +// --> +</script> +</head> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if($errormsg) print_error_box($errormsg);?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), false, "disks_manage.php"); + $tab_array[1] = array(gettext("Format"), true, "disks_manage_init.php"); + $tab_array[2] = array(gettext("Tools"), false, "disks_manage_tools.php"); + $tab_array[3] = array(gettext("iSCSI Initiator"), false, "disks_manage_iscsi.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form id="iform" name="iform" action="disks_manage_init.php" method="post"> + <?= CMDOUT_AJAX_SCRIPT ?> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td> + <td width="78%" class="vtable"> + <select name="disk" class="formselect" id="disk" onchange="disk_change();"> + <?php foreach ($a_alldisk as $diskv): ?> + <option value="<?=$diskv['fullname'];?>" <?php if ($diskv['name'] == $disk) echo "selected=\selected\"";?>> + <?php echo htmlspecialchars($diskv['name'] . ": " .$diskv['size'] . " (" . $diskv['desc'] . ")");?> + <?php endforeach; ?> + </option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("File system");?></td> + <td width="78%" class="vtable"> + <select name="type" class="formselect" id="type"> + <?php foreach ($a_fst as $fstval => $fstname): ?> + <option value="<?=$fstval;?>" <?php if($type == $fstval) echo 'selected="selected"';?>><?=htmlspecialchars($fstname);?></option> + <?php endforeach; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Don't Erase MBR");?></td> + <td width="78%" class="vtable"> + <input name="notinitmbr" id="notinitmbr" type="checkbox" value="yes" /><br /> + <?= gettext("don't erase the MBR (useful for some RAID controller cards)"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="doCMDSubmit" name="doCMDSubmit" type="button" class="formbtn" value="<?=gettext("Format disk!");?>" onclick="execCMD();" /> + </td> + </tr> + <tr> + <!-- Format Output Container - Do Not Delete --> + <td id="cmdOutputTD" valign="top" colspan="2" style="visibility: hidden; border: solid 1px silver; vertical-align: middle; width: 100%"></td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong> + </span> + <br /> + <span class="vexpl"> + <?= gettext("This step will erase all your partition, create partition number 1 and format the hard drive with the file system specified."); ?> + </span> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/disks_manage_iscsi.php b/config/freenas/www/disks_manage_iscsi.php new file mode 100644 index 00000000..5180fc1a --- /dev/null +++ b/config/freenas/www/disks_manage_iscsi.php @@ -0,0 +1,209 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_manage_iscsi.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("iSCSI Initiator")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! is_array($freenas_config['iscsi'])) +{ + $freenas_config['iscsi'] = array(); +} + +$pconfig['enable'] = isset($freenas_config['iscsi']['enable']); +$pconfig['targetaddress'] = $freenas_config['iscsi']['targetaddress']; +$pconfig['targetname'] = $freenas_config['iscsi']['targetname']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']) + { + $reqdfields = array_merge($reqdfields, explode(" ", "targetaddress targetname")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "targetaddress,targetname")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['enable'] && !is_ipaddr($_POST['targetaddress'])){ + $error_bucket[] = array("error" => gettext("A valid IP address must be specified."), + "field" => "targetaddress"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['iscsi']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['iscsi']['targetaddress'] = $_POST['targetaddress']; + $freenas_config['iscsi']['targetname'] = $_POST['targetname']; + + write_config(); + + $retval = 0; + if (! file_exists($d_sysrebootreqd_path)) + { + /* nuke the cache file */ + config_lock(); + services_iscsi_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.targetname.disabled = endis; + document.iform.targetaddress.disabled = endis; + /* adjust colors */ + document.iform.targetname.style.backgroundColor = color; + document.iform.targetaddress.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), false, "disks_manage.php"); + $tab_array[1] = array(gettext("Format"), false, "disks_manage_init.php"); + $tab_array[2] = array(gettext("Tools"), false, "disks_manage_tools.php"); + $tab_array[3] = array(gettext("iSCSI Initiator"), true, "disks_manage_iscsi.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form id="iform" name="iform" action="disks_manage_iscsi.php" method="post"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("iSCSI Initiator");?></span> + <span style="vertical-align: middle; position: relative; left: 81%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Target IP address"); ?></td> + <td width="78%" class="vtable"> + <input name="targetaddress" type="text" class="formfld unknown" id="targetaddress" size="20" value="<?=htmlspecialchars($pconfig['targetaddress']);?>" /> + <br /><?= gettext("Target IP address"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("targetname"); ?></td> + <td width="78%" class="vtable"> + <input name="targetname" type="text" class="formfld unknown" id="targetname" size="20" value="<?=htmlspecialchars($pconfig['targetname']);?>" /> + <br /><?= gettext("targetname"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/disks_manage_tools.php b/config/freenas/www/disks_manage_tools.php new file mode 100644 index 00000000..d851f65c --- /dev/null +++ b/config/freenas/www/disks_manage_tools.php @@ -0,0 +1,331 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_manage_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +function create_cmd_output(&$action, &$a_disk, &$disk, &$partition, &$umount) { + $cmdout = CMDOUT_PARA; + + ob_end_flush(); + + $retvalue =<<<EOD +{$cmdout} + +EOD; + + switch($action) + { + case "fsck": + /* Get the id of the disk. */ + $id = array_search_ex($disk, $a_disk, "name"); + /* Get the filesystem type of the disk. */ + $type = $a_disk[$id]['fstype']; + /* Check if disk is mounted. */ + $ismounted = disks_check_mount_fullname($disk.$partition); + + /* Umount disk if necessary. */ + if($umount && $ismounted) { + $diskinit_str = "<strong class='red'>" . gettext("Note") . ":</strong> " . gettext("The disk is currently mounted! The mount point will be removed temporary to perform selected command.") . "<br /><br />"; + $retvalue .=<<<EOD + <div id="ismounted_out" style="font-family: Courier, monospace; font-size: small;"> + <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> + </div> + +EOD; + + disks_umount_fullname($disk.$partition); + } + + switch($type) + { + case "": + case "ufs": + case "ufs_no_su": + case "ufsgpt": + case "ufsgpt_no_su": + $button = create_toggle_button("Checking disk", "ufsgn_fsck_out"); + $cmd = "/sbin/fsck_ufs -y -f " . escapeshellarg($disk . $partition); + $out = create_cmdout_container("ufsgn_fsck_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + break; + case "gmirror": + case "gvinum": + case "graid5": + $diskinit_str = sprintf(gettext("Use <a href='%s'>RAID tools</a> for this disk!"), "disks_raid_{$type}_tools.php"); + $retvalue .=<<<EOD + <div id="graid5_out" style="display: none; font-family: Courier, monospace; font-size: small;"> + <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> + </div> + +EOD; + break; + case "msdos": + $button = create_toggle_button("Checking disk", "dos_fsck_out"); + $cmd = "/sbin/fsck_msdosfs -y -f " . escapeshellarg($disk . $partition); + $out = create_cmdout_container("dos_fsck_out", $cmd); + $retvalue .= assemble_cmdout($button, $out); + break; + } + + /* Mount disk if necessary. */ + if($umount && $ismounted) { + disks_mount_fullname($disk.$partition); + } + + break; + } + + return $retvalue; +} + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +if (!is_array($freenas_config['gvinum']['vdisk'])) + $freenas_config['gvinum']['vdisk'] = array(); + +gvinum_sort(); + +if (!is_array($freenas_config['gmirror']['vdisk'])) + $freenas_config['gmirror']['vdisk'] = array(); + +gmirror_sort(); + +if (!is_array($freenas_config['gconcat']['vdisk'])) + $freenas_config['gconcat']['vdisk'] = array(); + +gconcat_sort(); + +if (!is_array($freenas_config['gstripe']['vdisk'])) + $freenas_config['gstripe']['vdisk'] = array(); + +gstripe_sort(); + +if (!is_array($freenas_config['graid5']['vdisk'])) + $freenas_config['graid5']['vdisk'] = array(); + +graid5_sort(); + +$a_disk = array_merge($freenas_config['disks']['disk'], + $freenas_config['gvinum']['vdisk'], + $freenas_config['gmirror']['vdisk'], + $freenas_config['gconcat']['vdisk'], + $freenas_config['gstripe']['vdisk'], + $freenas_config['graid5']['vdisk']); + +if ($_POST) { + unset($input_errors); + unset($do_action); + + /* input validation */ + $reqdfields = explode(" ", "disk action"); + $reqdfieldsn = explode(",", "Disk,Action"); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $do_action = true; + $disk = $_POST['disk']; + $action = $_POST['action']; + $partition = $_POST['partitionno']; + $umount = $_POST['umount']; + + echo create_cmd_output($action, $a_disk, $disk, $partition, $umount); + exit; // cause of Ajax + } +} + +if (!isset($do_action)) +{ + $do_action = false; + $disk = ''; + $action = ''; + $partition = ''; + $umount = false; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +$pfSenseHead->setCloseHead(false); +echo $pfSenseHead->getHTML(); + +?> +<script type="text/javascript"> +<!-- +function disk_change() { + var next = null; + // Remove all entries from partition combobox. + document.iform.partitionno.length = 0; + // Insert entries for partition combobox. + alert(document.iform.disk.value); + switch(document.iform.disk.value) + { + <?php foreach ($a_disk as $diskv): ?> + <?php if (strcmp($diskv['fstype'],"softraid")==0): ?> + <?php continue; ?> + <?php endif; ?> + case "/dev/<?=$diskv['name'];?>": + <?php $partinfo = disks_get_partition_info($diskv['name']);?> + <?php foreach($partinfo as $partinfon => $partinfov): ?> + if(document.all) // MS IE workaround. + next = document.iform.partitionno.length; + alert(document.iform.partitionno); + document.iform.partitionno.add(new Option("<?=$partinfon;?>","s<?=$partinfon;?>",false,<?php if("s{$partinfon}"==$partition){echo "true";}else{echo "false";};?>), next); + <?php endforeach; ?> + break; + <?php endforeach; ?> + } +} + +<?= CMDOUT_TOGGLE_FUNC ?> +// --> +</script> +</head> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_manage_tools.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), false, "disks_manage.php"); + $tab_array[1] = array(gettext("Format"), false, "disks_manage_init.php"); + $tab_array[2] = array(gettext("Tools"), true, "disks_manage_tools.php"); + $tab_array[3] = array(gettext("iSCSI Initiator"), false, "disks_manage_iscsi.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <?= CMDOUT_AJAX_SCRIPT ?> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td> + <td width="78%" class="vtable"> + <select name="disk" class="formselect" id="disk" onchange="disk_change();"> + <?php foreach ($a_disk as $diskn): ?> + <?php if (strcmp($diskn['fstype'],"softraid")==0): ?> + <?php continue; ?> + <?php endif; ?> + <option value="<?=$diskn['fullname'];?>"<?php if ($diskn['fullname'] == $disk) echo "selected=\"selected\"";?>> + <?php echo htmlspecialchars($diskn['name'] . ": " .$diskn['size'] . " (" . $diskn['desc'] . ")");?> + <?php endforeach; ?> + </option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Partition");?></td> + <td width="78%" class="vtable"> + <select name="partitionno" class="formselect" id="partitionno"></select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Command");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="fsck" <?php if ($action == "fsck") echo "selected"; ?>>fsck</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"></td> + <td width="78%" class="vtable"> + <input name="umount" type="checkbox" id="umount" value="yes" <?php if ($umount) echo "checked"; ?> /> + <strong> + <?= gettext("Unmount disk/partition"); ?> + </strong> + <span class="vexpl"> + <br /> + <?= gettext("If the selected disk/partition is mounted it will be unmounted temporary to perform selected command, otherwise the commands work in read-only mode."); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="doCMDSubmit" name="doCMDSubmit" type="button" class="formbtn" value="<?=gettext("Send Command!");?>" onclick="execCMD();" /> + </td> + </tr> + <tr> + <!-- Format Output Container - Do Not Delete --> + <td id="cmdOutputTD" valign="top" colspan="2" style="visibility: hidden; border: solid 1px silver; vertical-align: middle; width: 100%"></td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<script type="text/javascript"> +<!-- + disk_change(); +//--> +</script> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_mount.php b/config/freenas/www/disks_mount.php new file mode 100644 index 00000000..c72b0d82 --- /dev/null +++ b/config/freenas/www/disks_mount.php @@ -0,0 +1,235 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_mount.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Mount Point")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + + if (!file_exists($d_sysrebootreqd_path)) { + config_lock(); + /* reload all components that mount disk */ + disks_mount_all(); + /* reload all components that use mount */ + services_samba_configure(); + services_nfs_configure(); + services_rsyncd_configure(); + services_afpd_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_mountdirty_path)) + unlink($d_mountdirty_path); + } + } +} + +if ($_GET['act'] == "del") +{ + if ($a_mount[$_GET['id']]) { + disks_umount_adv($a_mount[$_GET['id']]); + unset($a_mount[$_GET['id']]); + write_config(); + touch($d_mountdirty_path); + pfSenseHeader("disks_mount.php"); + exit; + } +} + +if ($_GET['act'] == "ret") +{ + if ($a_mount[$_GET['id']]) { + disks_mount($a_mount[$_GET['id']]); + pfSenseHeader("disks_mount.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form id="iform" name="iform" action="disks_mount.php" method="post"> +<?php if (file_exists($d_mountdirty_path)): ?> +<?php print_info_box_np(gettext("The mount point list has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), true, "disks_mount.php"); + $tab_array[1] = array(gettext("Tools"), false, "disks_mount_tools.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Disk");?></td> + <td class="listhdrr"><?=gettext("Partition");?></td> + <td class="listhdrr"><?=gettext("File system");?></td> + <td class="listhdrr"><?=gettext("Share name");?></td> + <td class="listhdrr"><?=gettext("Description");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_mount as $mount): ?> + <tr> + <td valign="middle" class="listlr"> + <?=htmlspecialchars($mount['mdisk']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($mount['partition']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($mount['fstype']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($mount['sharename']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($mount['desc']);?> + </td> + <td valign="middle" class="listbg" style="color: #FFFFFF;"> + <?php + if (file_exists($d_mountdirty_path)) { + $stat = gettext("configuring"); + } else { + $stat = disks_check_mount($mount); + if ($stat == false) { + $stat = "ERROR - <a href=\"disks_mount.php?act=ret&id=$i\">retry</a>"; + } else { + $stat = gettext("OK"); + } + } + echo $stat; + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_mount_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit mount");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_mount.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" onclick="return confirm('<?= gettext("Do you really want to delete this mount point? All elements that still use it will become invalid (e.g. share)!"); ?>');" title="<?=gettext("delete mount");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="6"></td> + <td class="list" nowrap> + <a href="disks_mount_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add mount");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="7"> + <span class="red"> + <strong>Note:</strong> + </span> + <br /> + <span class="vexpl"> + <?= gettext("Second configuration step: Declaring the filesystem used by your"); ?> + </span> + <br /> + <span class="vexpl"> + <a href="disks_manage.php">previously configured disk</a> + </span> + </td> + </tr> + </table> + </div> + </td> + </tr> + </table> +</form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/disks_mount_edit.php b/config/freenas/www/disks_mount_edit.php new file mode 100644 index 00000000..6b7a2248 --- /dev/null +++ b/config/freenas/www/disks_mount_edit.php @@ -0,0 +1,307 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_mount_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Mount Point"), + gettext("Edit")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +if (!is_array($freenas_config['gvinum']['vdisk'])) + $freenas_config['gvinum']['vdisk'] = array(); + +gvinum_sort(); + +if (!is_array($freenas_config['gmirror']['vdisk'])) + $freenas_config['gmirror']['vdisk'] = array(); + +gmirror_sort(); + +if (!is_array($freenas_config['gconcat']['vdisk'])) + $freenas_config['gconcat']['vdisk'] = array(); + +gconcat_sort(); + +if (!is_array($freenas_config['gstripe']['vdisk'])) + $freenas_config['gstripe']['vdisk'] = array(); + +gstripe_sort(); + +if (!is_array($freenas_config['graid5']['vdisk'])) + $freenas_config['graid5']['vdisk'] = array(); + +graid5_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +$a_disk = array_merge($freenas_config['disks']['disk'],$freenas_config['gvinum']['vdisk'],$freenas_config['gmirror']['vdisk'],$freenas_config['gconcat']['vdisk'],$freenas_config['gstripe']['vdisk'],$freenas_config['graid5']['vdisk']); + +/* Load the cfdevice file*/ +$filename=$g['varetc_path']."/cfdevice"; +if (file_exists($filename)) + $cfdevice = trim(file_get_contents("$filename")); + +if (isset($id) && $a_mount[$id]) { + $pconfig['mdisk'] = $a_mount[$id]['mdisk']; + $pconfig['partition'] = $a_mount[$id]['partition']; + $pconfig['fullname'] = $a_mount[$id]['fullname']; + $pconfig['fstype'] = $a_mount[$id]['fstype']; + $pconfig['sharename'] = $a_mount[$id]['sharename']; + $pconfig['desc'] = $a_mount[$id]['desc']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = split(" ", "partitionno mdisk fstype"); + $reqdfieldsn = split(",", "Partition,Mdisk,Fstype"); + + do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); + + if (($_POST['sharename'] && !is_validsharename($_POST['sharename']))) + { + $error_bucket[] = array("error" => gettext("The share name may only consist of the characters a-z, A-Z, 0-9, _ , -."), + "field" => "sharename"); + } + + + if (($_POST['desc'] && !is_validdesc($_POST['desc']))) + { + $error_bucket[] = array("error" => gettext("The description name contain invalid characters."), + "field" => "desc"); + + } + $device=$_POST['mdisk'].$_POST['partitionno']; + + if ($device == $cfdevice ) + { + $error_bucket[] = array("error" => gettext("Can't mount the system partition 1, the DATA partition is the 2."), + "field" => "mdisk"); + + } + + /* check for name conflicts */ + foreach ($a_mount as $mount) + { + if (isset($id) && ($a_mount[$id]) && ($a_mount[$id] === $mount)) + continue; + + /* Check for duplicate mount point */ + if ($mount['mdisk'] == $_POST['mdisk']) + { + $error_bucket[] = array("error" => gettext("This disk/partition is allready configured."), + "field" => "mdisk"); + break; + } + + if (($_POST['sharename']) && ($mount['sharename'] == $_POST['sharename'])) + { + $error_bucket[] = array("error" => gettext("Duplicate Share Name."), + "field" => "sharename"); + break; + } + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $mount = array(); + $mount['mdisk'] = $_POST['mdisk']; + $mount['partition'] = $_POST['partitionno']; + $mount['fstype'] = $_POST['fstype']; + $mount['desc'] = $_POST['desc']; + /* if not sharename given, create one */ + if (!$_POST['sharename']) + $mount['sharename'] = "disk_{$_POST['mdisk']}_part_{$_POST['partitionno']}"; + else + $mount['sharename'] = $_POST['sharename']; + + // Generate fullname + $mount['fullname'] = "{$mount['mdisk']}{$mount['partition']}"; + + if (isset($id) && $a_mount[$id]) + $a_mount[$id] = $mount; + else + $a_mount[] = $mount; + + touch($d_mountdirty_path); + + write_config(); + + pfSenseHeader("disks_mount.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="disks_mount_edit.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Disk");?></td> + <td width="78%" class="vtable"> + <select name="mdisk" class="formselect" id="mdisk"> + <?php foreach ($a_disk as $disk): ?> + <?php if (strcmp($disk['fstype'],"softraid")==0): ?> + <?php continue; ?> + <?php endif; ?> + <option value="<?=$disk['fullname'];?>" <?php if ($pconfig['mdisk'] == $disk['name']) echo "selected";?>> + <?php echo htmlspecialchars($disk['name'] . ": " .$disk['size'] . " (" . $disk['desc'] . ")"); ?> + </option> + <?php endforeach; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Partition");?></td> + <td width="78%" class="vtable"> + <select name="partitionno" class="formselect" id="partition_number"> + <option value="s1" <?php if ($pconfig['partition'] == "s1") echo "selected"; ?>>1 (or new software RAID method)</option> + <option value="s2" <?php if ($pconfig['partition'] == "s2") echo "selected"; ?>>2</option> + <option value="s3" <?php if ($pconfig['partition'] == "s3") echo "selected"; ?>>3</option> + <option value="s4" <?php if ($pconfig['partition'] == "s4") echo "selected"; ?>>4</option> + <option value="gmirror" <?php if ($pconfig['partition'] == "gmirror") echo "selected"; ?>>previous <?=_SOFTRAID ;?> - gmirror</option> + <option value="graid5" <?php if ($pconfig['partition'] == "graid5") echo "selected"; ?>>previous <?=_SOFTRAID ;?> - graid5</option> + <option value="gvinum" <?php if ($pconfig['partition'] == "gvinum") echo "selected"; ?>>previous <?=_SOFTRAID ;?> - gvinum</option> + <option value="p1" <?php if ($pconfig['partition'] == "gpt") echo "selected"; ?>>GPT (or new software RAID method with GPT)</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("File system");?></td> + <td width="78%" class="vtable"> + <select name="fstype" class="formselect" id="fstype"> + <option value="ufs" <?php if ($pconfig['fstype'] == "ufs") echo "selected=\"selected\""; ?>>UFS</option> + <option value="msdosfs" <?php if ($pconfig['fstype'] == "msdosfs") echo "selected\"selected\""; ?>>FAT</option> + <option value="ntfs" <?php if ($pconfig['fstype'] == "ntfs") echo "selected\"selected\""; ?>>NTFS (read-only)</option> + <option value="ext2fs" <?php if ($pconfig['fstype'] == "ext2fs") echo "selected\"selected\""; ?>>EXT2 FS</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Share name");?></td> + <td width="78%" class="vtable"> + <input name="sharename" type="text" class="formfld unknown" id="sharename" size="20" value="<?=htmlspecialchars($pconfig['sharename']);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td> + <td width="78%" class="vtable"> + <input name="desc" type="text" class="formfld unknown" id="desc" size="20" value="<?=htmlspecialchars($pconfig['desc']);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + <?php if (isset($id) && $a_mount[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + <tr> + <td width="100%" align="left" valign="top" colspan="2"> + <span class="red"> + <strong><?= gettext("WARNING"); ?>:</strong> + </span> + <ol> + <li> + <span class="vexpl"> + <?= gettext("You can't mount the partition '"); ?> + <?php echo htmlspecialchars($cfdevice);?> + <?= gettext("' where the config file is stored"); ?> + </span> + </li> + <li><span class="vexpl"><?= gettext("FreeBSD NTFS has lots of bugs."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/disks_mount_tools.php b/config/freenas/www/disks_mount_tools.php new file mode 100644 index 00000000..4f415b77 --- /dev/null +++ b/config/freenas/www/disks_mount_tools.php @@ -0,0 +1,233 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_mount_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("Mount Point"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +function create_cmd_output(&$action, &$a_mount, &$fullname) { + $cmdout = CMDOUT_PARA_WOHINT; + + ob_end_flush(); + + $retvalue =<<<EOD +{$cmdout} + +EOD; + + /* Get the id of the mount array entry. */ + $id = array_search_ex($fullname, $a_mount, "fullname"); + /* Get the mount data. */ + $mount = $a_mount[$id]; + + switch($action) + { + case "mount": + $diskinit_str = gettext("Mounting '{$fullname}'...") . "<br />"; + $result = disks_mount_fullname($fullname); + break; + case "umount": + $diskinit_str = gettext("Umounting '{$fullname}'...") . "<br />"; + $result = disks_umount_fullname($fullname); + break; + } + + /* Display result */ + (0 == $result) ? $diskinit_str .= gettext("Successful") : $diskinit_str .= gettext("Failed"); + + $retvalue .=<<<EOD + <div id="ismounted_out" style="font-family: Courier, monospace; font-size: small;"> + <pre style="font-family: Courier, monospace; font-size: small; font-style: italic;">{$diskinit_str}</pre> + </div> + +EOD; + + return $retvalue; +} + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_action); + + /* input validation */ + $reqdfields = explode(" ", "fullname action"); + $reqdfieldsn = explode(",", "Fullname,Action"); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if(!$input_errors) + { + $do_action = true; + $fullname = $_POST['fullname']; + $action = $_POST['action']; + + echo create_cmd_output($action, $a_mount, $fullname); + exit; // cause of Ajax + } +} + +if(!isset($do_action)) +{ + $do_action = false; + $fullname = ''; + $action = ''; +} + +// URL GET from the disks_manage_init.php page: +// we get the $disk value, must found the $fullname now +if(isset($_GET['disk'])) { + $disk = $_GET['disk']; + $id = array_search_ex($disk, $a_mount, "mdisk"); + + $fullname = $a_mount[$id]['fullname']; +} +if(isset($_GET['action'])) { + $action = $_GET['action']; +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +$pfSenseHead->setCloseHead(false); +echo $pfSenseHead->getHTML(); + +?> +<script type="text/javascript"> +<!-- +<?= CMDOUT_TOGGLE_FUNC ?> +// --> +</script> +</head> +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_mount_tools.php" method="post" name="iform" id="iform"> +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage"), false, "disks_mount.php"); + $tab_array[1] = array(gettext("Tools"), true, "disks_mount_tools.php"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <?= CMDOUT_AJAX_SCRIPT ?> + <?php if ($input_errors) print_input_errors($input_errors); ?> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Share Name"); ?></td> + <td class="vtable"> + <select name="fullname" class="formselect" id="fullname"> + <?php foreach ($a_mount as $mountv): ?> + <option value="<?=$mountv['fullname'];?>"<?php if ($mountv['fullname'] == $fullname) echo "selected";?>> + <?php echo htmlspecialchars($mountv['sharename'] . " (" . gettext("Disk") . ": " . $mountv['mdisk'] . " " . gettext("Partition") . ": " . $mountv['partition'] . ")");?> + <?php endforeach; ?> + </option> + </select> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Command"); ?></td> + <td class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="mount" <?php if ($action == "mount") echo "selected"; ?>>mount</option> + <option value="umount" <?php if ($action == "umount") echo "selected"; ?>>umount</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="doCMDSubmit" name="doCMDSubmit" type="button" class="formbtn" value="<?=gettext("Send Command!");?>" onclick="execCMD();" /> + </td> + </tr> + <tr> + <!-- Format Output Container - Do Not Delete --> + <td id="cmdOutputTD" valign="top" colspan="2" style="visibility: hidden; border: solid 1px silver; vertical-align: middle; width: 100%"></td> + </tr> + </table> + </div> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gconcat.php b/config/freenas/www/disks_raid_gconcat.php new file mode 100644 index 00000000..e7fc9f81 --- /dev/null +++ b/config/freenas/www/disks_raid_gconcat.php @@ -0,0 +1,236 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gconcat.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Concat"), + gettext("RAID")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['gconcat']['vdisk'])) + $freenas_config['gconcat']['vdisk'] = array(); + +gconcat_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_raid = &$freenas_config['gconcat']['vdisk']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + config_lock(); + /* reload all components that create raid device */ + disks_raid_gconcat_configure(); + config_unlock(); + write_config(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_raidconfdirty_path)) + unlink($d_raidconfdirty_path); + } + } +} + +if ($_GET['act'] == "del") { + if ($a_raid[$_GET['id']]) { + $raidname=$a_raid[$_GET['id']]['name']; + disks_raid_gconcat_delete($raidname); + unset($a_raid[$_GET['id']]); + write_config(); + touch($d_raidconfdirty_path); + pfSenseHeader("disks_raid_gconcat.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_raid_gconcat.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), true, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gconcat.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gconcat_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gconcat_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Volume name");?></td> + <td class="listhdrr"><?=gettext("Type");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_raid as $raid): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['type']);?> + </td> + <td valign="middle" class="listr"> + <?php + $raidconfiguring = file_exists($d_raidconfdirty_path) && + in_array($raid['name']."\n",file($d_raidconfdirty_path)); + if ($raidconfiguring) + echo gettext("configuring"); + else { + $tempo=$raid['name']; + echo "{$raidstatus[$tempo]['size']}"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?php + if ($raidconfiguring) + echo gettext("configuring"); + else { + echo "{$raidstatus[$tempo]['desc']}"; + } + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_raid_gconcat_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_raid_gconcat.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="4"></td> + <td class="list" nowrap> + <a href="disks_raid_gconcat_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="5"> + <span class="red"> + <strong><?= gettext("Note:"); ?></strong> + </span> + <br /> + <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span> + <br /> + <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span> + <br /> + <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span> + </span> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gconcat_edit.php b/config/freenas/www/disks_raid_gconcat_edit.php new file mode 100644 index 00000000..f4bd33cc --- /dev/null +++ b/config/freenas/www/disks_raid_gconcat_edit.php @@ -0,0 +1,256 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gconcat_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Concat"), + gettext("RAID"), + isset($id) ? gettext("Edit") : gettext("Add")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['gconcat']['vdisk'])) + $freenas_config['gconcat']['vdisk'] = array(); + +gconcat_sort(); +disks_sort(); + +$a_raid = &$freenas_config['gconcat']['vdisk']; +$all_raid = array_merge((array)$freenas_config['graid5']['vdisk'],(array)$freenas_config['gconcat']['vdisk'],(array)$freenas_config['gvinum']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gconcat']['vdisk']); +$a_disk = get_fstype_disks_list("softraid"); + +if (!sizeof($a_disk)) { + $nodisk_errors[] = gettext("You must add disks first."); +} + +if (isset($id) && $a_raid[$id]) { + $pconfig['name'] = $a_raid[$id]['name']; + $pconfig['type'] = $a_raid[$id]['type']; + $pconfig['diskr'] = $a_raid[$id]['diskr']; + $pconfig['fullname'] = $a_raid[$id]['fullname']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "name"); + $reqdfieldsn = explode(",", "Name"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['name'] && !is_validaliasname($_POST['name']))) + { + $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."), + "field" => "name"); + } + + /* check for name conflicts */ + foreach ($a_raid as $raid) + { + if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid)) + continue; + + if ($raid['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."), + "field" => "name"); + break; + } + } + + /* check the number of RAID disk for volume */ + + if (count($_POST['diskr']) < 2) + $error_bucket[] = array("error" => gettext("There must be a minimum of 2 disks in a JBOD."), + "field" => "diskr"); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $raid = array(); + $raid['name'] = $_POST['name']; + $raid['type'] = "JBOD"; + $raid['diskr'] = $_POST['diskr']; + $raid['desc'] = "Software gconcat JBOD"; + $raid['fullname'] = "/dev/concat/{$raid['name']}"; + + if (isset($id) && $a_raid[$id]) + $a_raid[$id] = $raid; + else + $a_raid[] = $raid; + + $fd = @fopen("$d_raidconfdirty_path", "a"); + if (!$fd) { + echo "ERR Could not save RAID configuration.\n"; + exit(0); + } + fwrite($fd, "$raid[name]\n"); + fclose($fd); + + write_config(); + + pfSenseHeader("disks_raid_gconcat.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), true, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gconcat_edit.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Raid name");?></td> + <td width="78%" class="vtable"> + <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td> + <td class="vtable">JBOD</td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td> + <td width="78%" class="vtable"> + <? + $i=0; + $disable_script=""; + + foreach ($a_disk as $diskv) { + $r_name=""; + + foreach($all_raid as $raid) { + if (in_array($diskv['fullname'],(array)$raid['diskr'])) { + $r_name=$raid['name']; + if ($r_name!=$pconfig['name']) $disable_script.="document.getElementById($i).disabled=1;\n"; + break; + } + } + echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[fullname]'". + ((is_array($pconfig['diskr']) && in_array($diskv['fullname'],$pconfig['diskr'])) ? " checked=\"checked\"" : "") . + " />$diskv[name] ($diskv[size], $diskv[desc])".(($r_name) ? " - assigned to $r_name" : "")."<br />\n"; + $i++; + + $i++; + } + + if ($disable_script) + echo "<script type='text/javascript'><!--\n$disable_script--></script>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gconcat_infos.php b/config/freenas/www/disks_raid_gconcat_infos.php new file mode 100644 index 00000000..09dfd76a --- /dev/null +++ b/config/freenas/www/disks_raid_gconcat_infos.php @@ -0,0 +1,143 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gconcat_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Concat"), + gettext("Information")); + +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + } +} +if (!isset($do_action)) { +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), true, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gconcat.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gconcat_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gconcat_tools.php"); + $tab_array[2] = array(gettext("Information"), true, "disks_raid_gconcat_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gconcat_infos.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" class="vtable"> + <?php + echo "<pre>"; + echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />"; + + exec("/sbin/gconcat list",$rawdata); + foreach ($rawdata as $line){ + echo htmlspecialchars($line) . "<br>"; + } + + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gconcat_tools.php b/config/freenas/www/disks_raid_gconcat_tools.php new file mode 100644 index 00000000..7783450d --- /dev/null +++ b/config/freenas/www/disks_raid_gconcat_tools.php @@ -0,0 +1,187 @@ +<?php +/* + disks_raid_gmirror_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Concat"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_action); + + $reqdfields = explode(" ", "action object"); + $reqdfieldsn = explode(",", "Action,Object"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $do_action = true; + $action = $_POST['action']; + $object = $_POST['object']; + } + } + if (!isset($do_action)) { + $do_action = false; + $action = ''; + $object = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), true, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), true, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gmirror_tools.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="list" <?php if ($action == "list") echo "selected"; ?>>list</option> + <option value="status" <?php if ($action == "status") echo "selected"; ?>>status</option> + <option value="clear" <?php if ($action == "clear") echo "selected"; ?>>clear</option> + <option value="stop" <?php if ($action == "stop") echo "selected"; ?>>stop</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Send Command!" /> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_action) { + echo("<strong>" . gettext("GCONCAT command output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + system("/sbin/gmirror $action " . escapeshellarg($object)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <ol> + <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li> + <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gmirror.php b/config/freenas/www/disks_raid_gmirror.php new file mode 100644 index 00000000..78390a64 --- /dev/null +++ b/config/freenas/www/disks_raid_gmirror.php @@ -0,0 +1,236 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gmirror.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Mirror"), + gettext("RAID")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['gmirror']['vdisk'])) + $freenas_config['gmirror']['vdisk'] = array(); + +gmirror_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_raid = &$freenas_config['gmirror']['vdisk']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + config_lock(); + /* reload all components that create raid device */ + disks_raid_gmirror_configure(); + config_unlock(); + write_config(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_raidconfdirty_path)) + unlink($d_raidconfdirty_path); + } + } +} + +if ($_GET['act'] == "del") { + if ($a_raid[$_GET['id']]) { + $raidname=$a_raid[$_GET['id']]['name']; + disks_raid_gmirror_delete($raidname); + unset($a_raid[$_GET['id']]); + write_config(); + touch($d_raidconfdirty_path); + pfSenseHeader("disks_raid_gmirror.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_raid_gmirror.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Volume name");?></td> + <td class="listhdrr"><?=gettext("Type");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_raid as $raid): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['type']);?> + </td> + <td valign="middle" class="listr"> + <?php + $raidconfiguring = file_exists($d_raidconfdirty_path) && + in_array($raid['name']."\n",file($d_raidconfdirty_path)); + if ($raidconfiguring) + echo gettext("configuring"); + else { + $tempo=$raid['name']; + echo "{$raidstatus[$tempo]['size']}"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?php + if ($raidconfiguring) + echo gettext("configuring"); + else { + echo "{$raidstatus[$tempo]['desc']}"; + } + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_raid_gmirror_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_raid_gmirror.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="4"></td> + <td class="list" nowrap> + <a href="disks_raid_gmirror_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="5"> + <span class="red"> + <strong><?= gettext("Note:"); ?></strong> + </span> + <br /> + <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span> + <br /> + <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span> + <br /> + <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span> + </span> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gmirror_edit.php b/config/freenas/www/disks_raid_gmirror_edit.php new file mode 100644 index 00000000..ac08a442 --- /dev/null +++ b/config/freenas/www/disks_raid_gmirror_edit.php @@ -0,0 +1,277 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gmirror_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Mirror"), + gettext("RAID"), + isset($id) ? gettext("Edit") : gettext("Add")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['gmirror']['vdisk'])) + $freenas_config['gmirror']['vdisk'] = array(); + +gmirror_sort(); +disks_sort(); + +$a_raid = &$freenas_config['gmirror']['vdisk']; +$all_raid = array_merge((array)$freenas_config['graid5']['vdisk'],(array)$freenas_config['gmirror']['vdisk'],(array)$freenas_config['gvinum']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gconcat']['vdisk']); +$a_disk = get_fstype_disks_list("softraid"); + +if (!sizeof($a_disk)) { + $nodisk_errors[] = gettext("You must add disks first."); +} + +if (isset($id) && $a_raid[$id]) { + $pconfig['name'] = $a_raid[$id]['name']; + $pconfig['fullname'] = $a_raid[$id]['fullname']; + $pconfig['type'] = $a_raid[$id]['type']; + $pconfig['balance'] = $a_raid[$id]['balance']; + $pconfig['diskr'] = $a_raid[$id]['diskr']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "name"); + $reqdfieldsn = explode(",", "Name"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['name'] && !is_validaliasname($_POST['name']))) + { + $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."), + "field" => "name"); + } + + + /* check for name conflicts */ + foreach ($a_raid as $raid) + { + if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid)) + continue; + + if ($raid['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."), + "field" => "name"); + break; + } + } + + /* check the number of RAID disk for volume */ + + if (count($_POST['diskr']) != 2) + $error_bucket[] = array("error" => gettext("There must be 2 disks in a RAID 1 volume."), + "field" => "diskr"); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $raid = array(); + $raid['name'] = $_POST['name']; + $raid['balance'] = $_POST['balance']; + $raid['type'] = 1; + $raid['diskr'] = $_POST['diskr']; + $raid['desc'] = "Software RAID {$_POST['type']}"; + $raid['fullname'] = "/dev/mirror/{$raid['name']}"; + + if (isset($id) && $a_raid[$id]) + $a_raid[$id] = $raid; + else + $a_raid[] = $raid; + + $fd = @fopen("$d_raidconfdirty_path", "a"); + if (!$fd) { + echo "ERR Could not save RAID configuration.\n"; + exit(0); + } + fwrite($fd, "$raid[name]\n"); + fclose($fd); + + write_config(); + + pfSenseHeader("disks_raid_gmirror.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gmirror_edit.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Raid name");?></td> + <td width="78%" class="vtable"> + <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td> + <td class="vtable"> + RAID 1 (<?= gettext("mirroring"); ?>) + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Balance algorithm"); ?></td> + <td width="78%" class="vtable"> + <select name="balance" class="formselect"> + <?php $balvals = array( + "split"=>"Split request", + "load"=>"Read from lowest load", + "round-robin"=>"Round-robin read"); + ?> + <?php foreach ($balvals as $balval => $balname): ?> + <option value="<?=$balval;?>" <?php if($pconfig['balance'] == $balval) echo 'selected';?>><?=htmlspecialchars($balname);?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("Select your read balance algorithm."); ?></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td> + <td width="78%" class="vtable"> + <? + $i=0; + $disable_script=""; + + foreach ($a_disk as $diskv) { + $r_name=""; + + foreach($all_raid as $raid) { + if (in_array($diskv['fullname'],(array)$raid['diskr'])) { + $r_name=$raid['name']; + if ($r_name!=$pconfig['name']) $disable_script.="document.getElementById($i).disabled=1;\n"; + break; + } + } + echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[fullname]'". + ((is_array($pconfig['diskr']) && in_array($diskv['fullname'],$pconfig['diskr'])) ? " checked=\"checked\"" : "") . + " />$diskv[name] ($diskv[size], $diskv[desc])".(($r_name) ? " - assigned to $r_name" : "")."<br />\n"; + $i++; + + $i++; + } + + if ($disable_script) + echo "<script type='text/javascript'><!--\n$disable_script--></script>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gmirror_infos.php b/config/freenas/www/disks_raid_gmirror_infos.php new file mode 100644 index 00000000..878f571e --- /dev/null +++ b/config/freenas/www/disks_raid_gmirror_infos.php @@ -0,0 +1,143 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gmirror_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Mirror"), + gettext("Information")); + +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + } +} +if (!isset($do_action)) { +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), true, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gmirror_infos.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" class="vtable"> + <?php + echo "<pre>"; + echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />"; + + exec("/sbin/gmirror list",$rawdata); + foreach ($rawdata as $line){ + echo htmlspecialchars($line) . "<br>"; + } + + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gmirror_init.php b/config/freenas/www/disks_raid_gmirror_init.php new file mode 100644 index 00000000..2b2d59af --- /dev/null +++ b/config/freenas/www/disks_raid_gmirror_init.php @@ -0,0 +1,179 @@ +<?php +/* $Id$ */ +/* + disks_raid_gmirror_init.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +/* ========================================================================== */ +/* == T H I S F I L E I S C U R R E N T L Y N O T U S E D == */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Mirror"), + gettext("Initialize")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "disk"); + $reqdfieldsn = explode(",", "Disk"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (! $input_errors) { + $do_format = true; + $disk = $_POST['disk']; + } +} + +if (! isset($do_format)) { + $do_format = false; + $disk = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Vinum (unstable)"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Format RAID"), true, "disks_raid_gmirror_init.php"); + $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gmirror_tools.php"); + $tab_array[3] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gmirror_init.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td> + <td width="78%" class="vtable"> + <input name="disk" type="text" class="formfld" id="disk" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_format) { + echo("<strong>" . gettext("Disk format UFS output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + /* Create filesystem */ + system("/sbin/newfs -U /dev/mirror/" . escapeshellarg($disk)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <span class="vexpl"> + <?= gettext("This step will format the RAID volume in Unix FileSystem (UFS)."); ?> + </span> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gmirror_tools.php b/config/freenas/www/disks_raid_gmirror_tools.php new file mode 100644 index 00000000..0fe99576 --- /dev/null +++ b/config/freenas/www/disks_raid_gmirror_tools.php @@ -0,0 +1,191 @@ +<?php +/* + disks_raid_gmirror_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Mirror"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "action object"); + $reqdfieldsn = explode(",", "Action,Object"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $do_action = true; + $action = $_POST['action']; + $object = $_POST['object']; + } + } + if (!isset($do_action)) { + $do_action = false; + $action = ''; + $object = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), true, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gmirror.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), true, "disks_raid_gmirror_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gmirror_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gmirror_tools.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="rebuild" <?php if ($action == "rebuild") echo "selected=\"selected\""; ?>>rebuild</option> + <option value="list" <?php if ($action == "list") echo "selected=\"selected\""; ?>>list</option> + <option value="status" <?php if ($action == "status") echo "selected=\"selected\""; ?>>status</option> + <option value="remove" <?php if ($action == "remove") echo "selected=\"selected\""; ?>>remove</option> + <option value="activate" <?php if ($action == "activate") echo "selected=\"selected\""; ?>>activate</option> + <option value="deactivate" <?php if ($action == "deactivate") echo "selected=\"selected\""; ?>>deactivate</option> + <option value="forget" <?php if ($action == "forget") echo "selected=\"selected\""; ?>>forget</option> + <option value="clear" <?php if ($action == "clear") echo "selected=\"selected\""; ?>>clear</option> + <option value="stop" <?php if ($action == "stop") echo "selected=\"selected\""; ?>>stop</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Send Command!" /> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_action) { + echo("<strong>" . gettext("GMIRROR command output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + system("/sbin/gmirror $action " . escapeshellarg($object)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <ol> + <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li> + <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_graid5.php b/config/freenas/www/disks_raid_graid5.php new file mode 100644 index 00000000..6273b077 --- /dev/null +++ b/config/freenas/www/disks_raid_graid5.php @@ -0,0 +1,236 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_graid5.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM RAID5"), + gettext("RAID")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['graid5']['vdisk'])) + $freenas_config['graid5']['vdisk'] = array(); + +graid5_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_raid = &$freenas_config['graid5']['vdisk']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + config_lock(); + /* reload all components that create raid device */ + disks_raid_graid5_configure(); + config_unlock(); + write_config(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_raidconfdirty_path)) + unlink($d_raidconfdirty_path); + } + } +} + +if ($_GET['act'] == "del") { + if ($a_raid[$_GET['id']]) { + $raidname=$a_raid[$_GET['id']]['name']; + disks_raid_graid5_delete($raidname); + unset($a_raid[$_GET['id']]); + write_config(); + touch($d_raidconfdirty_path); + pfSenseHeader("disks_raid_graid5.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_raid_graid5.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), true, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_graid5.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_graid5_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_graid5_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Volume name");?></td> + <td class="listhdrr"><?=gettext("Type");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_raid as $raid): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['type']);?> + </td> + <td valign="middle" class="listr"> + <?php + $raidconfiguring = file_exists($d_raidconfdirty_path) && + in_array($raid['name']."\n",file($d_raidconfdirty_path)); + if ($raidconfiguring) + echo gettext("configuring"); + else { + $tempo=$raid['name']; + echo "{$raidstatus[$tempo]['size']}"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?php + if ($raidconfiguring) + echo gettext("configuring"); + else { + echo "{$raidstatus[$tempo]['desc']}"; + } + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_raid_graid5_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_raid_graid5.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="4"></td> + <td class="list" nowrap> + <a href="disks_raid_graid5_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="5"> + <span class="red"> + <strong><?= gettext("Note:"); ?></strong> + </span> + <br /> + <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span> + <br /> + <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span> + <br /> + <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span> + </span> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_graid5_edit.php b/config/freenas/www/disks_raid_graid5_edit.php new file mode 100644 index 00000000..27069f6c --- /dev/null +++ b/config/freenas/www/disks_raid_graid5_edit.php @@ -0,0 +1,258 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_graid5_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM RAID5"), + gettext("RAID"), + isset($id) ? gettext("Edit") : gettext("Add")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['graid5']['vdisk'])) + $freenas_config['graid5']['vdisk'] = array(); + +graid5_sort(); +disks_sort(); + +$a_raid = &$freenas_config['graid5']['vdisk']; +$all_raid = array_merge((array)$freenas_config['graid5']['vdisk'],(array)$freenas_config['graid5']['vdisk'],(array)$freenas_config['gvinum']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['graid5']['vdisk']); +$a_disk = get_fstype_disks_list("softraid"); + +if (!sizeof($a_disk)) { + $nodisk_errors[] = gettext("You must add disks first."); +} + +if (isset($id) && $a_raid[$id]) { + $pconfig['name'] = $a_raid[$id]['name']; + $pconfig['type'] = $a_raid[$id]['type']; + $pconfig['diskr'] = $a_raid[$id]['diskr']; + $pconfig['fullname'] = $a_raid[$id]['fullname']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "name"); + $reqdfieldsn = explode(",", "Name"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['name'] && !is_validaliasname($_POST['name']))) + { + $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."), + "field" => "name"); + } + + /* check for name conflicts */ + foreach ($a_raid as $raid) + { + if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid)) + continue; + + if ($raid['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."), + "field" => "name"); + break; + } + } + + /* check the number of RAID disk for volume */ + + if (count($_POST['diskr']) < 3) + $error_bucket[] = array("error" => gettext("There must be a minimum of 3 disks in a RAID 5 volume."), + "field" => "diskr"); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $raid = array(); + $raid['name'] = $_POST['name']; + $raid['type'] = "JBOD"; + $raid['diskr'] = $_POST['diskr']; + $raid['desc'] = "Software graid5 RAID 5"; + $raid['fullname'] = "/dev/raid5/{$raid['name']}"; + + if (isset($id) && $a_raid[$id]) + $a_raid[$id] = $raid; + else + $a_raid[] = $raid; + + $fd = @fopen("$d_raidconfdirty_path", "a"); + if (!$fd) { + echo "ERR Could not save RAID configuration.\n"; + exit(0); + } + fwrite($fd, "$raid[name]\n"); + fclose($fd); + + write_config(); + + pfSenseHeader("disks_raid_graid5.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), true, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_graid5.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_graid5_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_graid5_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_graid5_edit.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Raid name");?></td> + <td width="78%" class="vtable"> + <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td> + <td class="vtable"> + RAID 5 (<?= gettext("rotated block-interleaved parity"); ?>) + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td> + <td width="78%" class="vtable"> + <? + $i=0; + $disable_script=""; + + foreach ($a_disk as $diskv) { + $r_name=""; + + foreach($all_raid as $raid) { + if (in_array($diskv['fullname'],(array)$raid['diskr'])) { + $r_name=$raid['name']; + if ($r_name!=$pconfig['name']) $disable_script.="document.getElementById($i).disabled=1;\n"; + break; + } + } + echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[fullname]'". + ((is_array($pconfig['diskr']) && in_array($diskv['fullname'],$pconfig['diskr'])) ? " checked=\"checked\"" : "") . + " />$diskv[name] ($diskv[size], $diskv[desc])".(($r_name) ? " - assigned to $r_name" : "")."<br />\n"; + $i++; + + $i++; + } + + if ($disable_script) + echo "<script type='text/javascript'><!--\n$disable_script--></script>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_graid5_infos.php b/config/freenas/www/disks_raid_graid5_infos.php new file mode 100644 index 00000000..31506011 --- /dev/null +++ b/config/freenas/www/disks_raid_graid5_infos.php @@ -0,0 +1,143 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_graid5_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM RAID5"), + gettext("Information")); + +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + } +} +if (!isset($do_action)) { +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), true, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_graid5.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gconcat_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_graid5_tools.php"); + $tab_array[2] = array(gettext("Information"), true, "disks_raid_graid5_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_graid5_infos.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" class="vtable"> + <?php + echo "<pre>"; + echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />"; + + exec("/sbin/graid5 list",$rawdata); + foreach ($rawdata as $line){ + echo htmlspecialchars($line) . "<br>"; + } + + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_graid5_tools.php b/config/freenas/www/disks_raid_graid5_tools.php new file mode 100644 index 00000000..c8b3cf5b --- /dev/null +++ b/config/freenas/www/disks_raid_graid5_tools.php @@ -0,0 +1,190 @@ +<?php +/* + disks_raid_graid5_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM RAID5"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_action); + + $reqdfields = explode(" ", "action object"); + $reqdfieldsn = explode(",", "Action,Object"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $do_action = true; + $action = $_POST['action']; + $object = $_POST['object']; + } + } + if (!isset($do_action)) { + $do_action = false; + $action = ''; + $object = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), true, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_graid5.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_graid5_init.php"); */ + $tab_array[1] = array(gettext("Tools"), true, "disks_raid_graid5_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_graid5_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_graid5_tools.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="list" <?php if ($action == "list") echo "selected"; ?>>list</option> + <option value="status" <?php if ($action == "status") echo "selected"; ?>>status</option> + <option value="insert" <?php if ($action == "insert") echo "selected"; ?>>insert</option> + <option value="remove" <?php if ($action == "remove") echo "selected"; ?>>remove</option> + <option value="clear" <?php if ($action == "clear") echo "selected"; ?>>clear</option> + <option value="stop" <?php if ($action == "stop") echo "selected"; ?>>stop</option> + <option value="destroy" <?php if ($action == "destroy") echo "selected"; ?>>destroy</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Send Command!" /> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_action) { + echo("<strong>" . gettext("GCONCAT command output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + system("/sbin/graid5 $action " . escapeshellarg($object)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <ol> + <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li> + <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gstripe.php b/config/freenas/www/disks_raid_gstripe.php new file mode 100644 index 00000000..4d5f622d --- /dev/null +++ b/config/freenas/www/disks_raid_gstripe.php @@ -0,0 +1,236 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gstripe.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Stripe"), + gettext("RAID")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['gstripe']['vdisk'])) + $freenas_config['gstripe']['vdisk'] = array(); + +gstripe_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_raid = &$freenas_config['gstripe']['vdisk']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + config_lock(); + /* reload all components that create raid device */ + disks_raid_gstripe_configure(); + config_unlock(); + write_config(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_raidconfdirty_path)) + unlink($d_raidconfdirty_path); + } + } +} + +if ($_GET['act'] == "del") { + if ($a_raid[$_GET['id']]) { + $raidname=$a_raid[$_GET['id']]['name']; + disks_raid_gstripe_delete($raidname); + unset($a_raid[$_GET['id']]); + write_config(); + touch($d_raidconfdirty_path); + pfSenseHeader("disks_raid_gstripe.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_raid_gstripe.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), true, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gstripe.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gstripe_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gstripe_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Volume name");?></td> + <td class="listhdrr"><?=gettext("Type");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_raid as $raid): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['type']);?> + </td> + <td valign="middle" class="listr"> + <?php + $raidconfiguring = file_exists($d_raidconfdirty_path) && + in_array($raid['name']."\n",file($d_raidconfdirty_path)); + if ($raidconfiguring) + echo gettext("configuring"); + else { + $tempo=$raid['name']; + echo "{$raidstatus[$tempo]['size']}"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?php + if ($raidconfiguring) + echo gettext("configuring"); + else { + echo "{$raidstatus[$tempo]['desc']}"; + } + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_raid_gstripe_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_raid_gstripe.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="4"></td> + <td class="list" nowrap> + <a href="disks_raid_gstripe_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="5"> + <span class="red"> + <strong><?= gettext("Note:"); ?></strong> + </span> + <br /> + <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span> + <br /> + <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span> + <br /> + <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span> + </span> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gstripe_edit.php b/config/freenas/www/disks_raid_gstripe_edit.php new file mode 100644 index 00000000..ab18d6e7 --- /dev/null +++ b/config/freenas/www/disks_raid_gstripe_edit.php @@ -0,0 +1,258 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gstripe_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Stripe"), + gettext("RAID"), + gettext("Edit")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['gstripe']['vdisk'])) + $freenas_config['gstripe']['vdisk'] = array(); + +gstripe_sort(); +disks_sort(); + +$a_raid = &$freenas_config['gstripe']['vdisk']; +$all_raid = array_merge((array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gvinum']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gstripe']['vdisk']); +$a_disk = get_fstype_disks_list("softraid"); + +if (!sizeof($a_disk)) { + $nodisk_errors[] = gettext("You must add disks first."); +} + +if (isset($id) && $a_raid[$id]) { + $pconfig['name'] = $a_raid[$id]['name']; + $pconfig['type'] = $a_raid[$id]['type']; + $pconfig['diskr'] = $a_raid[$id]['diskr']; + $pconfig['fullname'] = $a_raid[$id]['fullname']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "name"); + $reqdfieldsn = explode(",", "Name"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['name'] && !is_validaliasname($_POST['name']))) + { + $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."), + "field" => "name"); + } + + /* check for name conflicts */ + foreach ($a_raid as $raid) + { + if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid)) + continue; + + if ($raid['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."), + "field" => "name"); + break; + } + } + + /* check the number of RAID disk for volume */ + + if (count($_POST['diskr']) < 2) + $error_bucket[] = array("error" => gettext("There must be a minimum of 2 disks in a RAID 0 volume."), + "field" => "diskr"); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $raid = array(); + $raid['name'] = $_POST['name']; + $raid['type'] = "JBOD"; + $raid['diskr'] = $_POST['diskr']; + $raid['desc'] = "Software gstripe RAID 0"; + $raid['fullname'] = "/dev/stripe/{$raid['name']}"; + + if (isset($id) && $a_raid[$id]) + $a_raid[$id] = $raid; + else + $a_raid[] = $raid; + + $fd = @fopen("$d_raidconfdirty_path", "a"); + if (!$fd) { + echo "ERR Could not save RAID configuration.\n"; + exit(0); + } + fwrite($fd, "$raid[name]\n"); + fclose($fd); + + write_config(); + + pfSenseHeader("disks_raid_gstripe.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), true, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gstripe.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gstripe_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gstripe_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gstripe_edit.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Raid name");?></td> + <td width="78%" class="vtable"> + <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td> + <td class="vtable"> + RAID 5 (<?= gettext("rotated block-interleaved parity"); ?>) + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td> + <td width="78%" class="vtable"> + <? + $i=0; + $disable_script=""; + + foreach ($a_disk as $diskv) { + $r_name=""; + + foreach($all_raid as $raid) { + if (in_array($diskv['fullname'],(array)$raid['diskr'])) { + $r_name=$raid['name']; + if ($r_name!=$pconfig['name']) $disable_script.="document.getElementById($i).disabled=1;\n"; + break; + } + } + echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[fullname]'". + ((is_array($pconfig['diskr']) && in_array($diskv['fullname'],$pconfig['diskr'])) ? " checked=\"checked\"" : "") . + " />$diskv[name] ($diskv[size], $diskv[desc])".(($r_name) ? " - assigned to $r_name" : "")."<br />\n"; + $i++; + + $i++; + } + + if ($disable_script) + echo "<script type='text/javascript'><!--\n$disable_script--></script>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gstripe_infos.php b/config/freenas/www/disks_raid_gstripe_infos.php new file mode 100644 index 00000000..5d8a6de0 --- /dev/null +++ b/config/freenas/www/disks_raid_gstripe_infos.php @@ -0,0 +1,143 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_stripe_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Stripe"), + gettext("Information")); + +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + } +} +if (!isset($do_action)) { +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), true, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gstripe.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gconcat_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gstripe_tools.php"); + $tab_array[2] = array(gettext("Information"), true, "disks_raid_gstripe_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gstripe_infos.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" class="vtable"> + <?php + echo "<pre>"; + echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />"; + + exec("/sbin/gstripe list",$rawdata); + foreach ($rawdata as $line){ + echo htmlspecialchars($line) . "<br>"; + } + + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gstripe_tools.php b/config/freenas/www/disks_raid_gstripe_tools.php new file mode 100644 index 00000000..6bc7891a --- /dev/null +++ b/config/freenas/www/disks_raid_gstripe_tools.php @@ -0,0 +1,187 @@ +<?php +/* + disks_raid_stripe_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Stripe"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_action); + + $reqdfields = explode(" ", "action object"); + $reqdfieldsn = explode(",", "Action,Object"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $do_action = true; + $action = $_POST['action']; + $object = $_POST['object']; + } + } + if (!isset($do_action)) { + $do_action = false; + $action = ''; + $object = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), true, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), false, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gstripe.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gstripe_init.php"); */ + $tab_array[1] = array(gettext("Tools"), true, "disks_raid_gstripe_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gstripe_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gstripe_tools.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="list" <?php if ($action == "list") echo "selected"; ?>>list</option> + <option value="status" <?php if ($action == "status") echo "selected"; ?>>status</option> + <option value="clear" <?php if ($action == "clear") echo "selected"; ?>>clear</option> + <option value="stop" <?php if ($action == "stop") echo "selected"; ?>>stop</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Send Command!" /> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_action) { + echo("<strong>" . gettext("GSTRIPE command output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + system("/sbin/gstripe $action " . escapeshellarg($object)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <ol> + <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li> + <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gvinum.php b/config/freenas/www/disks_raid_gvinum.php new file mode 100644 index 00000000..134b2fb5 --- /dev/null +++ b/config/freenas/www/disks_raid_gvinum.php @@ -0,0 +1,235 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gvinum.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Vinum"), + gettext("RAID")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['gvinum']['vdisk'])) + $freenas_config['gvinum']['vdisk'] = array(); + +gvinum_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_raid = &$freenas_config['gvinum']['vdisk']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + config_lock(); + /* reload all components that create raid device */ + disks_raid_gvinum_configure(); + config_unlock(); + write_config(); + } + $savemsg = get_std_save_message($retval); + if ($retval == 0) { + if (file_exists($d_raidconfdirty_path)) + unlink($d_raidconfdirty_path); + } + } + } + + if ($_GET['act'] == "del") { + if ($a_raid[$_GET['id']]) { + $raidname=$a_raid[$_GET['id']]['name']; + disks_raid_gvinum_delete($raidname); + unset($a_raid[$_GET['id']]); + write_config(); + touch($d_raidconfdirty_path); + pfSenseHeader("disks_raid_gvinum.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<form action="disks_raid_gvinum.php" method="post" name="iform" id="iform"> +<?php if (file_exists($d_diskdirty_path)): ?> +<?php print_info_box_np(gettext("The Raid configuration has been changed.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), true, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gvinum.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="listhdrr"><?=gettext("Volume name");?></td> + <td class="listhdrr"><?=gettext("Type");?></td> + <td class="listhdrr"><?=gettext("Size");?></td> + <td class="listhdrr"><?=gettext("Status");?></td> + <td class="list"> </td> + </tr> + <?php $i = 0; foreach ($a_raid as $raid): ?> + <tr> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['name']);?> + </td> + <td valign="middle" class="listr"> + <?=htmlspecialchars($raid['type']);?> + </td> + <td valign="middle" class="listr"> + <?php + $raidconfiguring = file_exists($d_raidconfdirty_path) && + in_array($raid['name']."\n",file($d_raidconfdirty_path)); + if ($raidconfiguring) + echo gettext("configuring"); + else { + $tempo=$raid['name']; + echo "{$raidstatus[$tempo]['size']}"; + } + ?> + </td> + <td valign="middle" class="listr"> + <?php + if ($raidconfiguring) + echo "_CONFIGURING"; + else { + echo "{$raidstatus[$tempo]['desc']}"; + } + ?> + </td> + <td valign="middle" class="list"> + <a href="disks_raid_gvinum_edit.php?id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit raid");?>" width="17" height="17" border="0" alt="" /> + </a> + <a href="disks_raid_gvinum.php?act=del&id=<?=$i;?>"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete raid");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <?php $i++; endforeach; ?> + <tr> + <td class="list" colspan="4"></td> + <td class="list" nowrap> + <a href="disks_raid_gvinum_edit.php"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add disk");?>" width="17" height="17" border="0" alt="" /> + </a> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="5"> + <span class="red"> + <strong><?= gettext("Note:"); ?></strong> + </span> + <br /> + <span class="vexpl"><?= gettext("Optional configuration step: Configuring a virtual RAID disk using your"); ?></span> + <br /> + <span class="vexpl"><a href="disks_manage.php"><?= gettext("previsously configured disk."); ?></a></span> + <br /> + <span class="vexpl"><?= gettext("Wait for the \"up\" status before format it and mount it!."); ?></span> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gvinum_edit.php b/config/freenas/www/disks_raid_gvinum_edit.php new file mode 100644 index 00000000..e0245419 --- /dev/null +++ b/config/freenas/www/disks_raid_gvinum_edit.php @@ -0,0 +1,277 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gvinum_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Vinum"), + gettext("RAID"), + isset($id) ? gettext("Edit") : gettext("Add")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['raid']['vdisk'])) + $freenas_config['raid']['vdisk'] = array(); + +gvinum_sort(); +disks_sort(); + +$a_raid = &$freenas_config['gvinum']['vdisk']; +$a_disk = get_fstype_disks_list("softraid"); +$all_raid = array_merge((array)$freenas_config['graid5']['vdisk'],(array)$freenas_config['gmirror']['vdisk'],(array)$freenas_config['gvinum']['vdisk'],(array)$freenas_config['gstripe']['vdisk'],(array)$freenas_config['gconcat']['vdisk']); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!sizeof($a_disk)) { + $nodisk_errors[] = gettext("You must add disks first."); +} + +if (isset($id) && $a_raid[$id]) { + $pconfig['name'] = $a_raid[$id]['name']; + $pconfig['fullname'] = $a_raid[$id]['fullname']; + $pconfig['type'] = $a_raid[$id]['type']; + $pconfig['diskr'] = $a_raid[$id]['diskr']; +} + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "name type"); + $reqdfieldsn = explode(",", "Name,Type"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['name'] && !is_validaliasname($_POST['name']))) + { + $error_bucket[] = array("error" => gettext("The device name may only consist of the characters a-z, A-Z, 0-9."), + "field" => "name"); + } + + /* check for name conflicts */ + foreach ($a_raid as $raid) + { + if (isset($id) && ($a_raid[$id]) && ($a_raid[$id] === $raid)) + continue; + + if ($raid['name'] == $_POST['name']) + { + $error_bucket[] = array("error" => gettext("This device already exists in the raid volume list."), + "field" => "name"); + break; + } + } + + /* check the number of RAID disk for volume */ + + switch ($_POST['type']) + { + case 0: + if (count($_POST['diskr']) < 2) + $error_bucket[] = array("error" => gettext("There must be a minimum of 2 disks in a RAID 0 volume."), + "field" => "diskr"); + break; + case 1: + if (count($_POST['diskr']) != 2) + $error_bucket[] = array("error" => gettext("There must be 2 disks in a RAID 1 volume."), + "field" => "diskr"); + break; + case 5: + if (count($_POST['diskr']) < 3) + $error_bucket[] = array("error" => gettext("There must be a minimum of 3 disks in a RAID 5 volume."), + "field" => "diskr"); + break; + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $raid = array(); + $raid['name'] = $_POST['name']; + $raid['type'] = $_POST['type']; + $raid['diskr'] = $_POST['diskr']; + $raid['desc'] = "Software gvinum RAID {$_POST['type']}"; + $raid['fullname'] = "/dev/gvinum/{$raid['name']}"; + + if (isset($id) && $a_raid[$id]) + $a_raid[$id] = $raid; + else + $a_raid[] = $raid; + + $fd = @fopen("$d_raidconfdirty_path", "a"); + if (!$fd) { + echo gettext("ERR Could not save RAID configuration.\n"); + exit(0); + } + fwrite($fd, "$raid[name]\n"); + fclose($fd); + + write_config(); + + pfSenseHeader("disks_raid_gvinum.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), true, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), true, "disks_raid_gvinum.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gvinum_edit.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Raid name");?></td> + <td width="78%" class="vtable"> + <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>" /> + </td> + </tr> + <tr> + <td valign="top" class="vncellreq"><?= gettext("Type"); ?></td> + <td class="vtable"> + <select name="type" class="formselect" id="type"> + <option value="0" <?php if ($pconfig['type'] == 0) echo "selected=\"selected\""; ?>>RAID 0 (<?= gettext("striping"); ?>)</option> + <option value="1" <?php if ($pconfig['type'] == 1) echo "selected=\"selected\""; ?>>RAID 1 (<?= gettext("mirroring"); ?>)</option> + <option value="5" <?php if ($pconfig['type'] == 5) echo "selected=\"selected\""; ?>>RAID 5 (<?= gettext("rotated block-interleaved parity"); ?>)</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Members of this volume"); ?></td> + <td width="78%" class="vtable"> + <? + $i=0; + $disable_script=""; + + foreach ($a_disk as $diskv) { + $r_name=""; + + if (strcmp($diskv['fstype'],"raid")==0) { + foreach($all_raid as $raid) { + if (in_array($diskv['name'],$raid['diskr'])) { + $r_name=$raid['name']; + + if ($r_name!=$pconfig['name']) + $disable_script.="document.getElementById($i).disabled=1;\n"; + break; + } + } + echo "<input name='diskr[]' id='$i' type='checkbox' value='$diskv[name]'". + ((is_array($pconfig['diskr']) && in_array($diskv['name'], $pconfig['diskr'])) ? " checked=\"checked\"" : ""). + " />$diskv[name] ($diskv[size], $diskv[desc])" . (($r_name) ? " - assigned to $r_name" : "") . "<br>\n"; + } + $i++; + } + if ($disable_script) echo "<script type='text/javascript'><!--\n$disable_script--></script>\n"; + ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gvinum_infos.php b/config/freenas/www/disks_raid_gvinum_infos.php new file mode 100644 index 00000000..71a424fa --- /dev/null +++ b/config/freenas/www/disks_raid_gvinum_infos.php @@ -0,0 +1,144 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gvinum_infos.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Vinum"), + gettext("Information")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + } +} +if (!isset($do_action)) { +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), true, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php"); + $tab_array[2] = array(gettext("Information"), true, "disks_raid_gvinum_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gvinum_infos.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" class="vtable"> + <?php + echo "<pre>"; + echo "<strong>" . gettext("Software RAID information and status") . "</strong><br />"; + + exec("/sbin/gvinum list",$rawdata); + foreach ($rawdata as $line) + { + echo htmlspecialchars($line) . "<br>"; + } + unset ($line); + echo "</pre>"; + ?> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gvinum_init.php b/config/freenas/www/disks_raid_gvinum_init.php new file mode 100644 index 00000000..787c416e --- /dev/null +++ b/config/freenas/www/disks_raid_gvinum_init.php @@ -0,0 +1,181 @@ +<?php +/* $Id$ */ +/* + disks_raid_gmirror_init.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +/* ========================================================================== */ +/* == T H I S F I L E I S C U R R E N T L Y N O T U S E D == */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Vinum"), + gettext("Initialize")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $reqdfields = explode(" ", "disk"); + $reqdfieldsn = explode(",", "Disk"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (! $input_errors) { + $do_format = true; + $disk = $_POST['disk']; + } +} + +if (! isset($do_format)) { + $do_format = false; + $disk = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Vinum (unstable)"), true, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php"); + $tab_array[1] = array(gettext("Format RAID"), true, "disks_raid_gvinum_init.php"); + $tab_array[2] = array(gettext("Tools"), false, "disks_raid_gvinum_tools.php"); + $tab_array[3] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gvinum_init.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Volume name");?></td> + <td width="78%" class="vtable"> + <input name="disk" type="text" class="formfld" id="disk" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Save" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_format) { + echo("<strong>_DISKSRAIDINITPHP_INFO</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + /* Create filesystem */ + system("/sbin/newfs -U /dev/gvinum/" . escapeshellarg($disk)); + /* Do it twice for test the RAID5 bug at reboot*/ + system("/sbin/newfs -U /dev/gvinum/" . escapeshellarg($disk)); + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <span class="vexpl"> + <?= gettext("This step will format the RAID volume in Unix FileSystem (UFS)."); ?> + </span> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/disks_raid_gvinum_tools.php b/config/freenas/www/disks_raid_gvinum_tools.php new file mode 100644 index 00000000..343fc221 --- /dev/null +++ b/config/freenas/www/disks_raid_gvinum_tools.php @@ -0,0 +1,220 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + disks_raid_gvinum_tools.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("System"), + gettext("Disks"), + gettext("GEOM Vinum"), + gettext("Tools")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_action); + + $reqdfields = explode(" ", "action object"); + $reqdfieldsn = explode(",", "Action,Object"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) { + $do_action = true; + $action = $_POST['action']; + $object = $_POST['object']; + } + } + if (!isset($do_action)) { + $do_action = false; + $action = ''; + $object = ''; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Geom Mirror"), false, "disks_raid_gmirror.php"); + $tab_array[1] = array(gettext("Geom Concat"), false, "disks_raid_gconcat.php"); + $tab_array[2] = array(gettext("Geom Stripe"), false, "disks_raid_gstripe.php"); + $tab_array[3] = array(gettext("Geom RAID5"), false, "disks_raid_graid5.php"); + $tab_array[4] = array(gettext("Geom Vinum"), true, "disks_raid_gvinum.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Manage RAID"), false, "disks_raid_gvinum.php"); + /* $tab_array[1] = array(gettext("Format RAID"), false, "disks_raid_gmirror_init.php"); */ + $tab_array[1] = array(gettext("Tools"), true, "disks_raid_gvinum_tools.php"); + $tab_array[2] = array(gettext("Information"), false, "disks_raid_gvinum_infos.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form action="disks_raid_gvinum_tools.php" method="post" name="iform" id="iform"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <input name="object" type="text" class="formfld unknown" id="object" size="20" value="<?=htmlspecialchars($disk);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Object name");?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect" id="action"> + <option value="start" <?php if ($action == "start") echo "selected=\"selected\""; ?>>start</option> + <option value="rebuild" <?php if ($action == "rebuild") echo "selected=\"selected\""; ?>>rebuild parity</option> + <option value="list" <?php if ($action == "list") echo "selected=\"selected\""; ?>>list</option> + <option value="remove" <?php if ($action == "remove") echo "selected=\"selected\""; ?>>remove</option> + <option value="forceup" <?php if ($action == "forceup") echo "selected=\"selected\""; ?>>Force State to UP</option> + <option value="saveconfig" <?php if ($action == "saveconfig") echo "selected=\"selected\""; ?>>saveconfig</option> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="Submit" type="submit" class="formbtn" value="Send Command!" /> + <?php if (isset($id) && $a_raid[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + <tr> + <td valign="top" colspan="2"> + <? + if ($do_action) { + echo("<strong>" . gettext("GVINUM command output:") . "</strong><br />"); + echo('<pre>'); + ob_end_flush(); + + switch ($action) + { + case "remove": + /* Remove recursivly object */ + system("/sbin/gvinum rm -r " . escapeshellarg($object)); + break; + case "start": + /* Start object */ + system("/sbin/gvinum start " . escapeshellarg($object)); + break; + case "rebuild": + /* Rebuild RAID 5 parity */ + system("/sbin/gvinum rebuildparity " . escapeshellarg($object)); + break; + case "list": + /* Disaply a detailed list of object */ + system("/sbin/gvinum list " . escapeshellarg($object)); + break; + case "forceup": + /* Force object state up */ + system("/sbin/gvinum setstate -f up " . escapeshellarg($object)); + break; + case "saveconfig": + /* Save config */ + system("/sbin/gvinum saveconfig"); + break; + } + + echo('</pre>'); + } + ?> + </td> + </tr> + <tr> + <td align="left" valign="top" colspan="2"> + <span class="red"> + <strong>WARNING:</strong><br /> + </span> + <ol> + <li><span class="vexpl"><?= gettext("Use these specials actions for debugging only!"); ?></span></li> + <li><span class="vexpl"><?= gettext("There is no need of using this menu for start a RAID volume (start automaticaly)."); ?></span></li> + </ol> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +</body> +</html> diff --git a/config/freenas/www/services_afp.php b/config/freenas/www/services_afp.php new file mode 100644 index 00000000..2487c6f7 --- /dev/null +++ b/config/freenas/www/services_afp.php @@ -0,0 +1,199 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_afp.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("AFP")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['afp'])) { + $freenas_config['afp'] = array(); +} + + +$pconfig['enable'] = isset($freenas_config['afp']['enable']); +$pconfig['afpname'] = $freenas_config['afp']['afpname']; +$pconfig['guest'] = isset($freenas_config['afp']['guest']); +$pconfig['local'] = isset($freenas_config['afp']['local']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = split(" ", "afpname"); + $reqdfieldsn = split(",", "Afpname"); + + do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); + + if ($_POST['enable'] && !$_POST['guest']) + { + if (!$_POST['local']) + $error_bucket[] = array("error" => gettext("You must select at least one authentication method."), + "field" => "local"); + } + if ($_POST['enable'] && !$_POST['local']) + { + if (!$_POST['guest']) + $error_bucket[] = array("error" => gettext("You must select at least one authentication method."), + "field" => "name"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['afp']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['afp']['guest'] = $_POST['guest'] ? true : false; + $freenas_config['afp']['local'] = $_POST['local'] ? true : false; + $freenas_config['afp']['afpname'] = $_POST['afpname']; + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + /* nuke the cache file */ + config_lock(); + services_afpd_configure(); + services_zeroconf_configure(); + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.guest.disabled = endis; + document.iform.local.disabled = endis; + document.iform.afpname.disabled = endis; + /* color adjustments */ + document.iform.guest.style.backgroundColor = color; + document.iform.local.style.backgroundColor = color; + document.iform.afpname.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="services_afp.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("AFP Server");?></span> + <span style="vertical-align: middle; position: relative; left: 84%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Server Name");?></td> + <td width="78%" class="vtable"> + <input name="afpname" type="text" class="formfld unknown" id="afpname" size="20" value="<?=htmlspecialchars($pconfig['afpname']);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Authentication");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="guest" id="guest" type="checkbox" value="yes" <?php if ($pconfig['guest']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable guest access."); ?><br /> + <input name="local" id="local" type="checkbox" value="yes" <?php if ($pconfig['local']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable local user authentication."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_ftp.php b/config/freenas/www/services_ftp.php new file mode 100644 index 00000000..050361e5 --- /dev/null +++ b/config/freenas/www/services_ftp.php @@ -0,0 +1,392 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_ftp.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("FTP")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['ftp'])) +{ + $freenas_config['ftp'] = array(); +} + +$pconfig['enable'] = isset($freenas_config['ftp']['enable']); +$pconfig['port'] = $freenas_config['ftp']['port']; +$pconfig['authbackend'] = $freenas_config['ftp']['authentication_backend']; +$pconfig['numberclients'] = $freenas_config['ftp']['numberclients']; +$pconfig['maxconperip'] = $freenas_config['ftp']['maxconperip']; +$pconfig['timeout'] = $freenas_config['ftp']['timeout']; +$pconfig['anonymous'] = isset($freenas_config['ftp']['anonymous']); +$pconfig['localuser'] = isset($freenas_config['ftp']['localuser']); +$pconfig['pasv_max_port'] = $freenas_config['ftp']['pasv_max_port']; +$pconfig['pasv_min_port'] = $freenas_config['ftp']['pasv_min_port']; +$pconfig['pasv_address'] = $freenas_config['ftp']['pasv_address']; +$pconfig['banner'] = $freenas_config['ftp']['banner']; +$pconfig['natmode'] = isset($freenas_config['ftp']['natmode']); +$pconfig['passiveip'] = $freenas_config['ftp']['passiveip']; +$pconfig['fxp'] = isset($freenas_config['ftp']['fxp']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']) { + $reqdfields = array_merge($reqdfields, explode(" ", "numberclients maxconperip timeout port")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Numberclients,Maxconperip,Timeout,Port")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['enable'] && !is_port($_POST['port'])) + { + $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."), + "field" => "port"); + } + if ($_POST['enable'] && !is_numericint($_POST['numberclients'])) { + $error_bucket[] = array("error" => gettext("The maximum Number of client must be a number."), + "field" => "numberclients"); + } + + if ($_POST['enable'] && !is_numericint($_POST['maxconperip'])) { + $error_bucket[] = array("error" => gettext("The max con per ip must be a number."), + "field" => "maxconperip"); + } + if ($_POST['enable'] && !is_numericint($_POST['timeout'])) { + $error_bucket[] = array("error" => gettext("The maximum idle time be a number."), + "field" => "timeout"); + } + + if ($_POST['enable'] && ($_POST['pasv_address'])) + { + if (!is_ipaddr($_POST['pasv_address'])) + $error_bucket[] = array("error" => gettext("The pasv address must be a public IP address."), + "field" => "pasv_address"); + + } + + if ($_POST['enable'] && ($_POST['pasv_max_port'])) + { + if (!is_port($_POST['pasv_max_port'])) + $error_bucket[] = array("error" => gettext("The pasv_max_port port must be a valid port number."), + "field" => "pasv_max_port"); + } + + if ($_POST['enable'] && ($_POST['pasv_min_port'])) + { + if (!is_port($_POST['pasv_min_port'])) + $error_bucket[] = array("error" => gettext("The pasv_min_port port must be a valid port number."), + "field" => "pasv_min_port"); + + } + + if (($_POST['passiveip'] && !is_ipaddr($_POST['passiveip']))) { + $error_bucket[] = array("error" => gettext("A valid IP address must be specified."), + "field" => "passiveip"); + + } + + if (!($_POST['anonymous']) && !($_POST['localuser'])) { + $input_errors[] = _SRVFTP_MSGVALIDAUTH; + $error_bucket[] = array("error" => gettext("You must select at minium anonymous or/and local user authentication."), + "field" => "localuser"); + + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['ftp']['numberclients'] = $_POST['numberclients']; + $freenas_config['ftp']['maxconperip'] = $_POST['maxconperip']; + $freenas_config['ftp']['timeout'] = $_POST['timeout']; + $freenas_config['ftp']['port'] = $_POST['port']; + $freenas_config['ftp']['authentication_backend'] = $_POST['authbackend']; + $freenas_config['ftp']['anonymous'] = $_POST['anonymous'] ? true : false; + $freenas_config['ftp']['localuser'] = $_POST['localuser'] ? true : false; + $freenas_config['ftp']['pasv_max_port'] = $_POST['pasv_max_port']; + $freenas_config['ftp']['pasv_min_port'] = $_POST['pasv_min_port']; + $freenas_config['ftp']['pasv_address'] = $_POST['pasv_address']; + $freenas_config['ftp']['banner'] = $_POST['banner']; + $freenas_config['ftp']['passiveip'] = $_POST['passiveip']; + $freenas_config['ftp']['fxp'] = $_POST['fxp'] ? true : false; + $freenas_config['ftp']['natmode'] = $_POST['natmode'] ? true : false; + $freenas_config['ftp']['enable'] = $_POST['enable'] ? true : false; + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) { + /* nuke the cache file */ + config_lock(); + services_wzdftpd_configure(); + services_zeroconf_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.port.disabled = endis; + document.iform.authbackend.disabled = endis; + document.iform.timeout.disabled = endis; + document.iform.numberclients.disabled = endis; + document.iform.maxconperip.disabled = endis; + document.iform.anonymous.disabled = endis; + document.iform.localuser.disabled = endis; + document.iform.banner.disabled = endis; + document.iform.fxp.disabled = endis; + document.iform.natmode.disabled = endis; + document.iform.passiveip.disabled = endis; + document.iform.pasv_max_port.disabled = endis; + document.iform.pasv_min_port.disabled = endis; + /* color adjustments */ + document.iform.port.style.backgroundColor = color; + document.iform.authbackend.backgroundColor = color; + document.iform.timeout.style.backgroundColor = color; + document.iform.numberclients.style.backgroundColor = color; + document.iform.maxconperip.style.backgroundColor = color; + document.iform.anonymous.style.backgroundColor = color; + document.iform.localuser.style.backgroundColor = color; + document.iform.banner.style.backgroundColor = color; + document.iform.fxp.style.backgroundColor = color; + document.iform.natmode.style.backgroundColor = color; + document.iform.passiveip.style.backgroundColor = color; + document.iform.pasv_max_port.style.backgroundColor = color; + document.iform.pasv_min_port.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="services_ftp.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("FTP Server");?></span> + <span style="vertical-align: middle; position: relative; left: 84%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("TCP port");?></td> + <td width="78%" class="vtable"> + <input name="port" type="text" class="formfld unknown" id="port" size="20" value="<?=htmlspecialchars($pconfig['port']);?>" /> + </td> + </tr> + <?php + if (file_exists("/usr/local/sbin/wzdftpd")) { + $a_backends = array(); + + $dh = opendir("/usr/local/share/wzdftpd/backends"); + while (false !== ($filename = readdir($dh))) { + if (preg_match("/\.so$/", $filename)) { + $lastslash = strrpos($filename, "/"); + $dot = strrpos($filename, "."); + + $backend_name = str_replace("libwzd", + "", + substr($filename, + $lastslash, + $dot - $lastslash)); + $a_backends[] = $backend_name; + } + } + } + ?> + <?php if (is_array($a_backends)) : ?> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication Backend");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="authbackend" id="authbackend" class="formselect"> + <?php foreach ($a_backends as $backend) : ?> + <option value="<?= $backend ?>"><?= $backend ?></option> + <?php endforeach; ?> + </select><br /> + <?= gettext("Choose a particular backend, that will be used to authenticate FTP users."); ?> + </td> + </tr> + <?php endif; ?> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Number of clients");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="numberclients" type="text" class="formfld unknown" id="numberclients" size="20" value="<?=htmlspecialchars($pconfig['numberclients']);?>" /> + <br /> + <?= gettext("Maximum number of simultaneous clients."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Max conn per ip");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="maxconperip" type="text" class="formfld unknown" id="maxconperip" size="20" value="<?=htmlspecialchars($pconfig['maxconperip']);?>" /> + <br /> + <?= gettext("Maximum connection per IP address."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Timeout");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="timeout" type="text" class="formfld unknown" id="timeout" size="20" value="<?=htmlspecialchars($pconfig['timeout']);?>" /> + <br /> + <?= gettext("Maximum idle time in seconds."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Anonymous login");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="anonymous" type="checkbox" id="anonymous" value="yes" <?php if ($pconfig['anonymous']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable Anonymous login"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Local User");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="localuser" type="checkbox" id="localuser" value="yes" <?php if ($pconfig['localuser']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable local User login"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Banner");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <textarea name="banner" cols="65" rows="7" id="banner" class="formpre"><?=htmlspecialchars($pconfig['banner']);?></textarea> + <br /> + <?= gettext("Greeting banner displayed by FTP when a connection first comes in."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("FXP");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="fxp" type="checkbox" id="fxp" value="yes" <?php if ($pconfig['fxp']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable FXP protocol."); ?> + <br /> + <?= gettext("FXP allows transfers between two remote servers without any file data going to the client asking for the transfer (insecure!)."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("NAT mode");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="natmode" type="checkbox" id="natmode" value="yes" <?php if ($pconfig['natmode']) echo "checked=\"checked\""; ?> /> + <?= gettext("Force NAT mode"); ?> + <br /> + <?= gettext("Enable it if your FTP server is behind a NAT box that doesn't support applicative FTP proxying"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Passive IP address");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="passiveip" type="text" class="formfld unknown" id="passiveip" size="30" value="<?=htmlspecialchars($pconfig['passiveip']);?>" /> + <?= gettext("Use this option to override the IP address that FTP daemon will advertise in response to the PASV command."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("pasv_min_port");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="pasv_min_port" type="text" class="formfld unknown" id="pasv_min_port" size="20" value="<?=htmlspecialchars($pconfig['pasv_min_port']);?>" /> + <?= gettext("The minimum port to allocate for PASV style data connections."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("pasv_max_port");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="pasv_max_port" type="text" class="formfld unknown" id="pasv_max_port" size="20" value="<?=htmlspecialchars($pconfig['pasv_max_port']);?>" /> + <?= gettext("The maximum port to allocate for PASV style data connections."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submitt" name="Submitt" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_nfs.php b/config/freenas/www/services_nfs.php new file mode 100644 index 00000000..7b4b9a18 --- /dev/null +++ b/config/freenas/www/services_nfs.php @@ -0,0 +1,243 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_nfs.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("NFS")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['nfs'])) +{ + $freenas_config['nfs'] = array(); +} + +$pconfig['enable'] = isset($freenas_config['nfs']['enable']); +$pconfig['bindto'] = $freenas_config['nfs']['bindto']; +$pconfig['serveudp'] = isset($freenas_config['nfs']['serveudp']); +$pconfig['servetcp'] = isset($freenas_config['nfs']['servetcp']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = explode(" ", "bindto"); + $reqdfieldsn = explode(",", "IP address to bind to"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['nfs']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['nfs']['bindto'] = $_POST['bindto']; + if (isset($_POST['servetcp'])) { + $freenas_config['nfs']['servetcp'] = $_POST['servetcp']; + } else { + unset($freenas_config['nfs']['servetcp']); + } + if (isset($_POST['serveudp'])) { + $freenas_config['nfs']['serveudp'] = $_POST['serveudp']; + } else { + unset($freenas_config['nfs']['serveudp']); + } + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + /* nuke the cache file */ + config_lock(); + services_nfs_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.servetcp.disabled = endis; + document.iform.serveudp.disabled = endis; + document.iform.bindto.disabled = endis; + /* color adjustments */ + document.iform.servetcp.style.backgroundColor = color; + document.iform.serveudp.style.backgroundColor = color; + document.iform.bindto.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<form id="iform" name="iform" action="services_nfs.php" method="post"> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Settings"), true, "services_nfs.php"); + $tab_array[1] = array(gettext("Exports"), false, "services_nfs_export.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("NFS Server");?></span> + <span style="vertical-align: middle; position: relative; left: 84%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Bind to IP address");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="bindto" id="bindto" class="formselect"> + <option value="(ANY)"<?php if ($pconfig['bindto'] == "(ANY)") { echo " selected=\"selected\""; } ?>> + (ANY) + </option> + <option value="<?= $config['interfaces']['wan'][ipaddr] ?>"<?php if ($pconfig['bindto'] == $config['interfaces']['wan'][ipaddr]) { echo " selected=\"selected\""; } ?>> + <?= $config['interfaces']['wan'][ipaddr] ?> + </option> + <option value="<?= $config['interfaces']['lan'][ipaddr] ?>"<?php if ($pconfig['bindto'] == $config['interfaces']['lan'][ipaddr]) { echo " selected=\"selected\""; } ?>> + <?= $config['interfaces']['lan'][ipaddr] ?> + </option> + <?php + for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): + ?> + <option value="<?= $config['interfaces']['opt' . $i][ipaddr] ?>"<?php if ($pconfig['bindto'] == $config['interfaces']['opt' . $i][ipaddr]) { echo " selected=\"selected\""; } ?>> + <?= $config['interfaces']['opt' . $i][ipaddr] ?> + </option> + <?php endfor; ?> + </select> + <br /> + <?= gettext("Use an address from the list to make nfsd and rpcbind bind to a specific address."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Client Types");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <p> + <input type="checkbox" name="servetcp" id="servetcp" value="on"<?php if ($pconfig['servetcp']) { echo " checked=\"checked\""; } ?>/> + <label for="servetcp"><?= gettext("Serve TCP NFS clients"); ?></label> + </p> + <p> + <input type="checkbox" name="serveudp" id="serveudp" value="on"<?php if ($pconfig['serveudp']) { echo " checked=\"checked\""; } ?>/> + <label for="serveudp"><?= gettext("Serve UDP NFS clients"); ?></label> + </p> + <p> + <span class="red"><strong><?= gettext("Note"); ?>: </strong></span> + <span class="vexpl"> + <?= gettext("Usually it's save to enable support for both, UDP and TCP client types."); ?> + </span> + </p> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_nfs_export.php b/config/freenas/www/services_nfs_export.php new file mode 100644 index 00000000..c1712762 --- /dev/null +++ b/config/freenas/www/services_nfs_export.php @@ -0,0 +1,165 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_nfs_export.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("NFS"), + gettext("Exports")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + if($_POST['apply']) { + $retval = 0; + if(!file_exists($d_sysrebootreqd_path)) { + config_lock(); + services_nfs_configure(); + services_zeroconf_configure(); + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + + if(0 == $retval) { + if(file_exists($d_nfsexportconfdirty_path)) + unlink($d_nfsexportconfdirty_path); + } + } + } +} + +if($_GET['act'] == "ret") { + pfSenseHeader("services_nfs_export.php"); + exit; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<form id="iform" name="iform" action="services_nfs_export.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if (file_exists($d_nfsexportconfdirty_path)): ?> +<?php print_info_box_np(gettext("The exports have been modified.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<div id="inputerrors"></div> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Settings"), false, "services_nfs.php"); + $tab_array[1] = array(gettext("Exports"), true, "services_nfs_export.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%" class="listhdrr"><?= gettext("Export"); ?></td> + <td width="25%" class="listhdrr"><?= gettext("Description"); ?></td> + <td width="20%" class="listhdrr"><?= gettext("Export To"); ?></td> + <td width="10%" class="list"></td> + </tr> + <?php $i = 0; foreach($a_mount as $mountv): ?> + <tr> + <td class="listr">/mnt/<?=htmlspecialchars($mountv['sharename']);?></td> + <td class="listr"><?=htmlspecialchars($mountv['desc']);?></td> + <td class="listbg" style="color: #FFFFFF;"><?= isset($mountv['nfs']['networks']) ? str_replace(",", "<br />", htmlspecialchars($mountv['nfs']['networks'])) : gettext("None"); ?></td> + <td valign="middle" nowrap class="list"> + <?php if(isset($freenas_config['nfs']['enable'])) + echo("<a href='services_nfs_export_edit.php?id={$i}'><img src='./themes/" . $g['theme'] . "/images/icons/icon_e.gif' alt='" . gettext("Edit Export") . "' title='" . gettext("Edit Export") . "' width='17' height='17' border='0' /></a>"); + ?> + </td> + </tr> + <?php $i++; endforeach; ?> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/services_nfs_export_edit.php b/config/freenas/www/services_nfs_export_edit.php new file mode 100644 index 00000000..f9fd53ea --- /dev/null +++ b/config/freenas/www/services_nfs_export_edit.php @@ -0,0 +1,783 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_samba_share_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("NFS"), + gettext("Exports"), + gettext("Edit")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$pconfig['mapall'] = $freenas_config['mounts']['mount'][$id]['nfs']['mapall']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = explode(" ", "authnetworks"); + $reqdfieldsn = explode(",", "Destination network"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (isset($_POST['authnetworks']) && is_array($_POST['authnetworks'])) { + foreach ($_POST['authnetworks'] as $netel) { + list($_POST['network'], $_POST['network_subnet']) = explode('/', $netel); + + if (($_POST['network'] && !is_ipaddr($_POST['network']))) { + $error_bucket[] = array("error" => gettext("A valid network must be specified."), + "field" => "network"); + } + + if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) { + $error_bucket[] = array("error" => gettext("A valid network bit count must be specified."), + "field" => "network_subnet"); + } + + $osn[] = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet']; + } + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['mounts']['mount'][$id]['nfs']['networks'] = implode(",", $osn); + $freenas_config['mounts']['mount'][$id]['nfs']['mapall'] = $_POST['mapall']; + + touch($d_nfsexportconfdirty_path); + write_config(); + pfSenseHeader("services_nfs_export.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$addressTransString = gettext("Address"); +$plusimgDescTransString = gettext("add to network list"); +$minusimgDescTransString = gettext("remove from network list"); +$currentnetTransString = gettext("Current networks"); +$networksTypehintTransString = gettext("Network that is authorised to access NFS shares"); + +$networkCount = count($freenas_config['nfs']['nfsnetwork']); +$generatedWANSubnet = gen_subnet($config['interfaces']['wan']['ipaddr'], + $config['interfaces']['wan']['subnet']); +$generatedLANSubnet = gen_subnet($config['interfaces']['lan']['ipaddr'], + $config['interfaces']['lan']['subnet']); + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function network_exists(myValue) { + for (i = 0; i < $('authnetworks').options.length; i++) { + if ($('authnetworks').options[i].value == myValue) { + return true; + } + } + + return false; +} +function selectnetel() { + for (i = 0; i < $('authnetworks').options.length; i++) { + $('authnetworks').options[i].selected = true; + } +} +function get_selected_listitems() { + var selected = new Array(); + + if (!$('authnetworks')) { return; } + + for (i = 0; i < $('authnetworks').options.length; i++) { + if ($('authnetworks').childNodes[i].selected == true) { + selected.push($('authnetworks').options[i]); + } + } + + return selected; +} + +function add_selnetwork(net, mask) { + var newOption = document.createElement("option"); + var newOptionText = document.createTextNode(net + '/' + mask); + var selectSize = $('authnetworks').size; + + if (!net || !mask) { return; } + + if (network_exists(net + '/' + mask)) { + alert('Element already exist in the network list'); + return; + } + + newOption.setAttribute('value', net + '/' + mask); + newOption.appendChild(newOptionText); + + /* add the option to the select element */ + $('authnetworks').appendChild(newOption); + $('authnetworks').setAttribute('size', '3'); + + /* clear values from HTML fields */ + if ($('network')) { $('network').value = ''; } + if ($('network_subnet')) { $('network_subnet').selectedIndex = 0; } +} + +function remove_selnetwork() { + var selectedItems = get_selected_listitems(); + + if (selectedItems.length <= 0) { + alert('No element selected!'); + return; + } + + for (i = 0; i < selectedItems.length; i++) { + $('authnetworks').removeChild(selectedItems[i]); + } +} + +function create_authnetworks_tr(selectElement) { + var newTR = document.createElement("tr"); + newTR.setAttribute('id', 'authNetworksTR'); + + var newImageTR = document.createElement("tr"); + newImageTR.setAttribute('id', 'authNetworksImageTR'); + + var descTD = document.createElement("td"); + descTD.setAttribute('align', 'left'); + descTD.setAttribute('valign', 'top'); + descTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;'); + + var selectTD = document.createElement("td"); + selectTD.setAttribute('align', 'left'); + selectTD.setAttribute('valign', 'middle'); + selectTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;'); + + var typehintTD = document.createElement("td"); + typehintTD.setAttribute('align', 'left'); + typehintTD.setAttribute('valign', 'middle'); + typehintTD.setAttribute('colspan', '2'); + typehintTD.setAttribute('style', 'padding-top: 10px; border-top: solid 1px grey;'); + + var blankTD = document.createElement("td"); + blankTD.setAttribute('align', 'left'); + blankTD.setAttribute('valign', 'top'); + + var imageTD = document.createElement("td"); + imageTD.setAttribute('align', 'left'); + imageTD.setAttribute('valign', 'middle'); + imageTD.setAttribute('style', 'vertical-align: middle;'); + imageTD.setAttribute('colspan', '3'); + + var newSpan = document.createElement("span"); + newSpan.setAttribute('style', 'padding-left: 5px; vertical-align: middle;'); + + var newTypehintSpan = document.createElement("span"); + newTypehintSpan.setAttribute('style', 'padding-left: 5px; vertical-align: middle;'); + + var newDescription = document.createTextNode('{$currentnetTransString}:'); + var newImgDescription = document.createTextNode('{$minusimgDescTransString}'); + var typehint = document.createTextNode('{$networksTypehintTransString}'); + + var newSelect = document.createElement("select"); + newSelect.setAttribute('name', 'authnetworks[]'); + newSelect.setAttribute('class', 'formselect'); + newSelect.setAttribute('id', 'authnetworks'); + newSelect.setAttribute('multiple', 'multiple'); + newSelect.setAttribute('size', '{$networkCount}'); + + /* divs are used to achieve proper alignement */ + newImageDiv = document.createElement("div"); + newImageDiv.setAttribute('style', 'float: left;'); + + newImageDescDiv = document.createElement("div"); + newImageDescDiv.setAttribute('style', 'padding-top: 1px;'); + + /* try to add each network to the select element */ + +EOD; + +if (isset($freenas_config['mounts']['mount'][$id]['nfs']['networks'])) { + foreach (explode(",", $freenas_config['mounts']['mount'][$id]['nfs']['networks']) as $networkel) { + list($netaddress, $netmask) = explode('/', $networkel); + $networkSanitized = htmlspecialchars($netaddress); + + $jscriptstr .= <<<EOD + var newOption = document.createElement("option"); + var newOptionText = document.createTextNode('{$networkSanitized}/{$netmask}'); + + newOption.setAttribute('value', '{$networkSanitized}/{$netmask}'); + newOption.appendChild(newOptionText); + + /* add the option to the select element */ + newSelect.appendChild(newOption); + +EOD; + } // end if +} // end foreach + +$jscriptstr .= <<<EOD + var newImage = document.createElement("img"); + newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_minus.png'); + newImage.setAttribute('alt', 'remove network'); + newImage.setAttribute('border', '0'); + newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;'); + newImage.setAttribute('onclick', 'remove_selnetwork();'); + + /* assemble everything */ + newTypehintSpan.appendChild(typehint); + + descTD.appendChild(newDescription); + selectElement != null ? selectTD.appendChild(selectElement) : selectTD.appendChild(newSelect); + typehintTD.appendChild(newTypehintSpan); + + newImageDiv.appendChild(newImage); + newImageDescDiv.appendChild(newImgDescription); + + imageTD.appendChild(newImageDiv); + imageTD.appendChild(newImageDescDiv); + + newTR.appendChild(descTD); + newTR.appendChild(selectTD); + newTR.appendChild(typehintTD); + + newImageTR.appendChild(blankTD); + newImageTR.appendChild(imageTD); + + $('networkopttab').appendChild(newTR); + $('networkopttab').appendChild(newImageTR); +} + +function create_network_tr() { + var newTR = document.createElement("tr"); + newTR.setAttribute('id', 'typeDetailsTR'); + + var descTD = document.createElement("td"); + descTD.setAttribute('align', 'left'); + descTD.setAttribute('valign', 'top'); + + var inputTD = document.createElement("td"); + inputTD.setAttribute('align', 'left'); + inputTD.setAttribute('valign', 'top'); + + var selectTD = document.createElement("td"); + selectTD.setAttribute('align', 'left'); + selectTD.setAttribute('valign', 'middle'); + + var imageTD = document.createElement("td"); + imageTD.setAttribute('align', 'left'); + imageTD.setAttribute('valign', 'middle'); + + var newDescription = document.createTextNode('{$addressTransString}:'); + var newImgDescription = document.createTextNode('{$plusimgDescTransString}'); + + var newInput = document.createElement("input"); + newInput.setAttribute('name', 'network'); + newInput.setAttribute('type', 'text'); + newInput.setAttribute('class', 'formfld host'); + newInput.setAttribute('id', 'network'); + newInput.setAttribute('size', '20'); + newInput.setAttribute('value', ''); + + var newSelect = document.createElement("select"); + newSelect.setAttribute('name', 'network_subnet'); + newSelect.setAttribute('class', 'formselect'); + newSelect.setAttribute('id', 'network_subnet'); + + var newImage = document.createElement("img"); + newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png'); + newImage.setAttribute('alt', 'add network'); + newImage.setAttribute('border', '0'); + newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;'); + newImage.setAttribute('onclick', 'add_selnetwork($("network").value, $("network_subnet").value);'); + + /* divs are used to achieve proper alignement */ + newImageDiv = document.createElement("div"); + newImageDiv.setAttribute('style', 'float: left;'); + + newImageDescDiv = document.createElement("div"); + newImageDescDiv.setAttribute('style', 'padding-top: 1px;'); + + /* add options to select */ + for (i = 31; i > 0; i--) { + var newOption = document.createElement("option"); + var newOptionText = document.createTextNode(i.toString()); + + newOption.setAttribute('value', i); + newOption.appendChild(newOptionText); + + /* add the option to the select element */ + newSelect.appendChild(newOption); + } + + /* assemble everything */ + descTD.appendChild(newDescription); + inputTD.appendChild(newInput); + selectTD.appendChild(newSelect); + + newImageDiv.appendChild(newImage); + newImageDescDiv.appendChild(newImgDescription); + + imageTD.appendChild(newImageDiv); + imageTD.appendChild(newImageDescDiv); + + newTR.appendChild(descTD); + newTR.appendChild(inputTD); + newTR.appendChild(selectTD); + newTR.appendChild(imageTD); + + $('networkopttab').appendChild(newTR); +} + +function create_wan_tr() { + var wanSubnet = '{$config['interfaces']['wan']['subnet']}'; + + var newTR = document.createElement("tr"); + newTR.setAttribute('id', 'typeDetailsTR'); + + var descTD = document.createElement("td"); + descTD.setAttribute('align', 'left'); + descTD.setAttribute('valign', 'top'); + + var nettextTD = document.createElement("td"); + nettextTD.setAttribute('align', 'left'); + nettextTD.setAttribute('valign', 'top'); + + var imageTD = document.createElement("td"); + imageTD.setAttribute('align', 'left'); + imageTD.setAttribute('valign', 'middle'); + imageTD.setAttribute('colspan', '2'); + + var newDescription = document.createTextNode('{$addressTransString}:'); + var newWanDescription = document.createTextNode('{$generatedWANSubnet}/' + wanSubnet); + + var newNetTextSpan = document.createElement("span"); + newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;'); + + var newImage = document.createElement("img"); + newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png'); + newImage.setAttribute('alt', 'add network'); + newImage.setAttribute('border', '0'); + newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;'); + newImage.setAttribute('onclick', 'add_selnetwork("{$generatedWANSubnet}", ' + wanSubnet + ');'); + + /* divs are used to achieve proper alignement */ + newImageDiv = document.createElement("div"); + newImageDiv.setAttribute('style', 'float: left;'); + + newImageDescDiv = document.createElement("div"); + newImageDescDiv.setAttribute('style', 'padding-top: 1px;'); + + var newImgDescription = document.createTextNode('{$plusimgDescTransString}'); + + /* assemble everything */ + newNetTextSpan.appendChild(newWanDescription); + + descTD.appendChild(newDescription); + nettextTD.appendChild(newNetTextSpan); + + newImageDiv.appendChild(newImage); + newImageDescDiv.appendChild(newImgDescription); + + imageTD.appendChild(newImageDiv); + imageTD.appendChild(newImageDescDiv); + + newTR.appendChild(descTD); + newTR.appendChild(nettextTD); + newTR.appendChild(imageTD); + + $('networkopttab').appendChild(newTR); +} + +function create_lan_tr() { + var lanSubnet = '{$config['interfaces']['lan']['subnet']}'; + + var newTR = document.createElement("tr"); + newTR.setAttribute('id', 'typeDetailsTR'); + + var descTD = document.createElement("td"); + descTD.setAttribute('align', 'left'); + descTD.setAttribute('valign', 'top'); + + var nettextTD = document.createElement("td"); + nettextTD.setAttribute('align', 'left'); + nettextTD.setAttribute('valign', 'top'); + + var imageTD = document.createElement("td"); + imageTD.setAttribute('align', 'left'); + imageTD.setAttribute('valign', 'middle'); + imageTD.setAttribute('colspan', '2'); + + var newDescription = document.createTextNode('{$addressTransString}:'); + var newLanDescription = document.createTextNode('{$generatedLANSubnet}/' + lanSubnet); + + var newNetTextSpan = document.createElement("span"); + newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;'); + + var newImage = document.createElement("img"); + newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png'); + newImage.setAttribute('alt', 'add network'); + newImage.setAttribute('border', '0'); + newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;'); + newImage.setAttribute('onclick', 'add_selnetwork("{$generatedLANSubnet}", ' + lanSubnet + ');'); + + /* divs are used to achieve proper alignement */ + newImageDiv = document.createElement("div"); + newImageDiv.setAttribute('style', 'float: left;'); + + newImageDescDiv = document.createElement("div"); + newImageDescDiv.setAttribute('style', 'padding-top: 1px;'); + + var newImgDescription = document.createTextNode('{$plusimgDescTransString}'); + + /* assemble everything */ + newNetTextSpan.appendChild(newLanDescription); + + descTD.appendChild(newDescription); + nettextTD.appendChild(newNetTextSpan); + + newImageDiv.appendChild(newImage); + newImageDescDiv.appendChild(newImgDescription); + + imageTD.appendChild(newImageDiv); + imageTD.appendChild(newImageDescDiv); + + newTR.appendChild(descTD); + newTR.appendChild(nettextTD); + newTR.appendChild(imageTD); + + $('networkopttab').appendChild(newTR); +} + +function get_optnetwork() { + var slashIndex= $('opt_iface_desc').firstChild.nodeValue.indexOf('/'); + var myNetwork = $('opt_iface_desc').firstChild.nodeValue.substring(0, slashIndex); + + return myNetwork; +} + +function get_optsubnet() { + var slashIndex= $('opt_iface_desc').firstChild.nodeValue.indexOf('/'); + var mySubnet = $('opt_iface_desc').firstChild.nodeValue.substring(slashIndex + 1, $('opt_iface_desc').firstChild.nodeValue.length); + + return mySubnet; +} + +function create_opt_tr() { + var newTR = document.createElement("tr"); + newTR.setAttribute('id', 'typeDetailsTR'); + + var descTD = document.createElement("td"); + descTD.setAttribute('align', 'left'); + descTD.setAttribute('valign', 'top'); + + var nettextTD = document.createElement("td"); + nettextTD.setAttribute('align', 'left'); + nettextTD.setAttribute('valign', 'top'); + + var imageTD = document.createElement("td"); + imageTD.setAttribute('align', 'left'); + imageTD.setAttribute('valign', 'middle'); + imageTD.setAttribute('colspan', '2'); + + var newDescription = document.createTextNode('{$addressTransString}:'); + var newImgDescription = document.createTextNode('{$plusimgDescTransString}'); + + var newImage = document.createElement("img"); + newImage.setAttribute('src', '/themes/{$g['theme']}/images/misc/bullet_toggle_plus.png'); + newImage.setAttribute('alt', 'add network'); + newImage.setAttribute('border', '0'); + newImage.setAttribute('style', 'margin-right: 5px; border: solid 1px silver; cursor: pointer;'); + newImage.setAttribute('onclick', 'add_selnetwork(get_optnetwork(), get_optsubnet());'); + + /* divs are used to achieve proper alignement */ + newImageDiv = document.createElement("div"); + newImageDiv.setAttribute('style', 'float: left;'); + + newImageDescDiv = document.createElement("div"); + newImageDescDiv.setAttribute('style', 'padding-top: 1px;'); + + /* add options to select */ + +EOD; + +for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { + $optSubnet = $config['interfaces']['opt' . $i]['subnet']; + $generatedOPTSubnet = gen_subnet($config['interfaces']['opt' . $i]['ipaddr'], + $config['interfaces']['opt' . $i]['subnet']); + + if (empty($optSubnet) || empty($generatedOPTSubnet)) { continue; } + + $jscriptstr .= <<<EOD + var selOptIndex = $('authnettype').selectedIndex; + var optNumber = $('authnettype').options[selOptIndex].value.substr(3, $('authnettype').options[selOptIndex].value.length); + var newOptDescription = null; + var newNetTextSpan = null; + + if (optNumber == {$i}) { + newOptDescription = document.createTextNode('{$generatedOPTSubnet}/{$optSubnet}'); + + newNetTextSpan = document.createElement("span"); + newNetTextSpan.setAttribute('id', 'opt_iface_desc'); + newNetTextSpan.setAttribute('style', 'font-weight: bold; font-style: italic; vertical-align: middle;'); + } + +EOD; +} + +$jscriptstr .= <<<EOD + /* assemble everything */ + if (newNetTextSpan) + newNetTextSpan.appendChild(newOptDescription); + + descTD.appendChild(newDescription); + if (newNetTextSpan) + nettextTD.appendChild(newNetTextSpan); + + newImageDiv.appendChild(newImage); + newImageDescDiv.appendChild(newImgDescription); + + imageTD.appendChild(newImageDiv); + imageTD.appendChild(newImageDescDiv); + + newTR.appendChild(descTD); + newTR.appendChild(nettextTD); + newTR.appendChild(imageTD); + + $('networkopttab').appendChild(newTR); +} + +function authnet_change() { + var tmpElement = $('authnetworks'); + + if ($('typeDetailsTR')) { $('networkopttab').removeChild($('typeDetailsTR')); } + if ($('authNetworksTR')) { $('networkopttab').removeChild($('authNetworksTR')); } + if ($('authNetworksImageTR')) { $('networkopttab').removeChild($('authNetworksImageTR')); } + + switch ($('authnettype').selectedIndex) { + case 0: + /* Network */ + create_network_tr(); + break; + case 1: + /* WAN subnet */ + create_wan_tr(); + break; + case 2: + /* LAN subnet */ + create_lan_tr(); + break; + +EOD; + +for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { + $case_count = 2 + $i; + + $jscriptstr .= <<<EOD + case {$case_count}: + /* OPT subnet */ + create_opt_tr(); + break; + +EOD; + +} // end for + +$jscriptstr .= <<<EOD + } // end switch + + create_authnetworks_tr(tmpElement); +} // end function authnet_change +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="disks_mount_edit.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" align="left" valign="middle" class="listtopic" colspan="2"><?=gettext("Export Options");?></td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Export Name"); ?></td> + <td width="78%" class="vtable"> + <input type="text" class="formfld file" size="30" value="/mnt/<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['sharename']);?>" readonly="readonly" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Description"); ?></td> + <td width="78%" class="vtable"> + <input type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['desc']);?>" readonly="readonly" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("map all user to root");?></td> + <td width="78%" class="vtable"> + <select name="mapall" class="formselect" id="mapall"> + <?php + $types = explode(",", "Yes,No"); + $vals = explode(" ", "yes no"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['mapall']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + <br /> + <?= gettext("All users will have the root privilege."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Authorised network");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <table border="0" cellspacing="0" cellpadding="4" id="networkopttab"> + <tr> + <td align="left" valign="middle"><?=gettext("Type");?>:</td> + <td align="left" valign="middle" colspan="4"> + <select name="authnettype" id="authnettype" class="formselect" onchange="authnet_change();"> + <option value="network"> + <?=gettext("Network")?> + </option> + <option value="wan"> + <?=gettext("WAN subnet");?> + </option> + <option value="lan"> + <?=gettext("LAN subnet");?> + </option> + <?php + for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): + ?> + <option value="opt<?=$i;?>"> + <?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> + <?=gettext("subnet");?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onmousedown="selectnetel();" onkeydown="selectnetel();" /> + <?php if(isset($id)): ?> + <input id="id" name="id" type="hidden" value="<?=$id;?>" /> + <?php endif; ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <span class="red"> + <strong><?= gettext("NOTE"); ?>:</strong> + </span> + <br /> + <ul> + <li> + <span class="vexpl"> + <?= gettext("The name of each exported directory is: /mnt/sharename"); ?> + </span> + </li> + <li> + <span class="vexpl"> + <?= gettext("Try adding networks to the 'current networks' list to authorize each particular network."); ?> + </span> + </li> + <li> + <span class="vexpl"> + <?= gettext("Use ctrl-click (or command-click on the Mac) to select and de-select elements from the 'current networks' list."); ?> + </span> + </li> + </ul> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +authnet_change(); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_rsyncd.php b/config/freenas/www/services_rsyncd.php new file mode 100644 index 00000000..a31aa229 --- /dev/null +++ b/config/freenas/www/services_rsyncd.php @@ -0,0 +1,277 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_rsyncd.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("RSYNCD"), + gettext("Server")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +/* TODO: use pfSense users/groups. */ +if (!is_array($freenas_config['system']['user'])) + $freenas_config['system']['user'] = array(); + +users_sort(); + +$a_user = &$freenas_config['system']['user']; + +if (!is_array($freenas_config['rsync'])) +{ + $freenas_config['rsync'] = array(); +} + +$pconfig['readonly'] = $freenas_config['rsyncd']['readonly']; +$pconfig['port'] = $freenas_config['rsyncd']['port']; +$pconfig['motd'] = $freenas_config['rsyncd']['motd']; +$pconfig['maxcon'] = $freenas_config['rsyncd']['maxcon']; +$pconfig['rsyncd_user'] = $freenas_config['rsyncd']['rsyncd_user']; +$pconfig['enable'] = isset($freenas_config['rsyncd']['enable']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_format); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']) + { + $reqdfields = array_merge($reqdfields, explode(" ", "readonly port")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Readonly,Port")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['enable']) { + if (!is_port($_POST['port'])) + $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."), + "field" => "port"); + else if (!is_numericint($_POST['maxcon'])) + $error_bucket[] = array("error" => gettext("The value provided by the maximum connections field is not a number"), + "field" => "maxcon"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['rsyncd']['readonly'] = $_POST['readonly']; + $freenas_config['rsyncd']['port'] = $_POST['port']; + $freenas_config['rsyncd']['motd'] = $_POST['motd']; + $freenas_config['rsyncd']['maxcon'] = $_POST['maxcon']; + $freenas_config['rsyncd']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['rsyncd']['rsyncd_user'] = $_POST['rsyncd_user']; + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + /* nuke the cache file */ + config_lock(); + services_rsyncd_configure(); + services_zeroconf_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.readonly.disabled = endis; + document.iform.port.disabled = endis; + document.iform.motd.disabled = endis; + document.iform.maxcon.disabled = endis; + document.iform.rsyncd_user.disabled = endis; + /* adjust colors */ + document.iform.readonly.style.backgroundColor = color; + document.iform.port.style.backgroundColor = color; + document.iform.motd.style.backgroundColor = color; + document.iform.maxcon.style.backgroundColor = color; + document.iform.rsyncd_user.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> + <?php + $tab_array = array(); + $tab_array[0] = array(gettext("Server"), true, "services_rsyncd.php"); + $tab_array[1] = array(gettext("Client"), false, "services_rsyncd_client.php"); + $tab_array[2] = array(gettext("Local"), false, "services_rsyncd_local.php"); + display_top_tabs($tab_array); + ?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form id="iform" name="iform" action="services_rsyncd.php" method="post"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Rsync Daemon");?></span> + <span style="vertical-align: middle; position: relative; left: 81%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Read only"); ?></td> + <td width="78%" class="vtable"> + <select name="readonly" class="formselect" id="readonly"> + <?php + $types = explode(",", "Yes,No"); + $vals = explode(" ", "yes no"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['readonly']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Map to user"); ?></td> + <td width="78%" class="vtable"> + <select name="rsyncd_user" class="formselect" id="rsyncd_user"> + <option value="ftp"<?php if ($pconfig['rsyncd_user'] == "ftp") echo "selected";?>> + <?php echo htmlspecialchars("guest"); ?> + <?php foreach ($a_user as $user): ?> + <option value="<?=$user['name'];?>"<?php if ($user['name'] == $pconfig['rsyncd_user']) echo "selected";?>> + <?php echo htmlspecialchars($user['name']); ?> + </option> + <?php endforeach; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("TCP port"); ?></td> + <td width="78%" class="vtable"> + <input name="port" type="text" class="formfld unknown" id="port" size="20" value="<?=htmlspecialchars($pconfig['port']);?>" /> + <br /><?= gettext("Alternate TCP port."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Maximum connections"); ?></td> + <td width="78%" class="vtable"> + <input name="maxcon" type="text" class="formfld unknown" id="maxcon" size="20" value="<?=htmlspecialchars($pconfig['maxcon']);?>" /> + <br /><?= gettext("Maximum number of simultaneous connections. Default is 0 (unlimited)"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?= gettext("MOTD"); ?></td> + <td width="78%" class="vtable"> + <textarea name="motd" cols="65" rows="7" id="motd" class="formpre"><?=htmlspecialchars($pconfig['motd']);?></textarea> + <br /> + <?= gettext("message of the day");?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_rsyncd_client.php b/config/freenas/www/services_rsyncd_client.php new file mode 100644 index 00000000..efb0e870 --- /dev/null +++ b/config/freenas/www/services_rsyncd_client.php @@ -0,0 +1,585 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_rsyncd_client.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("RSYNCD"), + gettext("Client")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['rsyncclient'])) +{ + $freenas_config['rsyncclient'] = array(); +} + +$a_months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); +$a_weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); +$a_mount = array(); + +$pconfig['readonly'] = $freenas_config['rsyncd']['readonly']; +$pconfig['port'] = $freenas_config['rsyncd']['port']; +$pconfig['motd'] = $freenas_config['rsyncd']['motd']; +$pconfig['maxcon'] = $freenas_config['rsyncd']['maxcon']; +$pconfig['rsyncd_user'] = $freenas_config['rsyncd']['rsyncd_user']; +$pconfig['enable'] = isset($freenas_config['rsyncd']['enable']); + +if (!is_array($freenas_config['mounts']['mount'])) { + $nodisk_errors[] = gettext("You must configure mount point first."); +} else { + if (! empty($_POST)) + { + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + unset($do_format); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']){ + $reqdfields = array_merge($reqdfields, explode(" ", "rsyncserverip sharetosync")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Rsyncserverip,Sharetosync")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['enable']) { + if (!is_port($_POST['port'])) + $error_bucket[] = array("error" => gettext("The TCP port must be a valid port number."), + "field" => "port"); + else if (!is_numericint($_POST['maxcon'])) + $error_bucket[] = array("error" => gettext("The value provided by the maximum connections field is not a number"), + "field" => "maxcon"); + } + + if (!is_array($freenas_config['mounts']['mount'])) { + $error_bucket[] = array("error" => gettext("You must configure mount point first."), + "field" => "none"); + } + + if ($_POST['enable'] && !is_ipaddr($_POST['rsyncserverip'])) { + $error_bucket[] = array("error" => gettext("A valid IP address must be specified."), + "field" => "rsyncserverip"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['rsyncclient']['opt_delete'] = $_POST['opt_delete'] ? true : false;; + $freenas_config['rsyncclient']['rsyncserverip'] = $_POST['rsyncserverip']; + $freenas_config['rsyncclient']['minute'] = $_POST['minutes']; + $freenas_config['rsyncclient']['hour'] = $_POST['hours']; + $freenas_config['rsyncclient']['day'] = $_POST['days']; + $freenas_config['rsyncclient']['month'] = $_POST['months']; + $freenas_config['rsyncclient']['weekday'] = $_POST['weekdays']; + $freenas_config['rsyncclient']['rsyncshare'] = $_POST['rsyncshare']; + $freenas_config['rsyncclient']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['rsyncclient']['sharetosync'] = $_POST['sharetosync']; + $freenas_config['rsyncclient']['all_mins'] = $_POST['all_mins']; + $freenas_config['rsyncclient']['all_hours'] = $_POST['all_hours']; + $freenas_config['rsyncclient']['all_days'] = $_POST['all_days']; + $freenas_config['rsyncclient']['all_months'] = $_POST['all_months']; + $freenas_config['rsyncclient']['all_weekdays'] = $_POST['all_weekdays']; + + write_config(); + + $retval = 0; + + if (!file_exists($d_sysrebootreqd_path)){ + /* nuke the cache file */ + config_lock(); + services_rsyncclient_configure(); + services_cron_configure(); + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + } + } + + mount_sort(); + $a_mount = &$freenas_config['mounts']['mount']; + + $pconfig['opt_delete'] = isset($freenas_config['rsyncclient']['opt_delete']); + $pconfig['enable'] = isset($freenas_config['rsyncclient']['enable']); + $pconfig['rsyncserverip'] = $freenas_config['rsyncclient']['rsyncserverip']; + $pconfig['rsyncshare'] = $freenas_config['rsyncclient']['rsyncshare']; + $pconfig['minute'] = $freenas_config['rsyncclient']['minute']; + $pconfig['hour'] = $freenas_config['rsyncclient']['hour']; + $pconfig['day'] = $freenas_config['rsyncclient']['day']; + $pconfig['month'] = $freenas_config['rsyncclient']['month']; + $pconfig['weekday'] = $freenas_config['rsyncclient']['weekday']; + $pconfig['sharetosync'] = $freenas_config['rsyncclient']['sharetosync']; + $pconfig['all_mins'] = $freenas_config['rsyncclient']['all_mins']; + $pconfig['all_hours'] = $freenas_config['rsyncclient']['all_hours']; + $pconfig['all_days'] = $freenas_config['rsyncclient']['all_days']; + $pconfig['all_months'] = $freenas_config['rsyncclient']['all_months']; + $pconfig['all_weekdays'] = $freenas_config['rsyncclient']['all_weekdays']; + + if ($pconfig['all_mins'] == 1){ + $all_mins_all = " checked"; + } else { + $all_mins_selected = " checked"; + } + + if ($pconfig['all_hours'] == 1){ + $all_hours_all = " checked"; + } else { + $all_hours_selected = " checked"; + } + + if ($pconfig['all_days'] == 1){ + $all_days_all = " checked"; + } else { + $all_days_selected = " checked"; + } + + if ($pconfig['all_months'] == 1){ + $all_months_all = " checked"; + } else { + $all_months_selected = " checked"; + } + + if ($pconfig['all_weekdays'] == 1){ + $all_weekdays_all = " checked"; + } else { + $all_weekdays_selected = " checked"; + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + +EOD; + +$i = 0; + +if (is_array($a_mount)) { + foreach ($a_mount as $mountv) { + $jscriptstr .= " document.iform.share_" . $i . ".disabled = endis;\n"; + $i++; + } +} + +/* Note: In contrast to FreeNAS we are only using + * three minutes and one hours field(s) + */ +$jscriptstr .= <<<EOD + + document.iform.rsyncserverip.disabled = endis; + document.iform.minutes1.disabled = endis; + document.iform.minutes2.disabled = endis; + document.iform.minutes3.disabled = endis; + document.iform.hours1.disabled = endis; + /* document.iform.hours2.disabled = endis; */ + document.iform.days1.disabled = endis; + document.iform.days2.disabled = endis; + /* document.iform.days3.disabled = endis; */ + document.iform.months.disabled = endis; + document.iform.weekdays.disabled = endis; + document.iform.all_mins1.disabled = endis; + document.iform.all_mins2.disabled = endis; + document.iform.all_hours1.disabled = endis; + document.iform.all_hours2.disabled = endis; + document.iform.all_days1.disabled = endis; + document.iform.all_days2.disabled = endis; + document.iform.all_months1.disabled = endis; + document.iform.all_months2.disabled = endis; + document.iform.all_weekdays1.disabled = endis; + document.iform.all_weekdays2.disabled = endis; + document.iform.opt_delete.disabled = endis; + /* color adjustments */ + document.iform.rsyncserverip.style.backgroundColor = color; + document.iform.minutes1.style.backgroundColor = color; + document.iform.minutes2.style.backgroundColor = color; + document.iform.minutes3.style.backgroundColor = color; + document.iform.hours1.style.backgroundColor = color; + /* document.iform.hours2.style.backgroundColor = color; */ + document.iform.days1.style.backgroundColor = color; + document.iform.days2.style.backgroundColor = color; + /* document.iform.days3.style.backgroundColor = color; */ + document.iform.months.style.backgroundColor = color; + document.iform.weekdays.style.backgroundColor = color; + document.iform.all_mins1.style.backgroundColor = color; + document.iform.all_mins2.style.backgroundColor = color; + document.iform.all_hours1.style.backgroundColor = color; + document.iform.all_hours2.style.backgroundColor = color; + document.iform.all_days1.style.backgroundColor = color; + document.iform.all_days2.style.backgroundColor = color; + document.iform.all_months1.style.backgroundColor = color; + document.iform.all_months2.style.backgroundColor = color; + document.iform.all_weekdays1.style.backgroundColor = color; + document.iform.all_weekdays2.style.backgroundColor = color; + document.iform.opt_delete.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Server"), false, "services_rsyncd.php"); + $tab_array[1] = array(gettext("Client"), true, "services_rsyncd_client.php"); + $tab_array[2] = array(gettext("Local"), false, "services_rsyncd_local.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form id="iform" name="iform" action="services_rsyncd_client.php" method="post"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Rsync Client Synchronization");?></span> + <span style="vertical-align: middle; position: relative; left: 70%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Remote RSYNC Server"); ?></td> + <td width="84%" class="vtable"> + <input name="rsyncserverip" id="rsyncserverip" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['rsyncserverip']);?>" /> + <br /> + <?= gettext("IP address of remote RSYNC server"); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("RSYNC Options"); ?></td> + <td width="84%" class="vtable"> + <input name="opt_delete" id="opt_delete" type="checkbox" value="yes" <?php if ($pconfig['opt_delete']) echo "checked=\"checked\""; ?> /> + <?= gettext("Delete files that don't exist on sender."); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Shares to be synchronized"); ?></td> + <td width="84%" class="vtable"> + <?php + if (is_array($freenas_config['mounts']['mount'])) { + $i=0; + foreach ($a_mount as $mountv) { + echo "<input name=\"sharetosync[]\" id=\"share_" . $i . "\" type=\"checkbox\" value=\"" . $mountv['sharename'] . "\""; + if ($mountv['sharename'] == $pconfig['sharetosync']) + echo " checked=\"checked\""; + echo" />"; + echo $mountv['sharename'] . " (" . $mountv['desc'] . ")<br />\n"; + $i++; + } + } + else + echo "You must configure mount point before!"; + ?> + <br /> + <?= gettext("This same local share must be present on the Remote Server."); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Synchronization Time"); ?></td> + <td width="84%" class="vtable"> + <table width="100%" border="1" cellpadding="4" cellspacing="0"> + <tr> + <td align="left" valign="top" class="listtopic"><?= gettext("minutes"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("hours"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("days"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("months"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("week days"); ?></td> + </tr> + <tr> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_min_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_mins" id="all_mins1" value="1"<?php echo $all_mins_all;?> /> + <label for="all_mins1">All</label><br /> + <input type="radio" name="all_mins" id="all_mins2" value="0"<?php echo $all_mins_selected;?> /> + <label for="all_mins2">Selected ...</label> + </div> + <div id="all_min_select" style="vertical-align: top;"> + <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes1" style="vertical-align: top;"> + <?php + $i = 0; + while ($i <= 23){ + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes2" style="vertical-align: top;"> + <?php + $i = 24; + while ($i <= 47) { + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple="multible" class="formselect" size="12" name="minutes[]" id="minutes3" style="vertical-align: top;"> + <?php + $i = 48; + while ($i <= 59) { + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_hours_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_hours" id="all_hours1" value="1"<?php echo $all_hours_all;?> /> + <label for="all_hours1">All</label><br /> + <input type="radio" name="all_hours" id="all_hours2" value="0"<?php echo $all_hours_selected;?> /> + <label for="all_hours2">Selected ...</label> + </div> + <div id="all_hours_select" style="vertical-align: top;"> + <select multiple size="24" name="hours[]" id="hours1" style="vertical-align: top;"> + <?php + $i = 0; + while ($i <= 23) { + if (isset($pconfig['hour'])) { + if (in_array($i, $pconfig['hour'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_days_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_days" id="all_days1" value="1" <?php echo $all_days_all;?> /> + <label for="all_days1">All</label><br /> + <input type="radio" name="all_days" id="all_days2" value="0"<?php echo $all_days_selected;?> /> + <label for="all_days2">Selected ...</label> + </div> + <div id="all_days_select" style="vertical-align: top;"> + <select multiple size="24" name="days[]" id="days1" style="vertical-align: top;"> + <?php + $i = 1; + while ($i <= 24) { + if (isset($pconfig['day'])) { + if (in_array($i, $pconfig['day'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple size="7" name="days[]" id="days2" style="vertical-align: top;"> + <?php + $i = 25; + while ($i <= 31) { + if (isset($pconfig['day'])) { + if (in_array($i, $pconfig['day'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell"> + <div id="all_months_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_months" id="all_months1" value="1"<?php echo $all_months_all;?> /> + <label for="all_months1">All</label><br /> + <input type="radio" name="all_months" id="all_months2" value="0"<?php echo $all_months_selected;?> /> + <label for="all_months2">Selected ...</label> + </div> + <div id="all_months_select" style="vertical-align: top;"> + <select multiple size="12" name="months[]" id="months" style="vertical-align: top;"> + <?php + $i=1; + foreach ($a_months as $monthv) { + if (isset($pconfig['month'])) { + if (in_array($i, $pconfig['month'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $monthv . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell"> + <div id="all_weekdays_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_weekdays" id="all_weekdays1" value="1"<?php echo $all_weekdays_all;?> /> + <label for="all_weekdays1">All</label><br /> + <input type="radio" name="all_weekdays" id="all_weekdays2" value="0"<?php echo $all_weekdays_selected;?> /> + <label for="all_weekdays2">Selected ...</label> + </div> + <div id="all_weekdays_select" style="vertical-align: top;"> + <select multiple size="7" name="weekdays[]" id="weekdays" style="vertical-align: top;"> + <?php + $i=0; + foreach ($a_weekdays as $weekdayv) { + if (isset($pconfig['weekday'])){ + if (in_array($i, $pconfig['weekday'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $weekdayv . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + </tr> + <tr> + <td align="left" valign="top" class="vncell" colspan="5"> + <?= gettext("Note: Ctrl-click (or command-click on the Mac) to select and de-select minutes, hours, days and months."); ?> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td width="16%" valign="top"> </td> + <td width="84%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_rsyncd_local.php b/config/freenas/www/services_rsyncd_local.php new file mode 100644 index 00000000..df29961a --- /dev/null +++ b/config/freenas/www/services_rsyncd_local.php @@ -0,0 +1,579 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_rsyncd_local.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("RSYNCD"), + gettext("Local")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['rsync_local'])) +{ + $freenas_config['rsync_local'] = array(); +} + +$a_months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); +$a_weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); + +$pconfig['readonly'] = $freenas_config['rsyncd']['readonly']; +$pconfig['port'] = $freenas_config['rsyncd']['port']; +$pconfig['motd'] = $freenas_config['rsyncd']['motd']; +$pconfig['maxcon'] = $freenas_config['rsyncd']['maxcon']; +$pconfig['rsyncd_user'] = $freenas_config['rsyncd']['rsyncd_user']; +$pconfig['enable'] = isset($freenas_config['rsyncd']['enable']); + +if (!is_array($freenas_config['mounts']['mount'])) { + $nodisk_errors[] = gettext("You must configure mount point first."); +} else { + if (! empty($_POST)) + { + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']){ + $reqdfields = array_merge($reqdfields, explode(" ", "source destination")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Source,Destination")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['enable'] && (strcmp($_POST['source'],$_POST['destination'])==0)) { + $error_bucket[] = array("error" => gettext("You can't have the same mount point for source and destination!"), + "field" => "source"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['rsync_local']['opt_delete'] = $_POST['opt_delete'] ? true : false;; + $freenas_config['rsync_local']['minute'] = $_POST['minutes']; + $freenas_config['rsync_local']['hour'] = $_POST['hours']; + $freenas_config['rsync_local']['day'] = $_POST['days']; + $freenas_config['rsync_local']['month'] = $_POST['months']; + $freenas_config['rsync_local']['weekday'] = $_POST['weekdays']; + $freenas_config['rsync_local']['source'] = $_POST['source']; + $freenas_config['rsync_local']['destination'] = $_POST['destination']; + $freenas_config['rsync_local']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['rsync_local']['sharetosync'] = $_POST['sharetosync']; + $freenas_config['rsync_local']['all_mins'] = $_POST['all_mins']; + $freenas_config['rsync_local']['all_hours'] = $_POST['all_hours']; + $freenas_config['rsync_local']['all_days'] = $_POST['all_days']; + $freenas_config['rsync_local']['all_months'] = $_POST['all_months']; + $freenas_config['rsync_local']['all_weekdays'] = $_POST['all_weekdays']; + + write_config(); + + $retval = 0; + + if (!file_exists($d_sysrebootreqd_path)){ + /* nuke the cache file */ + config_lock(); + services_rsync_local_configure(); + services_cron_configure(); + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + } + } + + mount_sort(); + $a_mount = &$freenas_config['mounts']['mount']; + + $pconfig['opt_delete'] = isset($freenas_config['rsync_local']['opt_delete']); + $pconfig['enable'] = isset($freenas_config['rsync_local']['enable']); + $pconfig['source'] = $freenas_config['rsync_local']['source']; + $pconfig['destination'] = $freenas_config['rsync_local']['destination']; + $pconfig['minute'] = $freenas_config['rsync_local']['minute']; + $pconfig['hour'] = $freenas_config['rsync_local']['hour']; + $pconfig['day'] = $freenas_config['rsync_local']['day']; + $pconfig['month'] = $freenas_config['rsync_local']['month']; + $pconfig['weekday'] = $freenas_config['rsync_local']['weekday']; + $pconfig['sharetosync'] = $freenas_config['rsync_local']['sharetosync']; + $pconfig['all_mins'] = $freenas_config['rsync_local']['all_mins']; + $pconfig['all_hours'] = $freenas_config['rsync_local']['all_hours']; + $pconfig['all_days'] = $freenas_config['rsync_local']['all_days']; + $pconfig['all_months'] = $freenas_config['rsync_local']['all_months']; + $pconfig['all_weekdays'] = $freenas_config['rsync_local']['all_weekdays']; + + if ($pconfig['all_mins'] == 1){ + $all_mins_all = " checked"; + } else { + $all_mins_selected = " checked"; + } + + if ($pconfig['all_hours'] == 1){ + $all_hours_all = " checked"; + } else { + $all_hours_selected = " checked"; + } + + if ($pconfig['all_days'] == 1){ + $all_days_all = " checked"; + } else { + $all_days_selected = " checked"; + } + + if ($pconfig['all_months'] == 1){ + $all_months_all = " checked"; + } else { + $all_months_selected = " checked"; + } + + if ($pconfig['all_weekdays'] == 1){ + $all_weekdays_all = " checked"; + } else { + $all_weekdays_selected = " checked"; + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + +EOD; + +/* Note: In contrast to FreeNAS we are only using + * three minutes and one hours field(s) + */ +$jscriptstr .= <<<EOD + + document.iform.source.disabled = endis; + document.iform.destination.disabled = endis; + document.iform.minutes1.disabled = endis; + document.iform.minutes2.disabled = endis; + document.iform.minutes3.disabled = endis; + document.iform.hours1.disabled = endis; + /* document.iform.hours2.disabled = endis; */ + document.iform.days1.disabled = endis; + document.iform.days2.disabled = endis; + /* document.iform.days3.disabled = endis; */ + document.iform.months.disabled = endis; + document.iform.weekdays.disabled = endis; + document.iform.all_mins1.disabled = endis; + document.iform.all_mins2.disabled = endis; + document.iform.all_hours1.disabled = endis; + document.iform.all_hours2.disabled = endis; + document.iform.all_days1.disabled = endis; + document.iform.all_days2.disabled = endis; + document.iform.all_months1.disabled = endis; + document.iform.all_months2.disabled = endis; + document.iform.all_weekdays1.disabled = endis; + document.iform.all_weekdays2.disabled = endis; + document.iform.opt_delete.disabled = endis; + /* color adjustments */ + document.iform.source.style.backgroundColor = color; + document.iform.destination.style.backgroundColor = color; + document.iform.minutes1.style.backgroundColor = color; + document.iform.minutes2.style.backgroundColor = color; + document.iform.minutes3.style.backgroundColor = color; + document.iform.hours1.style.backgroundColor = color; + /* document.iform.hours2.style.backgroundColor = color; */ + document.iform.days1.style.backgroundColor = color; + document.iform.days2.style.backgroundColor = color; + /* document.iform.days3.style.backgroundColor = color; */ + document.iform.months.style.backgroundColor = color; + document.iform.weekdays.style.backgroundColor = color; + document.iform.all_mins1.style.backgroundColor = color; + document.iform.all_mins2.style.backgroundColor = color; + document.iform.all_hours1.style.backgroundColor = color; + document.iform.all_hours2.style.backgroundColor = color; + document.iform.all_days1.style.backgroundColor = color; + document.iform.all_days2.style.backgroundColor = color; + document.iform.all_months1.style.backgroundColor = color; + document.iform.all_months2.style.backgroundColor = color; + document.iform.all_weekdays1.style.backgroundColor = color; + document.iform.all_weekdays2.style.backgroundColor = color; + document.iform.opt_delete.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Server"), false, "services_rsyncd.php"); + $tab_array[1] = array(gettext("Client"), false, "services_rsyncd_client.php"); + $tab_array[2] = array(gettext("Local"), true, "services_rsyncd_local.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <form id="iform" name="iform" action="services_rsyncd_local.php" method="post"> + <table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Rsync Client Synchronization");?></span> + <span style="vertical-align: middle; position: relative; left: 70%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Source"); ?></td> + <td width="84%" class="vtable"> + <select name="source" class="formselect" id="source"> + <?php + if (is_array($freenas_config['mounts']['mount'])) { + foreach ($a_mount as $mountv) { + echo "<option value=\"{$mountv['sharename']}\""; + if (strcmp($mountv['sharename'],$pconfig['source']) == 0) + echo " selected"; + echo">"; + echo htmlspecialchars($mountv['sharename']); + echo "</option>"; + } + } + else + echo gettext("You must configure mount point first."); + ?> + </select> + <br /> + <?= gettext("Source Mount Point."); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Destination"); ?></td> + <td width="84%" class="vtable"> + <select name="destination" class="formselect" id="destination"> + <?php + if (is_array($freenas_config['mounts']['mount'])) { + foreach ($a_mount as $mountv) { + echo "<option value=\"{$mountv['sharename']}\""; + if (strcmp($mountv['sharename'],$pconfig['destination']) == 0) + echo " selected"; + echo">"; + echo htmlspecialchars($mountv['sharename']); + echo "</option>"; + } + } + else + echo gettext("You must configure mount point first."); + ?> + </select> + <br /> + <?= gettext("Destination Mount Point."); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("RSYNC Options"); ?></td> + <td width="84%" class="vtable"> + <input name="opt_delete" id="opt_delete" type="checkbox" value="yes" <?php if ($pconfig['opt_delete']) echo "checked=\"checked\""; ?> /> + <?= gettext("Delete files that don't exist on sender."); ?> + </td> + </tr> + <tr> + <td width="16%" valign="top" class="vncellreq"><?= gettext("Synchronization Time"); ?></td> + <td width="84%" class="vtable"> + <table width="100%" border="1" cellpadding="4" cellspacing="0"> + <tr> + <td align="left" valign="top" class="listtopic"><?= gettext("minutes"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("hours"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("days"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("months"); ?></td> + <td align="left" valign="top" class="listtopic"><?= gettext("week days"); ?></td> + </tr> + <tr> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_min_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_mins" id="all_mins1" value="1"<?php echo $all_mins_all;?> /> + <label for="all_mins1">All</label><br /> + <input type="radio" name="all_mins" id="all_mins2" value="0"<?php echo $all_mins_selected;?> /> + <label for="all_mins2">Selected ...</label> + </div> + <div id="all_min_select" style="vertical-align: top;"> + <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes1" style="vertical-align: top;"> + <?php + $i = 0; + while ($i <= 23){ + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple="multible" class="formselect" size="24" name="minutes[]" id="minutes2" style="vertical-align: top;"> + <?php + $i = 24; + while ($i <= 47) { + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple="multible" class="formselect" size="12" name="minutes[]" id="minutes3" style="vertical-align: top;"> + <?php + $i = 48; + while ($i <= 59) { + if (isset($pconfig['minute'])) { + if (in_array($i, $pconfig['minute'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_hours_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_hours" id="all_hours1" value="1"<?php echo $all_hours_all;?> /> + <label for="all_hours1">All</label><br /> + <input type="radio" name="all_hours" id="all_hours2" value="0"<?php echo $all_hours_selected;?> /> + <label for="all_hours2">Selected ...</label> + </div> + <div id="all_hours_select" style="vertical-align: top;"> + <select multiple size="24" name="hours[]" id="hours1" style="vertical-align: top;"> + <?php + $i = 0; + while ($i <= 23) { + if (isset($pconfig['hour'])) { + if (in_array($i, $pconfig['hour'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell" nowrap="nowrap"> + <div id="all_days_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_days" id="all_days1" value="1" <?php echo $all_days_all;?> /> + <label for="all_days1">All</label><br /> + <input type="radio" name="all_days" id="all_days2" value="0"<?php echo $all_days_selected;?> /> + <label for="all_days2">Selected ...</label> + </div> + <div id="all_days_select" style="vertical-align: top;"> + <select multiple size="24" name="days[]" id="days1" style="vertical-align: top;"> + <?php + $i = 1; + while ($i <= 24) { + if (isset($pconfig['day'])) { + if (in_array($i, $pconfig['day'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + <select multiple size="7" name="days[]" id="days2" style="vertical-align: top;"> + <?php + $i = 25; + while ($i <= 31) { + if (isset($pconfig['day'])) { + if (in_array($i, $pconfig['day'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $i . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell"> + <div id="all_months_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_months" id="all_months1" value="1"<?php echo $all_months_all;?> /> + <label for="all_months1">All</label><br /> + <input type="radio" name="all_months" id="all_months2" value="0"<?php echo $all_months_selected;?> /> + <label for="all_months2">Selected ...</label> + </div> + <div id="all_months_select" style="vertical-align: top;"> + <select multiple size="12" name="months[]" id="months" style="vertical-align: top;"> + <?php + $i=1; + foreach ($a_months as $monthv) { + if (isset($pconfig['month'])) { + if (in_array($i, $pconfig['month'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $monthv . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + <td align="left" valign="top" class="vncell"> + <div id="all_weekdays_rdbtns" style="padding-bottom: 10px;" > + <input type="radio" name="all_weekdays" id="all_weekdays1" value="1"<?php echo $all_weekdays_all;?> /> + <label for="all_weekdays1">All</label><br /> + <input type="radio" name="all_weekdays" id="all_weekdays2" value="0"<?php echo $all_weekdays_selected;?> /> + <label for="all_weekdays2">Selected ...</label> + </div> + <div id="all_weekdays_select" style="vertical-align: top;"> + <select multiple size="7" name="weekdays[]" id="weekdays" style="vertical-align: top;"> + <?php + $i=0; + foreach ($a_weekdays as $weekdayv) { + if (isset($pconfig['weekday'])){ + if (in_array($i, $pconfig['weekday'])) { + $is_selected = " selected"; + } else { + $is_selected = ""; + } + } + + echo "<option value=\"" . $i . "\"" . $is_selected . ">" . $weekdayv . "\n"; + $i++; + } + ?> + </select> + </div> + </td> + </tr> + <tr> + <td align="left" valign="top" class="vncell" colspan="5"> + <?= gettext("Note: Ctrl-click (or command-click on the Mac) to select and de-select minutes, hours, days and months."); ?> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td width="16%" valign="top"> </td> + <td width="84%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </form> + </div> + </td> + </tr> +</table> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_samba.php b/config/freenas/www/services_samba.php new file mode 100644 index 00000000..afd90a08 --- /dev/null +++ b/config/freenas/www/services_samba.php @@ -0,0 +1,431 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_samba.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("CIFS")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['samba'])) +{ + $freenas_config['samba'] = array(); +} + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +$pconfig['netbiosname'] = $freenas_config['samba']['netbiosname']; +$pconfig['workgroup'] = $freenas_config['samba']['workgroup']; +$pconfig['serverdesc'] = $freenas_config['samba']['serverdesc']; +$pconfig['security'] = $freenas_config['samba']['security']; +$pconfig['localmaster'] = $freenas_config['samba']['localmaster']; +$pconfig['winssrv'] = $freenas_config['samba']['winssrv']; +/* $pconfig['hidemount'] = $freenas_config['samba']['hidemount']; */ +$pconfig['timesrv'] = $freenas_config['samba']['timesrv']; +$pconfig['unixcharset'] = $freenas_config['samba']['unixcharset']; +$pconfig['doscharset'] = $freenas_config['samba']['doscharset']; +$pconfig['loglevel'] = $freenas_config['samba']['loglevel']; +$pconfig['sndbuf'] = $freenas_config['samba']['sndbuf']; +$pconfig['rcvbuf'] = $freenas_config['samba']['rcvbuf']; +$pconfig['enable'] = isset($freenas_config['samba']['enable']); +$pconfig['recyclebin'] = isset($freenas_config['samba']['recyclebin']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + if ($_POST['enable']) { + $reqdfields = array_merge($reqdfields, explode(" ", "netbiosname workgroup security localmaster")); + $reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Netbiosname,Workgroup,Security, Localmaster")); + } + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['netbiosname'] && !is_domain($_POST['netbiosname']))) { + $error_bucket[] = array("error" => gettext("The Netbios name contains invalid characters."), + "field" => "netbiosname"); + } + if (($_POST['workgroup'] && !is_domain($_POST['workgroup']))) { + $error_bucket[] = array("error" => gettext("The Workgroup name contains invalid characters."), + "field" => "workgroup"); + } + if (($_POST['winssrv'] && !is_ipaddr($_POST['winssrv']))) { + $error_bucket[] = array("error" => gettext("The WINS server must be an IP address."), + "field" => "winssrv"); + } + + if (!is_numericint($_POST['sndbuf'])) { + $error_bucket[] = array("error" => gettext("PediaXThe SND Buffer value must be a number."), + "field" => "sndbuf"); + } + + if (!is_numericint($_POST['rcvbuf'])) { + $error_bucket[] = array("error" => gettext("The RCV Buffer value must be a number."), + "field" => "rcvbuf"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['samba']['netbiosname'] = $_POST['netbiosname']; + $freenas_config['samba']['workgroup'] = $_POST['workgroup']; + $freenas_config['samba']['serverdesc'] = $_POST['serverdesc']; + $freenas_config['samba']['security'] = $_POST['security']; + $freenas_config['samba']['localmaster'] = $_POST['localmaster']; + $freenas_config['samba']['winssrv'] = $_POST['winssrv']; + /* $freenas_config['samba']['hidemount'] = $_POST['hidemount']; */ + $freenas_config['samba']['timesrv'] = $_POST['timesrv']; + $freenas_config['samba']['doscharset'] = $_POST['doscharset']; + $freenas_config['samba']['unixcharset'] = $_POST['unixcharset']; + $freenas_config['samba']['loglevel'] = $_POST['loglevel']; + $freenas_config['samba']['sndbuf'] = $_POST['sndbuf']; + $freenas_config['samba']['rcvbuf'] = $_POST['rcvbuf']; + $freenas_config['samba']['recyclebin'] = $_POST['recyclebin'] ? true : false; + $freenas_config['samba']['enable'] = $_POST['enable'] ? true : false; + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) { + /* nuke the cache file */ + config_lock(); + services_samba_configure(); + services_zeroconf_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + } +} + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.netbiosname.disabled = endis; + document.iform.workgroup.disabled = endis; + document.iform.localmaster.disabled = endis; + document.iform.winssrv.disabled = endis; + document.iform.timesrv.disabled = endis; + document.iform.serverdesc.disabled = endis; + document.iform.doscharset.disabled = endis; + document.iform.unixcharset.disabled = endis; + document.iform.loglevel.disabled = endis; + document.iform.sndbuf.disabled = endis; + document.iform.rcvbuf.disabled = endis; + document.iform.recyclebin.disabled = endis; + document.iform.security.disabled = endis; + /* color adjustments */ + document.iform.netbiosname.style.backgroundColor = color; + document.iform.workgroup.style.backgroundColor = color; + document.iform.localmaster.style.backgroundColor = color; + document.iform.winssrv.style.backgroundColor = color; + document.iform.timesrv.style.backgroundColor = color; + document.iform.serverdesc.style.backgroundColor = color; + document.iform.doscharset.style.backgroundColor = color; + document.iform.unixcharset.style.backgroundColor = color; + document.iform.loglevel.style.backgroundColor = color; + document.iform.sndbuf.style.backgroundColor = color; + document.iform.rcvbuf.style.backgroundColor = color; + document.iform.recyclebin.style.backgroundColor = color; + document.iform.security.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<form id="iform" name="iform" action="services_samba.php" method="post"> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> +<div id="inputerrors"></div> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Settings"), true, "services_samba.php"); + $tab_array[1] = array(gettext("Shares"), false, "services_samba_share.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("CIFS share");?></span> + <span style="vertical-align: middle; position: relative; left: 84%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication");?></td> + <td width="78%" class="vtable"> + <select name="security" class="formselect" id="security"> + <?php + $types = explode(",", "Anonymous,Local User,Domain"); + $vals = explode(" ", "share user domain"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['security']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("NetBios name");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="netbiosname" type="text" class="formfld unknown" id="netbiosname" size="20" value="<?=htmlspecialchars($pconfig['netbiosname']);?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Workgroup");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="workgroup" type="text" class="formfld unknown" id="workgroup" size="20" value="<?=htmlspecialchars($pconfig['workgroup']);?>" /> + <br /> + <?= gettext("Workgroup to be member of.");?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="serverdesc" type="text" class="formfld unknown" id="serverdesc" size="30" value="<?=htmlspecialchars($pconfig['serverdesc']);?>" /> + <br /> + <?= gettext("Server description. This can usually be left blank.");?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Dos charset");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="doscharset" class="formselect" id="doscharset"> + <?php + $types = explode(",", "CP850,CP852,CP437,ASCII"); + $vals = explode(" ", "CP850 CP852 CP437 ASCII"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['doscharset']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Unix charset");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="unixcharset" class="formselect" id="unixcharset"> + <?php + $types = explode(",", "UTF-8,iso-8859-1,iso-8859-15,gb2312,ASCII"); + $vals = explode(" ", "UTF-8 iso-8859-1 iso-8859-15 gb2312 ASCII"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['unixcharset']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Log level");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="loglevel" class="formselect" id="loglevel"> + <?php + $types = explode(",", "Minimum,Normal,Full,Debug"); + $vals = explode(" ", "1 2 3 10"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['loglevel']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Local Master Browser");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="localmaster" class="formselect" id="localmaster"> + <?php + $types = explode(",", "Yes,No"); + $vals = explode(" ", "yes no"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['localmaster']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + <br /> + <?= gettext("Allows FreeNAS to try and become a local master browser."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Time Server");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <select name="timesrv" class="formselect" id="timesrv"> + <?php + $types = explode(",", "Yes,No"); + $vals = explode(" ", "yes no"); + $j = 0; + + for ($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['timesrv']) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($types[$j]);?> + </option> + <?php endfor; ?> + </select> + <br /> + <?= gettext("FreeNAS advertises itself as a time server to Windows clients."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("WINS server");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="winssrv" type="text" class="formfld host" id="winssrv" size="30" value="<?=htmlspecialchars($pconfig['winssrv']);?>" /> + <br /> + <?= gettext("WINS Server IP address."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Recycle Bin");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="recyclebin" type="checkbox" id="recyclebin" value="yes" <?php if ($pconfig['recyclebin']) echo "checked=\"checked\""; ?> /> + <?= gettext("Enable Recycle bin"); ?><br /> + <?= gettext("This will create a recycle bin on the CIFS shares"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Send Buffer Size");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="sndbuf" type="text" class="formfld unknown" id="sndbuf" size="30" value="<?=htmlspecialchars($pconfig['sndbuf']);?>" /> + <br /> + <?= gettext("Size of send buffer (16384 by default)."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Receive Buffer Size");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="rcvbuf" type="text" class="formfld unknown" id="rcvbuf" size="30" value="<?=htmlspecialchars($pconfig['rcvbuf']);?>" /> + <br /> + <?= gettext("Size of receive buffer (16384 by default)."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/services_samba_share.php b/config/freenas/www/services_samba_share.php new file mode 100644 index 00000000..1545df97 --- /dev/null +++ b/config/freenas/www/services_samba_share.php @@ -0,0 +1,165 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_samba_share.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("CIFS"), + gettext("Shares")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + if($_POST['apply']) { + $retval = 0; + if(!file_exists($d_sysrebootreqd_path)) { + config_lock(); + services_samba_configure(); + services_zeroconf_configure(); + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + + if(0 == $retval) { + if(file_exists($d_smbshareconfdirty_path)) + unlink($d_smbshareconfdirty_path); + } + } + } +} + +if($_GET['act'] == "ret") { + pfSenseHeader("services_samba_share.php"); + exit; +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<form id="iform" name="iform" action="services_samba_share.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if (file_exists($d_smbshareconfdirty_path)): ?> +<?php print_info_box_np(gettext("The shares has been modified.") . "<br />" . + gettext("You must apply the changes in order for them to take effect."));?> +<?php endif; ?> +<?php if ($input_errors) print_input_errors($input_errors); ?> +<div id="inputerrors"></div> + +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[0] = array(gettext("Settings"), false, "services_samba.php"); + $tab_array[1] = array(gettext("Shares"), true, "services_samba_share.php"); + display_top_tabs($tab_array); +?> + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%" class="listhdrr"><?= gettext("Share Name"); ?></td> + <td width="25%" class="listhdrr"><?= gettext("Description"); ?></td> + <td width="20%" class="listhdrr"><?= gettext("Browseable"); ?></td> + <td width="10%" class="list"></td> + </tr> + <?php $i = 0; foreach($a_mount as $mountv): ?> + <tr> + <td class="listr"><?=htmlspecialchars($mountv['sharename']);?></td> + <td class="listr"><?=htmlspecialchars($mountv['desc']);?></td> + <td class="listbg"><?=htmlspecialchars((is_array($freenas_config['samba']['hidemount']) && in_array($mountv['sharename'],$freenas_config['samba']['hidemount']))? gettext("No") : gettext("Yes"));?></td> + <td valign="middle" nowrap class="list"> + <?php if(isset($freenas_config['samba']['enable'])) + echo("<a href='services_samba_share_edit.php?id={$i}'><img src='./themes/" . $g['theme'] . "/images/icons/icon_e.gif' title='" . gettext("Edit Share") . "' width='17' height='17' border='0'></a>"); + ?> + </td> + </tr> + <?php $i++; endforeach; ?> + </table> + </div> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/services_samba_share_edit.php b/config/freenas/www/services_samba_share_edit.php new file mode 100644 index 00000000..d417fa4c --- /dev/null +++ b/config/freenas/www/services_samba_share_edit.php @@ -0,0 +1,157 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_samba_share_edit.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Services"), + gettext("CIFS"), + gettext("Shares"), + gettext("Edit")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +if(!is_array($freenas_config['samba']['hidemount'])) + $freenas_config['samba']['hidemount'] = array(); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + /* TODO: This logic needs to be tested! */ + if($_POST['browseable'] == gettext("No")) { + $freenas_config['samba']['hidemount'] = array_merge($freenas_config['samba']['hidemount'],array($freenas_config['mounts']['mount'][$id]['sharename'])); + } else { + if(is_array($freenas_config['samba']['hidemount']) && in_array($freenas_config['mounts']['mount'][$id]['sharename'],$freenas_config['samba']['hidemount'])) { + $freenas_config['samba']['hidemount'] = array_diff($freenas_config['samba']['hidemount'],array($freenas_config['mounts']['mount'][$id]['sharename'])); + } + } + + touch($d_smbshareconfdirty_path); + write_config(); + pfSenseHeader("services_samba_share.php"); + exit; + } +} + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="services_samba_share_edit.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Share Name"); ?></td> + <td width="78%" class="vtable"> + <input type="text" class="formfld file" size="30" value="<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['sharename']);?>" disabled="disabled" /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?= gettext("Description"); ?></td> + <td width="78%" class="vtable"> + <input type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($freenas_config['mounts']['mount'][$id]['desc']);?>" disabled="disabled"> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?= gettext("Browseable"); ?></td> + <td width="78%" class="vtable"> + <select name="browseable" class="formselect" id="browseable"> + <?php + $text = array(gettext("Yes"),gettext("No")); + $vals = explode(" ","1 0"); $j = 0; + for($j = 0; $j < count($vals); $j++): + ?> + <option value="<?=$vals[$j];?>" <?php if(is_array($freenas_config['samba']['hidemount']) && in_array($freenas_config['mounts']['mount'][$id]['sharename'],$freenas_config['samba']['hidemount'])) echo "selected=\"selected\"";?>> + <?=htmlspecialchars($text[$j]);?> + </option> + <?php endfor;?> + </select> + <br><?= gettext("This controls whether this share is seen in the list of available shares in a net view and in the browse list."); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="<?= gettext("Save"); ?>"> + <?php if(isset($id)): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <?php endif; ?> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +</body> +</html> diff --git a/config/freenas/www/services_unison.php b/config/freenas/www/services_unison.php new file mode 100644 index 00000000..eec58865 --- /dev/null +++ b/config/freenas/www/services_unison.php @@ -0,0 +1,249 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + services_unison.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +/* + ************************* + + Unison Installation Notes + + To work, unison requires an environment variable UNISON to point at + a writable directory. Unison keeps information there between syncs to + speed up the process. + + When a user runs the unison client, it will try to invoke ssh to + connect to the this server. Giving the local ssh a UNISON environment + variable without compromising ssh turned out to be non-trivial. + The solution is to modify the default path found in /etc/login.conf. + The path is seeded with "UNISON=/mnt" and this updated by the + /etc/inc/services.inc file. + + Todo: + * Arguably, a full client install could be done too to + allow FreeNAS to FreeNAS syncing. + + ************************* +*/ + +$pgtitle = array(gettext("Services"), + gettext("Unison")); + +require_once("freenas_config.inc"); +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['unison'])) { + $freenas_config['unison'] = array(); +} + +$pconfig['enable'] = isset($freenas_config['unison']['enable']); +$pconfig['share'] = $freenas_config['unison']['share']; +$pconfig['workdir'] = isset($freenas_config['unison']['workdir']); +$pconfig['makedir'] = isset($freenas_config['unison']['makedir']); + +if (! empty($_POST)) +{ + /* hash */ + unset($error_bucket); + /* simple error list */ + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = split(" ", "share workdir"); + $reqdfieldsn = split(",", "Share,Working Directory"); + + do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); + + $fullpath = "/mnt/{$_POST['share']}/{$_POST['workdir']}"; + + if (!$_POST['makedir'] && ($fullpath) && (!file_exists($fullpath))) { + $error_bucket[] = array("error" => gettext("The combination of share and working directory does not exist."), + "field" => "workdir"); + } + + if (is_array($error_bucket)) + foreach($error_bucket as $elem) + $input_errors[] =& $elem["error"]; + + /* if this is an AJAX caller then handle via JSON */ + if(isAjax() && is_array($error_bucket)) { + input_errors2Ajax(NULL, $error_bucket); + exit; + } + + if (!$input_errors) + { + $freenas_config['unison']['share'] = $_POST['share']; + $freenas_config['unison']['workdir'] = $_POST['workdir']; + $freenas_config['unison']['enable'] = $_POST['enable'] ? true : false; + $freenas_config['unison']['makedir'] = $_POST['makedir'] ? true : false; + + write_config(); + + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) + { + /* nuke the cache file */ + config_lock(); + services_unison_configure(); + /* services_zeroconf_configure(); */ + config_unlock(); + } + + $savemsg = get_std_save_message($retval); + } +} + +/* retrieve mounts to build list of share names */ +if (!is_array($freenas_config['mounts']['mount'])) + $freenas_config['mounts']['mount'] = array(); + +mount_sort(); + +$a_mount = &$freenas_config['mounts']['mount']; + +/* if ajax is calling, give them an update message */ +if(isAjax()) + print_info_box_np($savemsg); + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ + +$jscriptstr = <<<EOD +<script type="text/javascript"> +<!-- +function enable_change(enable_change) { + var endis; + + endis = !(document.iform.enable.checked || enable_change); + endis ? color = '#D4D0C8' : color = '#FFFFFF'; + + document.iform.share.disabled = endis; + document.iform.workdir.disabled = endis; + document.iform.makedir.disabled = endis; + /* color adjustments */ + document.iform.share.style.backgroundColor = color; + document.iform.workdir.style.backgroundColor = color; + document.iform.makedir.style.backgroundColor = color; +} +//--> +</script> + +EOD; + +$pfSenseHead->addScript($jscriptstr); +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="services_unison.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="100%" valign="middle" class="listtopic" colspan="2"> + <span style="vertical-align: middle; position: relative; left: 0px;"><?=gettext("Unison File Synchronisation");?></span> + <span style="vertical-align: middle; position: relative; left: 72%;"> + <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> onClick="enable_change(false)" /> <?= gettext("Enable"); ?> + </span> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Share");?></td> + <td width="78%" class="vtable"> + <select name="share" class="formselect" id="share"> + <?php foreach ($a_mount as $mount): $tmp=$mount['sharename']; ?> + <option value="<?=$tmp;?>" + <?php if ($tmp == $pconfig['share']) echo "selected=\"selected\"";?>><?=$tmp?></option> + <?php endforeach; ?> + </select> + <br /> + <?= gettext("You may need enough space to duplicate all files being synced."); ?>. + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Working Directory");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="workdir" type="text" class="formfld file" id="workdir" size="20" value="<?=htmlspecialchars($pconfig['workdir']);?>" /> + <?= gettext("Where the working files will be stored"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell"><?=gettext("Create");?></td> + <td width="78%" class="vtable" align="left" valign="middle"> + <input name="makedir" type="checkbox" id="makedir" value="yes" <?php if ($pconfig['makedir']) echo "checked=\"checked\""; ?> /> + <?= gettext("Create work directory if it doesn't exist"); ?> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /> + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <span class="red"> + <strong><?= gettext("Note"); ?>:</strong> + </span> + <br /> + <?= gettext("<a href='/system_advanced.php'>SSHD</a> must be enabled for Unison to work, and the <a href='/system_usermanager.php'>user</a> must have Full Shell enabled."); ?> + </td> + </tr> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +enable_change(false); +//--> +</script> +</body> +</html> diff --git a/config/freenas/www/status_disks.php b/config/freenas/www/status_disks.php new file mode 100644 index 00000000..704bc467 --- /dev/null +++ b/config/freenas/www/status_disks.php @@ -0,0 +1,127 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + status_disks.php + part of pfSense (http://www.pfSense.com) + Copyright (C) 2006 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on FreeNAS (http://www.freenas.org) + Copyright (C) 2005-2006 Olivier Cochard-Labbé <olivier@freenas.org>. + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +$pgtitle = array(gettext("Status"), + gettext("Disks")); + +require_once("guiconfig.inc"); +require_once("freenas_guiconfig.inc"); +require_once("freenas_functions.inc"); + +if (!is_array($freenas_config['disks']['disk'])) + $freenas_config['disks']['disk'] = array(); + +disks_sort(); + +$raidstatus=get_sraid_disks_list(); + +$a_disk_conf = &$freenas_config['disks']['disk']; + +include("head.inc"); +/* put your custom HTML head content here */ +/* using some of the $pfSenseHead function calls */ +echo $pfSenseHead->getHTML(); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> +<?php include("fbegin.inc"); ?> + +<?php if ($input_errors) print_input_errors($input_errors); ?> +<?php if ($savemsg) print_info_box($savemsg); ?> + <div id="inputerrors"></div> + <form id="iform" name="iform" action="status_disks.php" method="post"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="5%" class="listhdrr">Disk</td> + <td width="5%" class="listhdrr">Size</td> + <td width="60%" class="listhdrr">Description</td> + <td width="10%" class="listhdr">Status</td> + </tr> + <?php foreach ($a_disk_conf as $disk): ?> + <tr> + <td class="listr"> + <?=htmlspecialchars($disk['name']);?> + </td> + <td class="listr"> + <?=htmlspecialchars($disk['size']);?> + </td> + <td class="listr"> + <?=htmlspecialchars($disk['desc']);?> + </td> + <td class="listr"> + <?php + $stat=disks_status($disk); + echo $stat;?> + </td> + </tr> + <?php endforeach; ?> + <?php if (isset($raidstatus)): ?> + <?php foreach ($raidstatus as $diskk => $diskv): ?> + <tr> + <td class="listr"> + <?=htmlspecialchars($diskk);?> + </td> + <td class="listr"> + <?=htmlspecialchars($diskv['size']);?> + </td> + <td class="listr"> + + <?=htmlspecialchars("Software RAID volume");?> + </td> + <td class="listr"> + <?=htmlspecialchars($diskv['desc']);?> + </td> + </tr> + <?php endforeach; ?> + <?php endif; ?> + </table> + </form> +<?php include("fend.inc"); ?> +<?= checkForInputErrors(); ?> +<script type="text/javascript"> +<!-- +// enable_change(false); +//--> +</script> +</body> +</html> |