Changeset 45ed8ee for fedkit


Ignore:
Timestamp:
Sep 26, 2007 7:50:14 PM (17 years ago)
Author:
John Hickey <jhickey@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
30184e4
Parents:
5f1cd41
Message:

Updated to use automounter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/smbmount.pl

    r5f1cd41 r45ed8ee  
    11#!/usr/local/bin/perl
    2 use IO::Handle;
    32
     3#############################################################################
     4# smbmounts.pl: Setup Automounter to mount via SMB for federated experiments
     5# $Id: smbmount.pl,v 1.3 2007-09-27 02:50:14 jhickey Exp $
     6#
     7
     8$ADDR="users.isi.deterlab.net";
    49$TMCC="/usr/local/etc/emulab/tmcc";
    5 $SHARE=shift || "USERS";
    6 $PUSER=shift || "jhickey";
    7 $ADDR=shift || `cat /usr/local/etc/emulab/bossnode`;
     10$SHARE="USERS";
     11$FSTAB="/etc/fstab";
     12$HOMEROOT="/users";
     13$AMDROOT="/auto";
     14$AMDMAP="/etc/amd.users";
    815
    9 chomp $ADDR;
    10 print $ADDR;
     16$UMOUNT="/sbin/umount";
     17$MOUNT="/sbin/mount";
     18$MKDIR="/bin/mkdir";
     19$CP="/bin/cp";
     20$KILLALL="/usr/bin/killall";
     21$AMD="/usr/sbin/amd";
    1122
    12 #
    13 # Do SMB Mounts
    14 #
    15 #system("umount -A -f -t nfs,smbfs"); # or die("Failed to unmount NFS");
     23print "Killing amd.\n";
     24system("$KILLALL amd");
    1625
    17 open(TM, "$TMCC -s $ADDR accounts windows |") or die("Failed to execute TMCC");
     26print "Unmounting all nfs and smb filesystems.\n";
     27system("$UMOUNT -A -f -t nfs,smbfs"); # or die("Failed to unmount NFS");
    1828
    19 # create a smb config to set  autoflush for smb config
     29# Backup the fstab so we can run multiple times
     30if (! -f "$FSTAB.bak") {
     31        system("$CP $FSTAB $FSTAB.bak") && die("Unable to backup $FSTAB");
     32} else {
     33        system("$CP $FSTAB.bak $FSTAB") && die("Unable to restore $FSTAB");
     34}
     35
     36open(TM, "$TMCC accounts windows |") or die("Failed to execute TMCC");
    2037open(CONFIG, ">/etc/nsmb.conf") or die("Failed to open /etc/nsmb.conf");
    21 CONFIG->autoflush(1);
     38open(MAP, ">$AMDMAP") or die("Failed to open /etc/amd.users");
     39open(FSTAB,">>$FSTAB") or die("Cannot Open File $FSTAB");
    2240
     41print FSTAB "\n# SMB Configuration Generated by smbmount.pl\n";
     42print MAP "# AMD Configuration Generated by smbmount.pl\n";
     43print CONFIG "# SMB Configuration Generated by smbmount.pl\n\n";
    2344print CONFIG "[$SHARE]\naddr=$ADDR\n\n";
    2445
     
    3152                $homedir = $5;
    3253
    33                 $user =~  tr/a-z/A-Z/;
    34                 my $pass = `smbutil crypt '$pswd'`;
     54                $userlc = $user;
     55                # SMB demands upper case.
     56                $user =~  tr/a-z/A-Z/;
     57                my $pass = `smbutil crypt '$pswd'`;
    3558
    3659                print CONFIG "[$SHARE:$user]\npassword=$pass\n";
    37                 print "mount_smbfs -N -f 744 -d 755 -u $uid -g $gid //$user\@$SHARE/$user $homedir\n";
    38                 system("mount_smbfs -N -f 744 -d 755 -u $uid -g $gid //$user\@$SHARE/$user $homedir");
     60               
     61                if(! -d "$AMDROOT$homedir") {
     62                        system("$MKDIR -p $AMDROOT$homedir") && die("Failed to make directory");
     63                }
    3964
    40                 if($user =~ m/$PUSER/i) {
    41                         print "mount_smbfs -N -f 774 -d 755 -u $uid -g $gid //$user\@$SHARE/share /share\n";
    42                         system("mount_smbfs -N -f 774 -d 755 -u $uid -g $gid //$user\@$SHARE/share /share");
    43                         open(MOUNTS, "$TMCC -s $ADDR mounts |") or die("Failed to execute TMCC");
    44                         while(<MOUNTS>) {
    45                                 if(/LOCAL=\/proj\/(\S+)/) {
    46                                         print "mount_smbfs -N -f 774 -d 755 -u $uid -g $gid //$user\@$SHARE/proj-$1 /proj/$1\n";
    47                                         system("mount_smbfs -N -f 774 -d 755 -u $uid -g $gid //$user\@$SHARE/proj-$1 /proj/$1");
    48                                 }
    49                         }
    50                 }
     65                print FSTAB "//$user\@$SHARE/$user\t";
     66                print FSTAB "$AMDROOT$homedir\tsmbfs\t";
     67                print FSTAB "noauto,rw,-N,-f744,-d755,-u$uid,-g$gid\t0\t0\n";
     68
     69                print MAP "\n$userlc type:=program;fs:=$AMDROOT$homedir;\\\n";
     70                print MAP "mount:=\"$MOUNT mount $AMDROOT$homedir\";\\\n";
     71                print MAP "unmount:=\"$UMOUNT unmount $AMDROOT$homedir\";";
    5172        }
    5273}
    5374
    5475close(CONFIG);
     76close(FSTAB);
     77close(MAP);
    5578
     79print "Starting the automounter: $AMD -l syslog -a $AMDROOT $HOMEROOT $AMDMAP\n";
     80system("$AMD -l syslog -a $AMDROOT $HOMEROOT $AMDMAP") && die("Unable to start amd");
Note: See TracChangeset for help on using the changeset viewer.