_("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(); $schedule_size = array(); $schedule_share = array(); $schedule_timecounter = array(); $schedule_timemax = array(); $schedule_rotatecounter = array(); $schedule_rotatemax = array(); $schedule_lvname = array(); $schedule_vgname = array(); function snapshots_startelement($parser, $name, $attrs) { global $snapshots_id, $snapshots_lvname, $snapshots_vgname, $snapshots_shared, $snapshots_rotateid; global $schedule_size, $schedule_share; global $schedule_timecounter, $schedule_timemax; global $schedule_rotatecounter, $schedule_rotatemax; global $schedule_lvname, $schedule_vgname; 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"]); } else if ($name == "SCHEDULE") { array_push($schedule_size, $attrs["SIZE"]); array_push($schedule_share, $attrs["SHARE"]); array_push($schedule_timecounter, $attrs["TIMECOUNTER"]); array_push($schedule_timemax, $attrs["TIMEMAX"]); array_push($schedule_rotatecounter, $attrs["ROTATECOUNTER"]); array_push($schedule_rotatemax, $attrs["ROTATEMAX"]); array_push($schedule_lvname, $attrs["LVNAME"]); array_push($schedule_vgname, $attrs["VGNAME"]); } } 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); global $cluster_enabled, $cluster_nodename, $cluster_resource; $cluster_enabled = false; $cluster_nodename = ""; $cluster_resource = array(); function cluster_startelement($parser, $name, $attrs) { global $cluster_enabled, $cluster_nodename, $cluster_resource; if ($name == "CLUSTERING") { if ($attrs["STATE"] == "on") $cluster_enabled = true; else $cluster_enabled = false; } else if ($name == "NODENAME") $cluster_nodename = $attrs["VALUE"]; else if ($name == "RESOURCE") array_push($cluster_resource, $attrs["VALUE"]); } function cluster_endelement($parser, $name) { } $cluster_parser = xml_parser_create(); xml_set_element_handler($cluster_parser, "cluster_startelement", "cluster_endelement"); $cluster_fp = fopen("/opt/openfiler/etc/cluster.xml", "r"); while ($cluster_data = fread($cluster_fp, 4096)) xml_parse($cluster_parser, $cluster_data, feof($cluster_fp)); fclose($cluster_fp); xml_parser_free($cluster_parser); if (!$cluster_enabled) { $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); } 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) . "&vgname=" . urlencode($vgname)); 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 /mnt/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); exec("/usr/bin/sudo " . $GLOBALS["lvm_command_prefix"] . "lvcreate -s -L " . escapeshellarg($snapsize) . " -n of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapname) . " /dev/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); if ($fstype == "xfs") exec("/usr/bin/sudo /usr/sbin/xfs_freeze -u /mnt/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); $lvp = popen("/usr/bin/sudo " . $GLOBALS["lvm_command_prefix"] . "lvdisplay -c /dev/" . escapeshellarg($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"); for ($i = 0; $i < count($schedule_vgname); $i++) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n\n"); pclose($snapshotsp); exec("/usr/bin/sudo /bin/mkdir -p " . escapeshellarg($mountpath)); if (!$cluster_enabled) { $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); } else { $service_winbind = (strstr(exec("/usr/bin/sudo /sbin/service winbind status"), "running") ? 1 : 0); $service_smb = (strstr(exec("/usr/bin/sudo /sbin/service smb status"), "running") ? 1 : 0); $service_nfsv3 = (strstr(exec("/usr/bin/sudo /sbin/service nfs status"), "running") ? 1 : 0); $service_http = (strstr(exec("/usr/bin/sudo /sbin/service httpd status"), "running") ? 1 : 0); $clusterp = popen("/usr/bin/sudo /usr/bin/tee /etc/ha.d/haresources", "w"); $cluster_resource_str = ""; for ($i = 0; $i < count($cluster_resource); $i++) $cluster_resource_str .= " " . $cluster_resource[$i]; for ($i = 0; $i < count($volumes_id); $i++) { $fstype = $volumes_fstype[$fsj]; $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; $cluster_resource_str .= " Filesystem::/dev/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . "/mnt/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["mount_options"]; } for ($i = 0; $i < count($snapshots_id); $i++) { $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($snapshots_vgname[$i] == $volumes_vg[$fsj]) && ($snapshots_lvname[$i] == $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; $cluster_resource_str .= " Filesystem::/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i] . "::" . "/mnt/snapshots/" . $snapshots_vgname[$i] . "/" . $snapshots_lvname[$i] . "/" . $snapshots_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["snapshot_mount_options"]; } if ($service_winbind > 0) $cluster_resource_str .= " winbind"; if ($service_http > 0) $cluster_resource_str .= " httpd"; if ($service_nfsv3 > 0) $cluster_resource_str .= " nfs"; if ($service_smb > 0) $cluster_resource_str .= " smb"; $cluster_resource_str .= " openfiler"; fputs($clusterp, $cluster_nodename . $cluster_resource_str . "\n"); pclose($clusterp); } exec("/usr/bin/sudo /bin/mount -t " . $fs_info[$fs]["type"] . " -o " . $fs_info[$fs]["snapshot_mount_options"] . " /dev/" . $vgname . "/of.snapshot." . $volume . "." . $snapname . " " . escapeshellarg($mountpath)); apply_configuration(array("services" => "reload", "chmod" => "no", "chmod_path" => "")); } } flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); exit; } else if ($HTTP_POST_VARS["snapaction"] == "changesize") { for ($i = 0; $i < count($snapshots_lvname); $i++) if ((${"changesize-" . $snapshots_vgname[$i] . "-" . $snapshots_lvname[$i] . "-" . $snapshots_id[$i]} == "Save") && (substr(strtolower($snapshots_lvname[$i]), 0, 5) != "sched")) { if ($GLOBALS["lvm_version"] == 1) $snapshot_dev = "/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; else $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 " . $GLOBALS["lvm_command_prefix"] . "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 = intval(round($snapshot_info[6] / 2048.0)); $new_snapshot_size = ${"newsize-" . $snapshots_vgname[$i] . "-" . $snapshots_lvname[$i] . "-" . $snapshots_id[$i]}; if ($new_snapshot_size > $existing_snapshot_size) exec("/usr/bin/sudo " . $GLOBALS["lvm_command_prefix"] . "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"); for ($j = 0; $j < count($schedule_vgname); $j++) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n"); pclose($snapshotsp); break; } flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); apply_configuration(array("services" => "reload", "chmod" => "no", "chmod_path" => "")); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); exit; } else if ($HTTP_POST_VARS["snapaction"] == "schedulesnapshot") { if ((!is_numeric($snapsize)) || (!is_numeric($snapinterval)) || (!is_numeric($snaprotatecount)) || ($snaprotatecount < 1) || ($snapinterval < 1)) { flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); exit; } array_push($schedule_size, $snapsize); array_push($schedule_share, $snapshare); array_push($schedule_timemax, $snapinterval); array_push($schedule_timecounter, 23 - intval(date("H"))); array_push($schedule_rotatemax, $snaprotatecount); array_push($schedule_rotatecounter, 0); array_push($schedule_lvname, $volume); array_push($schedule_vgname, $vgname); $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"); for ($i = 0; $i < count($schedule_vgname); $i++) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n\n"); pclose($snapshotsp); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); 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) . "&vgname=" . urlencode($vgname)); exit; } $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) || ($snapshots_vgname[$i] != $vgname)) fputs($snapshotsp, "\t\n"); for ($i = 0; $i < count($schedule_vgname); $i++) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n"); pclose($snapshotsp); if (!$cluster_enabled) { $fstabp = popen("/usr/bin/sudo /usr/bin/tee /etc/fstab", "w"); for ($i = 0; $i < $fstabcount; $i++) { $str = ""; if ($fstab[$i][0] == "/dev/" . $vgname . "/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); } else { $service_winbind = (strstr(exec("/usr/bin/sudo /sbin/service winbind status"), "running") ? 1 : 0); $service_smb = (strstr(exec("/usr/bin/sudo /sbin/service smb status"), "running") ? 1 : 0); $service_nfsv3 = (strstr(exec("/usr/bin/sudo /sbin/service nfs status"), "running") ? 1 : 0); $service_http = (strstr(exec("/usr/bin/sudo /sbin/service httpd status"), "running") ? 1 : 0); $clusterp = popen("/usr/bin/sudo /usr/bin/tee /etc/ha.d/haresources", "w"); $cluster_resource_str = ""; for ($i = 0; $i < count($cluster_resource); $i++) $cluster_resource_str .= " " . $cluster_resource[$i]; for ($i = 0; $i < count($volumes_id); $i++) { $fstype = $volumes_fstype[$fsj]; $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; $cluster_resource_str .= " Filesystem::/dev/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . "/mnt/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["mount_options"]; } for ($i = 0; $i < count($snapshots_id); $i++) { $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($snapshots_vgname[$i] == $volumes_vg[$fsj]) && ($snapshots_lvname[$i] == $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; $cluster_resource_str .= " Filesystem::/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i] . "::" . "/mnt/snapshots/" . $snapshots_vgname[$i] . "/" . $snapshots_lvname[$i] . "/" . $snapshots_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["snapshot_mount_options"]; } if ($service_winbind > 0) $cluster_resource_str .= " winbind"; if ($service_http > 0) $cluster_resource_str .= " httpd"; if ($service_nfsv3 > 0) $cluster_resource_str .= " nfs"; if ($service_smb > 0) $cluster_resource_str .= " smb"; $cluster_resource_str .= " openfiler"; fputs($clusterp, $cluster_nodename . $cluster_resource_str . "\n"); pclose($clusterp); } apply_configuration(array("services" => "reload", "chmod" => "no", "chmod_path" => "")); exec("/usr/bin/sudo /bin/umount -f /dev/" . escapeshellarg($vgname) . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshot), $umount_output, $umount_result); exec("/usr/bin/sudo " . $GLOBALS["lvm_command_prefix"] . "lvremove -f /dev/" . escapeshellarg($vgname) . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshot)); exec("/usr/bin/sudo /bin/rmdir --ignore-fail-on-non-empty /mnt/snapshots/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume) . "/" . escapeshellarg($snapshot)); exec("/usr/bin/sudo /bin/rmdir -p --ignore-fail-on-non-empty /mnt/snapshots/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); exit; } else if ($HTTP_GET_VARS["snapaction"] == "deletesnapshotschedule") { $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); $httpd = (strstr(exec("/usr/bin/sudo /sbin/service httpd 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"); if ($httpd) exec("/usr/bin/sudo /sbin/service httpd stop"); $fstab_append = ""; for ($i = 0; $i < count($schedule_lvname); $i++) { if (($schedule_lvname[$i] == $volume) && ($schedule_vgname[$i] == $vgname)) { for ($j = 0; $j < count($snapshots_id); $j++) { if (($snapshots_lvname[$j] == $volume) && ($snapshots_vgname[$j] == $vgname) && (substr($snapshots_id[$j], 0, 5) == "sched")) { exec("/usr/bin/sudo /bin/umount -f /dev/" . escapeshellarg($vgname) . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshots_id[$j]), $umount_output, $umount_result); if ($umount_result != 0) { apply_configuration(array("services" => "restart", "chmod" => "no", "chmod_path" => "")); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); exit; } } } for ($j = 0; $j < count($snapshots_id); $j++) { if (($snapshots_lvname[$j] == $volume) && ($snapshots_vgname[$j] == $vgname) && (substr($snapshots_id[$j], 0, 5) == "sched")) { exec("/usr/bin/sudo /bin/rmdir --ignore-fail-on-non-empty /mnt/snapshots/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume) . "/" . escapeshellarg($snapshots_id[$j])); exec("/usr/bin/sudo /bin/rmdir -p --ignore-fail-on-non-empty /mnt/snapshots/" . escapeshellarg($vgname) . "/" . escapeshellarg($volume)); do { $newname = "oldsnap" . substr(sha1($snapshots_vgname[$j] . $snapshots_lvname[$j] . rand()), 0, 16); $mountpath = "/mnt/snapshots/" . $vgname . "/" . $volume . "/" . $newname; } while (is_dir($mountpath)); exec("/usr/bin/sudo " . $GLOBALS["lvm_command_prefix"] . "lvrename /dev/" . escapeshellarg($vgname) . "/of.snapshot." . escapeshellarg($volume) . "." . escapeshellarg($snapshots_id[$j]) . " /dev/" . escapeshellarg($vgname) . "/of.snapshot." . escapeshellarg($volume) . "." . $newname); exec("/usr/bin/sudo /bin/mkdir -p " . escapeshellarg($mountpath)); $snapshots_id[$j] = $newname; $snapshots_rotateid[$j] = 0; $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($snapshots_vgname[$j] == $volumes_vg[$fsj]) && ($snapshots_lvname[$j] == $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; $fstab_append = $fstab_append . "/dev/" . $vgname . "/of.snapshot." . $volume . "." . $newname . " " . $mountpath . " " . $fs_info[$fs]["type"] . " " . $fs_info[$fs]["snapshot_mount_options"] . " 0 0\n"; if ($cluster_enabled) exec("/usr/bin/sudo /bin/mount -t " . $fs_info[$fs]["type"] . " -o " . $fs_info[$fs]["snapshot_mount_options"] . " /dev/" . $vgname . "/of.snapshot." . $volume . "." . $newname . " " . escapeshellarg($mountpath)); } } break; } } $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"); for ($i = 0; $i < count($schedule_vgname); $i++) if (!(($schedule_lvname[$i] == $volume) && ($schedule_vgname[$i] == $vgname))) fputs($snapshotsp, "\t\n"); fputs($snapshotsp, "\n"); pclose($snapshotsp); if (!$cluster_enabled) { $fstabp = popen("/usr/bin/sudo /usr/bin/tee /etc/fstab", "w"); for ($i = 0; $i < $fstabcount; $i++) { $str = ""; if (substr($fstab[$i][0], 0, strlen("/dev/" . $vgname . "/of.snapshot." . $volume . ".sched")) == "/dev/" . $vgname . "/of.snapshot." . $volume . ".sched") continue; for ($j = 0; $j < count($fstab[$i]); $j++) { if ($j > 0) $str .= " "; $str .= $fstab[$i][$j]; } fputs($fstabp, ($str . "\n")); } fputs($fstabp, $fstab_append); pclose($fstabp); exec("/usr/bin/sudo /bin/mount -a"); } else { $service_winbind = (strstr(exec("/usr/bin/sudo /sbin/service winbind status"), "running") ? 1 : 0); $service_smb = (strstr(exec("/usr/bin/sudo /sbin/service smb status"), "running") ? 1 : 0); $service_nfsv3 = (strstr(exec("/usr/bin/sudo /sbin/service nfs status"), "running") ? 1 : 0); $service_http = (strstr(exec("/usr/bin/sudo /sbin/service httpd status"), "running") ? 1 : 0); $clusterp = popen("/usr/bin/sudo /usr/bin/tee /etc/ha.d/haresources", "w"); $cluster_resource_str = ""; for ($i = 0; $i < count($cluster_resource); $i++) $cluster_resource_str .= " " . $cluster_resource[$i]; for ($i = 0; $i < count($volumes_id); $i++) { $fstype = $volumes_fstype[$fsj]; $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; $cluster_resource_str .= " Filesystem::/dev/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . "/mnt/" . $volumes_vg[$i] . "/" . $volumes_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["mount_options"]; } for ($i = 0; $i < count($snapshots_id); $i++) { $fstype = ""; for ($fsj = 0; $fsj < count($volumes_id); $fsj++) { if (($snapshots_vgname[$i] == $volumes_vg[$fsj]) && ($snapshots_lvname[$i] == $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; $cluster_resource_str .= " Filesystem::/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i] . "::" . "/mnt/snapshots/" . $snapshots_vgname[$i] . "/" . $snapshots_lvname[$i] . "/" . $snapshots_id[$i] . "::" . $fs_info[$fs]["type"] . "::" . $fs_info[$fs]["snapshot_mount_options"]; } if ($service_winbind > 0) $cluster_resource_str .= " winbind"; if ($service_http > 0) $cluster_resource_str .= " httpd"; if ($service_nfsv3 > 0) $cluster_resource_str .= " nfs"; if ($service_smb > 0) $cluster_resource_str .= " smb"; $cluster_resource_str .= " openfiler"; fputs($clusterp, $cluster_nodename . $cluster_resource_str . "\n"); pclose($clusterp); } apply_configuration(array("services" => "restart", "chmod" => "no", "chmod_path" => "")); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); header("Location: ./volumes_snapshots.html?volume=" . urlencode($volume) . "&vgname=" . urlencode($vgname)); 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 . "\" in volume group \"" . $vgname . "\"\n"); $snapshots_found = false; for ($i = 0; $i < count($snapshots_lvname); $i++) if (($snapshots_lvname[$i] == $volume) && ($snapshots_vgname[$i] == $vgname)) { $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"); print("\n"); $dcolor = 0; for ($i = 0; $i < count($snapshots_lvname); $i++) if (($snapshots_lvname[$i] == $volume) && ($snapshots_vgname[$i] == $vgname)) { if ($GLOBALS["lvm_version"] == 1) $snapshot_dev = "/dev/" . $snapshots_vgname[$i] . "/of.snapshot." . $snapshots_lvname[$i] . "." . $snapshots_id[$i]; else $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 " . $GLOBALS["lvm_command_prefix"] . "lvdisplay -c " . $snapshot_symlink_dev, "r"); $j = 0; while (!feof($lvp)) $lvs[$j++] = fgets($lvp, 4096); pclose($lvp); $snapshot_info = explode(":", trim($lvs[0], " ")); $rand_id = sha1($snapshots_id[$i] . rand()); $scheduled = 0; if (substr($snapshots_id[$i], 0, 5) == "sched") { $dvalue = "#dddddd"; $scheduled = 1; } print("\n"); print("\n"); print("\n"); if (intval($snapshot_info[13]) >= intval($snapshot_info[6])) print("\n"); else print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); } print("
Snapshot nameDate/time takenBlock utilization (in MB)Snapshot size (in MB)Share contentsSaveDelete snapshot
" . htmlentities($snapshots_id[$i]) . "" . htmlentities(date("F j, Y H:i:s", $snapshot_stat[10])) . "Snapshot full. Please delete." . intval(round($snapshot_info[13] / 2048.0)) . ""); if ($scheduled) print(intval(round($snapshot_info[6] / 2048.0))); else print(""); print(""); if ($scheduled) print(($snapshots_shared[$i] == "yes") ? "Yes, do" : "No, don't"); else print(""); print(""); if ($scheduled) print("N/A"); else print(""); print("\n"); if ($scheduled) print("N/A"); else { 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 . "\" in volume group \"" . $vgname . "\"\n"); $schedule_found = false; for ($i = 0; $i < count($schedule_lvname); $i++) { if (($schedule_lvname[$i] == $volume) && ($schedule_vgname[$i] == $vgname)) { $schedule_found = true; $schedule_index = $i; break; } } if ($schedule_found == true) { print("
\n"); print("

Are you sure you want to delete
the schedule for this volume?

\n"); print("

Yes / NO DON'T DELETE ]

\n"); print("
\n"); print("

The following schedule exists for this volume. Click here to delete the schedule.

"); 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"); print("\n"); print("\n"); print("
Size in MBShare contents?Interval in hoursRotate countNext snapshot in...
" . $schedule_size[$schedule_index] . "" . (($schedule_share[$schedule_index] == "yes") ? "Yes, do" : "No, don't") . "" . $schedule_timemax[$schedule_index] . "" . $schedule_rotatemax[$schedule_index] . "" . $schedule_timecounter[$schedule_index] . " hours
\n"); print("
\n"); } else { print("

Scheduled snapshots are taken continuously with a time interval between sequential snapshots.
\n"); print("The time interval can be specified in hours below. The Rotate count field indicates how many
\n"); print("snapshots should be kept in rotation. After this count of snapshots are taken by the scheduler,
\n"); print("the oldest one is deleted when a newer snapshot is to be taken.

\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"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
Size in MBShare contents?Interval in hoursRotate countApply
\n"); print("
\n"); print("
\n"); } ?>

 


Take a snapshot

\n"); print("\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">
\n"); print("

 

\n"); nested_tab_end(); single_end(array()); generic_footer(array()); flock($flockp, LOCK_UN | LOCK_NB); fclose($flockp); ?>