Re: [Samba] Dynamic Home Shares

2009-04-08 Thread Ken Lupo
That will work for my dynamic creation. Does anyone know why the %U variable
returns username + underscore(username_) instead of just username?

On Wed, Apr 8, 2009 at 2:27 PM, Brian Gregorcy wrote:

> Here is the script that we use to create the home directory when the user
> first logs in.
>
>
>
>  humboldt samba # cat mkhomedir.sh
>> #!/bin/bash
>> # Creates home directories when account is created
>> # gregorcy
>> # Created: 03/21/2008
>> # Last Mod: 06/10/2008 - Added the if for is fac and cleanup
>> ###
>> #
>> # Variables
>> hostname=`hostname`
>> blessed="The permissions have been fixed "
>> subject1="does not have valid email in our LDAP"
>> subject2="A user is missing their homedir on  $hostname the home dir has
>> been created but the old homedirs should be checked for data"
>> emailto="supp...@che.utah.edu"
>> emailmes="/tmp/emailmessage.txt"
>> ldapmail=`ldapsearch -D "cn=***,ou=***,dc=*,dc=utah,dc=edu" -b
>> "ou=***,dc=***,dc=utah,dc=edu" -w * -x -LLL "(sAMAccountName=$1)" mail |
>> grep mail | sed 's/..//'`
>> ldapfac=`ldapsearch -D "cn=***,ou=***,dc=,dc=utah,dc=edu" -b
>> "ou=***,dc=***,dc=utah,dc=edu" -w * -x -LLL "(sAMAccountName=$1)"
>> memberof >> /tmp/testfac`
>>
>>
>>
>>
>> grep -q Faculty /tmp/testfac isfac=$?
>> echo $isfac
>>
>> # functionville
>> function createbless () {
>>touch /home/CHEMENG/$1/.blessed
>>echo "$blessed" >> /home/CHEMENG/$1/.blessed
>>#chown root:root /home/CHEMENG/$1/.blessed
>>chmod 700 /home/CHEMENG/$1/.blessed
>> }
>>
>>
>>
>> # scriptage
>> if [ ! -e /home/CHEMENG/$1 ]; thenecho "The home dir for "$1 "was
>> not found probably was not migrated "> $emailmes
>>mkdir /home/CHEMENG/$1echo "Created the home directory but
>> should check trashheap or CHE-2551-30 for old stuff" >> $emailmes
>>mail -s "$subject2" supp...@***.utah.edu < $emailmes
>>rm -r $emailmes
>> fi
>>
>> if [ ! -e /home/CHEMENG/$1/.blessed ]; then
>>mkdir /home/CHEMENG/$1
>>if [ $isfac = 0 ]; then
>>xfs_quota -x -c "limit bsoft=61440M bhard=63000M
>> $1" /home
>>fi
>>
>>
>>if [ $isfac != 0 ]; thenxfs_quota
>> -x -c "limit bsoft=3072M bhard=3200M $1" /home
>>fi
>>#cp -r /etc/skel/* /home/CHEMENG/$1/*
>>chown "$1:CHEMENG+Domain Users" /home/CHEMENG/$1
>>chmod -R 711 /home/CHEMENG/$1
>>if [ -z $ldapmail ]; then
>>echo "Add the attribute mail to the user $1">
>> $emailmes
>>echo "then manually :( create the .forward in
>> /home/CHEMENG/$1" >> $emailmes
>>echo "Or add the email attribute to the AD and
>> delete the .blessed file " >> $emailmes
>>mail -s "$1 $subject1"  supp...@***.utah.edu  <
>> $emailmes
>>rm -r $emailmes
>>createbless $1
>>exit 0
>>fi
>>touch /home/CHEMENG/$1/.forward
>>echo "$ldapmail" >> /home/CHEMENG/$1/.forward
>>#chown root:root /home/CHEMENG/$1/.forward
>>chmod 700 /home/CHEMENG/$1/.forward
>>createbless $1
>># mod the public_html folder so apache can see it
>>chown -R "$1:apache" /home/CHEMENG/$1/public_html
>>chmod -R 751 /home/CHEMENG/$1/public_html
>>chmod -R g+s /home/CHEMENG/$1/public_html
>>
>>
>> fi
>>
>> # Clean Up
>> rm /tmp/testfac
>>
>> exit 0
>>
>>
>> # Notes
>> # Basic premise for the .forward add
>> # touch /home/CHEMENG/$1/foo.txt
>> # echo "grego...@***.utah.edu" >> /home/CHEMENG/$1/foo.txt
>>
>> # LDAP Search String
>> # ldapsearch -D "cn=***,ou=,dc=*,dc=utah,dc=edu" -b
>> "ou=*8,dc=,dc=utah,dc=edu" -w  -x -LLL
>> "(sAMAccountName=)" mail | grep mail
>> # Output looks like this:
>> # mail: j...@***.utah.edu
>>
>
>
> Adam Williams wrote:
>
>> see root preexec = in the man page.  so when they go to %U$ (such as using
>> logon home = z: ) it will run a script that creates the required directory
>> in /home/pc/
>>
>> Ken Lupo wrote:
>>
>>> Hello,
>>>
>>> I am attempting to dynamically create user shares when they connect to
>>> the
>>> server based on their username. I cannot use [homes]. My reasoning for
>>> this
>>> is that the users require a $ at the end of the share or it becomes
>>> confusing to them(long story). What I'm seeing is that some Windows XP
>>> clients will connect to /home/ but other clients try to connect
>>> to
>>> /home/_ (with an underscore). For a work around I have
>>> symlinked
>>> all home folders from  to _
>>>
>>> Here is my smb.conf file:
>>>
>>> [global]
>>>workgroup = PC
>>>realm = PC.DOMAIN.COM
>>>server string = FILE
>>>security = ADS
>>>log file = /var/log/samba/%m.log
>>>   

