Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sysop-bioinformatics
management_scripts
Commits
b580e085
Commit
b580e085
authored
Aug 17, 2015
by
Haarst, Jan van
Browse files
Script to setup cluster accounts when logged in through AD
parent
f61f4c83
Changes
1
Hide whitespace changes
Inline
Side-by-side
before_first_login.sh
0 → 100644
View file @
b580e085
#!/bin/bash
# By jan.vanhaarst@wur.nl
## Script to create home directory and make sure the cluster knows where to find it.
## Installation :
## /etc/pam.d/password-auth:
## session optional pam_exec.so stdout seteuid /root/before_first_login.sh
# Quit on error
set
-o
errexit
if
[
$PAM_TYPE
==
'open_session'
]
then
# Variables
USER_NAME
=
${
PAM_USER
}
HOME_LOCATION
=
'/export/home/'
${
USER_NAME
}
PATH
=
$PATH
:/opt/rocks/bin:/sbin
HOMEDIRSRV
=
`
rocks list host attr
$(
hostname
-s
)
|
grep
Info_HomeDirSrv |
awk
'{print $3}'
`
HOMEDIRLOC
=
`
rocks list host attr
$(
hostname
-s
)
|
grep
Info_HomeDirLoc |
awk
'{print $3}'
`
# Check whether the home directory exists
if
[
$(
grep
-c
'^'
$USER_NAME
/etc/auto.home
)
==
0
]
then
# Create user entry in passwd file
WBINFO
=
$(
wbinfo
--user-info
$USER_NAME
)
if
[
$(
grep
-c
'^'
$USER_NAME
/etc/passwd
)
==
0
]
then
echo
"
$WBINFO
"
>>
/etc/passwd
fi
# Get user and group id's
read
USER_ID GROUP_ID
<<<
$(
echo
"
$WBINFO
"
|
awk
-F
':'
'{print $3 " " $4}'
)
# Fill home directory from /etc/skel
if
[
!
-d
$HOME_LOCATION
]
then
cp
-a
/etc/skel
$HOME_LOCATION
chown
-R
$USER_ID
:
$GROUP_ID
$HOME_LOCATION
fi
# Add user to auto.home and force automount to read it
if
[
$(
grep
-c
'^'
$USER_NAME
/etc/auto.home
)
==
0
]
then
echo
-e
"
$USER_NAME
\t
${
HOMEDIRSRV
}
:
${
HOMEDIRLOC
}
/
${
USER_NAME
}
"
>>
/etc/auto.home
/sbin/service autofs restart
fi
# Tell Rocks of the new user
rocks
sync users
>
/dev/null
fi
fi
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment