_("Your account"))); dual_begin(array()); print("

" . _("Home") . " / " . _("Your account") . "

\n"); print("

" . _("You have not authenticated yourself to the system yet with your") . " " . _("username") . " " . _("and") . " " . _("password") . ". " . _("You will not be able to use this section of the website without authenticating yourself first. So, please continue and login using the form on the right hand side.") . "

\n"); dual_middle(array()); show_account_details(array()); dual_end(array()); generic_footer(array()); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); exit; } $volumes_id = array(); $volumes_name = array(); $volumes_mountpoint = array(); $volumes_vg = array(); $volumes_fstype = array(); function volumes_startelement($parser, $name, $attrs) { global $volumes_id, $volumes_name, $volumes_mountpoint, $volumes_vg, $volumes_fstype; if ($name == "VOLUME") { array_push($volumes_id, $attrs["ID"]); array_push($volumes_name, $attrs["NAME"]); array_push($volumes_mountpoint, $attrs["MOUNTPOINT"]); array_push($volumes_vg, $attrs["VG"]); array_push($volumes_fstype, $attrs["FSTYPE"]); } } function volumes_endelement($parser, $name) { } $volumes_parser = xml_parser_create(); xml_set_element_handler($volumes_parser, "volumes_startelement", "volumes_endelement"); $volumes_fp = fopen("/opt/openfiler/etc/volumes.xml", "r"); while ($volumes_data = fread($volumes_fp, 4096)) xml_parse($volumes_parser, $volumes_data, feof($volumes_fp)); fclose($volumes_fp); xml_parser_free($volumes_parser); $snapshots_id = array(); $snapshots_lvname = array(); $snapshots_vgname = array(); $snapshots_shared = array(); $snapshots_rotateid = array(); function snapshots_startelement($parser, $name, $attrs) { global $snapshots_id, $snapshots_lvname, $snapshots_vgname, $snapshots_shared, $snapshots_rotateid; if ($name == "SNAPSHOT") { array_push($snapshots_id, $attrs["ID"]); array_push($snapshots_lvname, $attrs["LVNAME"]); array_push($snapshots_vgname, $attrs["VGNAME"]); array_push($snapshots_shared, $attrs["SHARED"]); array_push($snapshots_rotateid, $attrs["ROTATEID"]); } } function snapshots_endelement($parser, $name) { } $snapshots_parser = xml_parser_create(); xml_set_element_handler($snapshots_parser, "snapshots_startelement", "snapshots_endelement"); $snapshots_fp = fopen("/opt/openfiler/etc/snapshots.xml", "r"); while ($snapshots_data = fread($snapshots_fp, 4096)) xml_parse($snapshots_parser, $snapshots_data, feof($snapshots_fp)); fclose($snapshots_fp); xml_parser_free($snapshots_parser); $fstabp = popen("/usr/bin/sudo /bin/cat /etc/fstab", "r"); $i = 0; while (!feof($fstabp)) { $j = 0; $fstabstr = trim(fgets($fstabp, 4096)); if (strlen($fstabstr) <= 0) continue; if (substr($fstabstr, 0, 1) == "#") continue; $foo = explode(" ", $fstabstr); foreach ($foo as $fresultitem) { $fresultitem = trim($fresultitem); if (strlen($fresultitem) > 0) { $fstab[$i][$j] = $fresultitem; $j++; } } $i++; } $fstabcount = $i; pclose($fstabp); $vgname = "openfiler"; if ($HTTP_POST_VARS["snapaction"] == "takesnapshot") { if ((!is_valid_foldername($snapname)) || (substr(strtolower($snapname), 0, 5) == "sched") || (!is_numeric($snapsize))) { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } $snapname = strtolower($snapname); $mountpath = "/mnt/snapshots/" . $vgname . "/" . $volume . "/" . $snapname; if ((!is_dir($mountpath)) && (!is_file($mountpath))) { $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($vgname == $volumes_vg[$fsj]) && ($volume == $volumes_id[$fsj])) { $fstype = $volumes_fstype[$fsj]; break; } } $fs = 0; $fsfound = false; for ($fsi = 0; $fsi < count($fs_info); $fsi++) { if ($fs_info[$fsi]["type"] == $fstype) { $fs = $fsi; $fsfound = true; break; } } if ($fsfound == false) $fs = 0; if ($fstype == "xfs") exec("/usr/bin/sudo /usr/sbin/xfs_freeze -f /dev/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); exec("/usr/bin/sudo /sbin/lvm lvcreate -s -L " . escapeshellarg($snapsize) . " -n of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapname) . " /dev/openfiler/" . escapeshellarg($volume)); if ($fstype == "xfs") exec("/usr/bin/sudo /usr/sbin/xfs_freeze -u /dev/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); $lvp = popen("/usr/bin/sudo /sbin/lvm lvdisplay -c /dev/" . $vgname . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapname), "r"); $i = 0; while (!feof($lvp)) $lvds[$i++] = fgets($lvp, 4096); pclose($lvp); $lvinfo = explode(":", trim($lvds[0], " ")); if ($lvinfo[0] == ("/dev/" . $vgname . "/of.snapshot." . $volume . "." . $snapname)) { array_push($snapshots_id, $snapname); array_push($snapshots_lvname, $volume); array_push($snapshots_vgname, $vgname); array_push($snapshots_shared, $snapshare); array_push($snapshots_rotateid, 0); $snapshotsp = popen("/usr/bin/sudo /usr/bin/tee /opt/openfiler/etc/snapshots.xml", "w"); fputs($snapshotsp, "\n"); fputs($snapshotsp, "\n"); for ($i = 0; $i < count($snapshots_id); $i++) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n\n"); pclose($snapshotsp); exec("/usr/bin/sudo /bin/mkdir -p " . escapeshellarg($mountpath)); $fstabp = popen("/usr/bin/sudo /usr/bin/tee -a /etc/fstab", "w"); fputs($fstabp, "/dev/" . $vgname . "/of.snapshot." . $volume . "." . $snapname . " " . $mountpath . " " . $fs_info[$fs]["type"] . " " . $fs_info[$fs]["snapshot_mount_options"] . " 0 0\n"); pclose($fstabp); exec("/usr/bin/sudo /bin/mount -a"); apply_configuration(); } } flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } else if ($HTTP_POST_VARS["snapaction"] == "changesize") { for ($i = 0; $i < count($snapshots_lvname); $i++) if ((${"changesize-" . $snapshots_lvname[$i] . "-" . $snapshots_id[$i]} == "Save") && (substr(strtolower($snapshots_lvname[$i]), 0, 5) != "sched")) { $snapshot_dev = "/dev/mapper/" . $snapshots_vgname[$i] . "-of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; $snapshot_symlink_dev = "/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; if (file_exists($snapshot_dev)) { $lvp = popen("/usr/bin/sudo /sbin/lvm lvdisplay -c " . $snapshot_symlink_dev, "r"); $j = 0; while (!feof($lvp)) $lvs[$j++] = fgets($lvp, 4096); pclose($lvp); $snapshot_info = explode(":", trim($lvs[0], " ")); $existing_snapshot_size = ($snapshot_info[6] / 2048); $new_snapshot_size = ${"newsize-" . $snapshots_lvname[$i] . "-" . $snapshots_id[$i]}; if ($new_snapshot_size > $existing_snapshot_size) exec("/usr/bin/sudo /sbin/lvm lvextend -L " . escapeshellarg($new_snapshot_size) . " /dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]); } $snapshotsp = popen("/usr/bin/sudo /usr/bin/tee /opt/openfiler/etc/snapshots.xml", "w"); fputs($snapshotsp, "\n"); fputs($snapshotsp, "\n"); for ($j = 0; $j < count($snapshots_id); $j++) if ($j != $i) fputs($snapshotsp, "\t\n"); else fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n"); pclose($snapshotsp); break; } flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } else if ($HTTP_GET_VARS["snapaction"] == "deletesnapshot") { if (substr(strtolower($snapshot), 0, 5) == "sched") { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } $smb = (strstr(exec("/usr/bin/sudo /sbin/service smb status"), "running") ? 1 : 0); $nfsv3 = (strstr(exec("/usr/bin/sudo /sbin/service nfs status"), "running") ? 1 : 0); $atalk = (strstr(exec("/usr/bin/sudo /sbin/service atalk status"), "running") ? 1 : 0); if ($smb) exec("/usr/bin/sudo /sbin/service smb stop"); if ($nfsv3) exec("/usr/bin/sudo /sbin/service nfs stop"); if ($atalk) exec("/usr/bin/sudo /sbin/service atalk stop"); exec("/usr/bin/sudo /bin/umount -f /dev/openfiler/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshot), $umount_output, $umount_result); if ($umount_result != 0) { apply_configuration(); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } exec("/usr/bin/sudo /sbin/lvm lvremove -f /dev/openfiler/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshot)); $snapshotsp = popen("/usr/bin/sudo /usr/bin/tee /opt/openfiler/etc/snapshots.xml", "w"); fputs($snapshotsp, "\n"); fputs($snapshotsp, "\n"); for ($i = 0; $i < count($snapshots_id); $i++) if (($snapshots_id[$i] != $snapshot) || ($snapshots_lvname[$i] != $volume)) fputs($snapshotsp, "\t\n"); else { exec("/usr/bin/sudo /bin/rmdir --ignore-fail-on-non-empty /mnt/snapshots/openfiler/" . escapeshellarg($volume) . "/" . escapeshellarg($snapshot)); exec("/usr/bin/sudo /bin/rmdir -p --ignore-fail-on-non-empty /mnt/snapshots/openfiler/" . escapeshellarg($volume)); } fputs($snapshotsp, "\n"); pclose($snapshotsp); $fstabp = popen("/usr/bin/sudo /usr/bin/tee /etc/fstab", "w"); for ($i = 0; $i < $fstabcount; $i++) { $str = ""; if ($fstab[$i][0] == "/dev/openfiler/of.snapshot." . $volume . "." . $snapshot) continue; for ($j = 0; $j < count($fstab[$i]); $j++) { if ($j > 0) $str .= " "; $str .= $fstab[$i][$j]; } fputs($fstabp, ($str . "\n")); } pclose($fstabp); apply_configuration(); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume)); exit; } if (strlen($HTTP_GET_VARS["volume"]) <= 0) { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes.html"); exit; } $volume = strtolower($volume); $vn = 0; while (($vn < count($volumes_id)) && ($volumes_id[$vn] != $volume)) $vn++; if ($vn >= count($volumes_id)) { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes.html"); exit; } generic_header(array("title" => _("Administration Section"))); single_begin(array()); print("

" . _("Home") . " / " . _("Administration Section") . "

\n"); ?>

Welcome Administrator. The following are various system information and preferences, arranged into tabs. Please click on a tab to open up that category.

List of existing snapshots for volume \"" . $volume . "\"\n"); $snapshots_found = false; for ($i = 0; $i < count($snapshots_lvname); $i++) if (($snapshots_lvname[$i] == $volume) && ($snapshots_vgname[$i] == "openfiler")) { $snapshots_found = true; break; } if ($snapshots_found) { print("
\n"); print("\n"); print("\n"); print("
\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); $dcolor = 0; for ($i = 0; $i < count($snapshots_lvname); $i++) if (($snapshots_lvname[$i] == $volume) && ($snapshots_vgname[$i] == "openfiler")) { $snapshot_dev = "/dev/mapper/" . $snapshots_vgname[$i] . "-of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; $snapshot_symlink_dev = "/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; if (!file_exists($snapshot_dev)) continue; if ($dcolor == 0) { $dcolor = 1; $dvalue = $GLOBALS["color_table_row1"]; } else { $dcolor = 0; $dvalue = $GLOBALS["color_table_row2"]; } $snapshot_stat = stat($snapshot_dev); $lvp = popen("/usr/bin/sudo /sbin/lvm lvdisplay -c " . $snapshot_symlink_dev, "r"); $j = 0; while (!feof($lvp)) $lvs[$j++] = fgets($lvp, 4096); pclose($lvp); $lvp2 = popen("/usr/bin/sudo /sbin/lvm lvdisplay -C " . $snapshot_symlink_dev, "r"); $j = 0; while (!feof($lvp2)) $lvs2[$j++] = fgets($lvp2, 4096); pclose($lvp2); $snapshot_info = explode(":", trim($lvs[0], " ")); $snapshot_info2 = explode(" ", trim($lvs2[1], " ")); $rand_id = sha1($snapshots_id[$i] . rand()); /* Find the utilization field in the output from the above popen() */ $uc = 0; for ($j = 0; $j < count($snapshot_info2); $j++) { if (strlen(trim($snapshot_info2[$j])) > 0) $uc++; if ($uc == 6) { $uc = $j; break; } } print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); } print("
Snapshot nameDate/time takenBlock utilizationSnapshot size (in MB)Share contentsSaveDelete snapshot
" . htmlentities($snapshots_id[$i]) . "" . htmlentities(date("F j, Y H:i:s", $snapshot_stat[10])) . "" . $snapshot_info2[$uc] . "%\n"); print("
\n"); print("

Are you sure you want to delete
the snapshot named \"" . htmlentities($snapshots_id[$i]) . "\"?

\n"); print("

Yes / NO DON'T DELETE ]

\n"); print("
\n"); print("Delete\n"); print("
\n"); print("
\n"); print("
\n"); } else { print("

No snapshots were found.

\n"); } ?>

 


Schedule snapshots for volume \"" . $volume . "\"\n"); ?>

 


Take a snapshot

\n"); print("\n"); print("\n"); ?>

Snapshots work using the copy-on-write method.
Use the following form to take a snapshot of the supplied size
for the volume. Once the amount of updates to the volume since the snapshot was
taken crosses the size of the snapshot, the volume will become read-only until
more space is allocated to the snapshot. So please allocate enough space to it.
The snapshot name must be specified like a UNIX filename without its path.

">Snapshot name " align="center">Size in MB " align="center">Share contents? " align="center">Apply
" align="center"> " align="center"> " align="center"> " align="center">