Trying to repair dfferences b/w the merge
authorSapan Bhatia <sapanb@cs.princeton.edu>
Thu, 19 Mar 2009 18:54:01 +0000 (18:54 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Thu, 19 Mar 2009 18:54:01 +0000 (18:54 +0000)
nfsmount [new file with mode: 0755]

diff --git a/nfsmount b/nfsmount
new file mode 100755 (executable)
index 0000000..04115dc
--- /dev/null
+++ b/nfsmount
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $slicename=$ARGV[0];
+my $already_mounted_testfile = "/tmp/$slicename"."_nfsmounted";
+
+my $slice_dir="/vservers/$slicename/";
+
+if (-f $already_mounted_testfile) {
+       die("Sorry, only one successful NFS mount allowed per slice!");
+}
+
+my $remotepath = <STDIN>;
+my $localpath = <STDIN>;
+chomp($localpath);
+chomp($remotepath);
+$localpath=~s/\.\.//g;
+
+$localpath=$slice_dir.$localpath;
+
+unless (-d $localpath) {
+       die("Localpath does not exist, please create it first.");
+}
+
+my $hostexpr="(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)";
+my $pathexpr="\/?[\w\d]+\/[\w\d]*\/?";
+my $nfshost;
+my $nfspath;
+
+($nfshost,$nfspath)=split ':',$remotepath;
+
+if ($nfshost!~/(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)/) {
+       die("The hostname $nfshost does not seem to be right.");
+}
+
+if ($nfspath!~/^(((\.\.){1}\/)*|(\/){1})?(([a-zA-Z0-9]*)\/)*([a-zA-Z0-9]*)+$/) {
+       die("The remote path $nfspath does not seem to be right.");
+} 
+
+my $mntcmd="/bin/mount $remotepath $localpath";
+system($mntcmd);
+
+if ($?) {
+    print "Mount failed: $?";
+}
+else {
+    open FIL, ">$already_mounted_testfile";
+    print FIL "$remotepath $localpath";
+    close FIL;
+}