Posted on 05-15-2015 09:22 AM
Does anyone have the script (or any other way) to manually invoke the mounting of the home folder associated with a network user's home folder?
So we have User-Certificates for access to our in-house WiFi. Since its user-based, the wifi doesn't connect until the user is logged in, by that time the hook for mounting the home folder has past. We also have several home folder servers, so its not as simple as getting the user's username and adding it to a path.
Posted on 05-15-2015 09:34 AM
Hi,
Here's a link to our script on Github. If you want the user to initiate it, I would put it into an Applescript app for them to click on.
myhttps://github.com/amsysuk/public_scripts/blob/master/mount_SMBHome/mounthome.sh
Posted on 05-15-2015 09:40 AM
#!/usr/bin/perl -w
# config runtime environment
use strict;
use Sys::Syslog;
my $console = "/dev/console";
my $consoleuser = getpwuid((stat $console)[4]);
my $mtpt = "/Volumes/$consoleuser";
my $SMBHOME=`dscl "/Active Directory/YOURDOMAIN/All Domains" read Users/$consoleuser SMBHome`;
my $test = $mtpt;
my $count = 0;
(my $progname =$0) =~ s#.*/##;
$ENV{PATH} = '/bin:/usr/bin:/usr/sbin:/sbin';
umask 0022;
main:
openlog $progname, undef, 'user';
chomp($SMBHOME);
$SMBHOME =~ s#\#/#g;
$SMBHOME = (split ' ', $SMBHOME)[-1];
#look for the directory if it exists it could already be mounted or something else so try user+number
while ( -e $test) {
$count++;
$test = $mtpt . $count;
}
$mtpt = $test if ($count > 0);
syslog('notice', "making mount point %s", $mtpt);
system("mkdir "$mtpt"");
my $rc = system("mount_smbfs "$SMBHOME" "$mtpt"");
if ($rc) {
syslog('notice', "Mount failed removing directory %s", $mtpt);
system("rmdir $mtpt");
}
closelog;
Posted on 05-15-2015 09:41 AM
You could modify it to wait for a network to exist and ping the server before trying to mount as well. This is assuming they are on the right network
Posted on 05-20-2015 07:47 AM
Hey, thanks for the help!
I have to admit I'm not a strong scripter...and even less strong in pearl.
Todd, I tried your script and changed ERICSSON to our domain.
When I ran the script in the terminal I got a few errors:
line 4: use: command not found
line 5: use: command not found
line 7: my: command not found
line 8: syntax error near unexpected token `('
line 8: `my $consoleuser = getpwuid((stat $console) [4]);'
..and when I say 'less strong at pearl' I mean..never used it....
Posted on 05-20-2015 07:52 AM
i am guessing that the first line in your script is not
#!/usr/bin/perl -w
Posted on 05-20-2015 07:54 AM
sorry for the formatting mess on the last entry, that has been fixed.
Posted on 05-20-2015 07:55 AM
Not knowing Pearl I left the first line commented out as you posted it. Should the # be left out?
Posted on 05-20-2015 08:07 AM
All scripts need the hash and the exclamation point at the beginning of them to tell the shell what interpreter to run. So while it looks like a comment it is not