Re: [Samba] Dynamic Home Shares

2009-04-08 Thread Brian Gregorcy

Here is the script that we use to create the home directory when the user first 
logs in.




humboldt samba # cat mkhomedir.sh
#!/bin/bash
# Creates home directories when account is created
# gregorcy
# Created: 03/21/2008
# Last Mod: 06/10/2008 - Added the if for is fac and cleanup
###
#
# Variables
hostname=`hostname`
blessed="The permissions have been fixed "
subject1="does not have valid email in our LDAP"
subject2="A user is missing their homedir on  $hostname the home dir has been 
created but the old homedirs should be checked for data"
emailto="supp...@che.utah.edu"
emailmes="/tmp/emailmessage.txt"
ldapmail=`ldapsearch -D "cn=***,ou=***,dc=*,dc=utah,dc=edu" -b 
"ou=***,dc=***,dc=utah,dc=edu" -w * -x -LLL "(sAMAccountName=$1)" mail | grep mail | 
sed 's/..//'`
ldapfac=`ldapsearch -D "cn=***,ou=***,dc=,dc=utah,dc=edu" -b "ou=***,dc=***,dc=utah,dc=edu" 
-w * -x -LLL "(sAMAccountName=$1)" memberof >> /tmp/testfac`




grep -q Faculty /tmp/testfac 
isfac=$?

echo $isfac

# functionville
function createbless () {
touch /home/CHEMENG/$1/.blessed
echo "$blessed" >> /home/CHEMENG/$1/.blessed
#chown root:root /home/CHEMENG/$1/.blessed
chmod 700 /home/CHEMENG/$1/.blessed
}



# scriptage
if [ ! -e /home/CHEMENG/$1 ]; then 
	echo "The home dir for "$1 "was not found probably was not migrated "> $emailmes
	mkdir /home/CHEMENG/$1 
	echo "Created the home directory but should check trashheap or CHE-2551-30 for old stuff" >> $emailmes

mail -s "$subject2" supp...@***.utah.edu < $emailmes
rm -r $emailmes
fi

if [ ! -e /home/CHEMENG/$1/.blessed ]; then
mkdir /home/CHEMENG/$1
if [ $isfac = 0 ]; then
xfs_quota -x -c "limit bsoft=61440M bhard=63000M $1" 
/home
fi


		if [ $isfac != 0 ]; then 
			xfs_quota -x -c "limit bsoft=3072M bhard=3200M $1" /home

fi
	#cp -r /etc/skel/* /home/CHEMENG/$1/* 
	

chown "$1:CHEMENG+Domain Users" /home/CHEMENG/$1
chmod -R 711 /home/CHEMENG/$1   
if [ -z $ldapmail ]; then   
echo "Add the attribute mail to the user $1"> $emailmes
echo "then manually :( create the .forward in 
/home/CHEMENG/$1" >> $emailmes
echo "Or add the email attribute to the AD and delete the .blessed 
file " >> $emailmes
mail -s "$1 $subject1"  supp...@***.utah.edu  < 
$emailmes
rm -r $emailmes
createbless $1
exit 0
fi
touch /home/CHEMENG/$1/.forward
echo "$ldapmail" >> /home/CHEMENG/$1/.forward
#chown root:root /home/CHEMENG/$1/.forward
chmod 700 /home/CHEMENG/$1/.forward
createbless $1
# mod the public_html folder so apache can see it
chown -R "$1:apache" /home/CHEMENG/$1/public_html
chmod -R 751 /home/CHEMENG/$1/public_html
chmod -R g+s /home/CHEMENG/$1/public_html


fi  

# Clean Up
rm /tmp/testfac

exit 0


# Notes
# Basic premise for the .forward add
# touch /home/CHEMENG/$1/foo.txt
# echo "grego...@***.utah.edu" >> /home/CHEMENG/$1/foo.txt

# LDAP Search String
# ldapsearch -D "cn=***,ou=,dc=*,dc=utah,dc=edu" -b 
"ou=*8,dc=,dc=utah,dc=edu" -w  -x -LLL 
"(sAMAccountName=)" mail | grep mail
# Output looks like this:
# mail: j...@***.utah.edu



Adam Williams wrote:
see root preexec = in the man page.  so when they go to %U$ (such as 
using logon home = z: ) it will run a script that creates the required 
directory in /home/pc/


