5 my $slicename=$ARGV[0];
6 my $already_mounted_testfile = "/tmp/$slicename"."_nfsmounted";
8 my $slice_dir="/vservers/$slicename/";
10 if (-f $already_mounted_testfile) {
11 die("Sorry, only one successful NFS mount allowed per slice!");
14 my $remotepath = <STDIN>;
15 my $localpath = <STDIN>;
18 $localpath=~s/\.\.//g;
20 $localpath=$slice_dir.$localpath;
22 unless (-d $localpath) {
23 die("Localpath does not exist, please create it first.");
26 my $hostexpr="(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)";
27 my $pathexpr="\/?[\w\d]+\/[\w\d]*\/?";
31 ($nfshost,$nfspath)=split ':',$remotepath;
33 if ($nfshost!~/(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)/) {
34 die("The hostname $nfshost does not seem to be right.");
37 if ($nfspath!~/^(((\.\.){1}\/)*|(\/){1})?(([a-zA-Z0-9]*)\/)*([a-zA-Z0-9]*)+$/) {
38 die("The remote path $nfspath does not seem to be right.");
41 my $mntcmd="/bin/mount $remotepath $localpath";
45 print "Mount failed: $?";
48 open FIL, ">$already_mounted_testfile";
49 print FIL "$remotepath $localpath";