summaryrefslogtreecommitdiffstats
path: root/roles/ands_kitauth/files/scripts/login_script.sh
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ands_kitauth/files/scripts/login_script.sh')
-rwxr-xr-xroles/ands_kitauth/files/scripts/login_script.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/roles/ands_kitauth/files/scripts/login_script.sh b/roles/ands_kitauth/files/scripts/login_script.sh
new file mode 100755
index 0000000..9b66968
--- /dev/null
+++ b/roles/ands_kitauth/files/scripts/login_script.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+# Script to authomatecly create user home directories
+# Shall we consider creating both NFS and local homes? Or shall we just create it on NFS?
+
+LOG=/var/log/login_script
+DATE=`/bin/date +"%b %d %H:%M:%S"`
+
+if [ x${PAM_TYPE} == "xopen_session" ]; then set $(getent passwd $PAM_USER | awk -F ":" '{print $3" "$4" "$5" "$6}')
+ USERUID=$1; USERGID=$2; USERHOME=$4
+
+ echo "[$DATE]: login of $PAM_USER: UID=$USERUID: GID=$USERGID: HOME=$USERHOME: from $PAM_RHOST via $PAM_SERVICE" >> $LOG
+
+ if [ ! -z "${USERHOME}" -a ! -d ${USERHOME} ]; then
+ #if [ ! -d /home/${USERHOME} ]; then
+ echo " Home for user ${USERNAME} does not exist at ${USERHOME} => creating" >> $LOG
+
+ mkdir -p $USERHOME
+ cp -af /etc/skel/.[a-zA-Z]* $USERHOME
+ chown -R $USERUID.$USERGID $USERHOME
+ chmod 701 $USERHOME
+ chmod g+s $USERHOME
+ fi
+fi
+if [ x${PAM_TYPE} == "xclose_session" ]; then
+ echo "[$DATE]: logout of $PAM_USER $USERUID" >> $LOG
+fi