#!/usr/bin/perl

# Main
#
# This Perl mount a encrypted volume on OES (linux) using the virtual file services for NetWare on Linux.
#
{
  $file_nss = "+</_admin/Manage_NSS/manage.cmd";
  $reply;
  $command;

  $command = "<virtualIO><datastream name=\"command\"/></virtualIO>";
  open(NSSFILE, $file_nss) or die "Error opening NSS management file ($!) on server";
  print "file is now open \n";
  seek NSSFILE, 0, 0;
  syswrite(NSSFILE, $command, length($command)) or die "Error writing initialization to management file.";

  $command = "<nssRequest><volume><modifyState><volumeName>TEST</volumeName><volumeState>mounted</volumeState><volumePassword>huhu1234</volumePassword></modifyState></volume></nssRequest>";
  seek NSSFILE, 0, 0;
  syswrite(NSSFILE, $command, length($command)) or die "Error writing mount-command to management file.";
  seek NSSFILE, 0, 0;
  sysread (NSSFILE, $reply, 10000);
  print $reply;
  print "\n\n";

  close (NSSFILE);
}