Ken Lupo wrote:

Hello,

I am attempting to dynamically create user shares when they connect to the
server based on their username. I cannot use [homes]. My reasoning for this
is that the users require a $ at the end of the share or it becomes
confusing to them(long story). What I'm seeing is that some Windows XP
clients will connect to /home/ but other clients try to connect to
/home/_ (with an underscore). For a work around I have symlinked
all home folders from  to _

Here is my smb.conf file:

[global]
workgroup = PC
realm = PC.DOMAIN.COM
server string = FILE
security = ADS
log file = /var/log/samba/%m.log
local master = No
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
winbind use default domain = Yes
winbind offline logon = false
store dos attributes = Yes
ea support = Yes
dns proxy = no
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192
SO_RCVBUF=8192 SO_KEEPALIVE
inherit acls = yes
inherit permissions = yes
map acl inherit = yes

[%U$]
path = /home/PC/%U
comment = Homes
read only = No


Any help would be greatly appreicated.

Thank you,
Ken
  

--
To

Re: [Samba] Dynamic Home Shares

2009-04-08 Thread Ken Lupo
On Wed, Apr 8, 2009 at 2:13 PM, Adam Williams wrote:

> see root preexec = in the man page.  so when they go to %U$ (such as using
> logon home = z: ) it will run a script that creates the required directory
> in /home/pc/
>
>
> Ken Lupo wrote:
>
>> Hello,
>>
>> I am attempting to dynamically create user shares when they connect to the
>> server based on their username. I cannot use [homes]. My reasoning for
>> this
>> is that the users require a $ at the end of the share or it becomes
>> confusing to them(long story). What I'm seeing is that some Windows XP
>> clients will connect to /home/ but other clients try to connect
>> to
>> /home/_ (with an underscore). For a work around I have symlinked
>> all home folders from  to _
>>
>> Here is my smb.conf file:
>>
>> [global]
>>workgroup = PC
>>realm = PC.DOMAIN.COM
>>server string = FILE
>>security = ADS
>>log file = /var/log/samba/%m.log
>>local master = No
>>idmap uid = 16777216-33554431
>>idmap gid = 16777216-33554431
>>winbind use default domain = Yes
>>winbind offline logon = false
>>store dos attributes = Yes
>>ea support = Yes
>>dns proxy = no
>>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192
>> SO_RCVBUF=8192 SO_KEEPALIVE
>>inherit acls = yes
>>inherit permissions = yes
>>map acl inherit = yes
>>
>> [%U$]
>>path = /home/PC/%U
>>comment = Homes
>>read only = No
>>
>>
>> Any help would be greatly appreicated.
>>
>> Thank you,
>> Ken
>>
>>
> That will work for my dynamic creation. Does anyone know why the %U
variable returns username + undeerscore(username_)?
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


Re: [Samba] Dynamic Home Shares

2009-04-08 Thread Adam Williams
see root preexec = in the man page.  so when they go to %U$ (such as 
using logon home = z: ) it will run a script that creates the required 
directory in /home/pc/


Ken Lupo wrote:

Hello,

I am attempting to dynamically create user shares when they connect to the
server based on their username. I cannot use [homes]. My reasoning for this
is that the users require a $ at the end of the share or it becomes
confusing to them(long story). What I'm seeing is that some Windows XP
clients will connect to /home/ but other clients try to connect to
/home/_ (with an underscore). For a work around I have symlinked
all home folders from  to _

Here is my smb.conf file:

[global]
workgroup = PC
realm = PC.DOMAIN.COM
server string = FILE
security = ADS
log file = /var/log/samba/%m.log
local master = No
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
winbind use default domain = Yes
winbind offline logon = false
store dos attributes = Yes
ea support = Yes
dns proxy = no
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192
SO_RCVBUF=8192 SO_KEEPALIVE
inherit acls = yes
inherit permissions = yes
map acl inherit = yes

[%U$]
path = /home/PC/%U
comment = Homes
read only = No


Any help would be greatly appreicated.

Thank you,
Ken
  

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


[Samba] Dynamic Home Shares

2009-04-08 Thread Ken Lupo
Hello,

I am attempting to dynamically create user shares when they connect to the
server based on their username. I cannot use [homes]. My reasoning for this
is that the users require a $ at the end of the share or it becomes
confusing to them(long story). What I'm seeing is that some Windows XP
clients will connect to /home/ but other clients try to connect to
/home/_ (with an underscore). For a work around I have symlinked
all home folders from  to _

Here is my smb.conf file:

[global]
workgroup = PC
realm = PC.DOMAIN.COM
server string = FILE
security = ADS
log file = /var/log/samba/%m.log
local master = No
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
winbind use default domain = Yes
winbind offline logon = false
store dos attributes = Yes
ea support = Yes
dns proxy = no
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192
SO_RCVBUF=8192 SO_KEEPALIVE
inherit acls = yes
inherit permissions = yes
map acl inherit = yes

[%U$]
path = /home/PC/%U
comment = Homes
read only = No


Any help would be greatly appreicated.

Thank you,
Ken
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba