diff options
author | Jonathan Bauer | 2013-10-31 14:32:59 +0100 |
---|---|---|
committer | Jonathan Bauer | 2013-10-31 14:32:59 +0100 |
commit | 309ff04c3de66f383be359ff56b3d371f38272b3 (patch) | |
tree | c785fbb9d0e84a2cda52c2692fd4758785f95301 /scripts | |
parent | [vmware] deleted old named scripts (diff) | |
download | tm-scripts-309ff04c3de66f383be359ff56b3d371f38272b3.tar.gz tm-scripts-309ff04c3de66f383be359ff56b3d371f38272b3.tar.xz tm-scripts-309ff04c3de66f383be359ff56b3d371f38272b3.zip |
added pam session closing scripts with home directory unmounting. For reference only, do NOT use :)
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/pam_scripts_ses_close.ugly_ses_close | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/pam_scripts_ses_close.ugly_ses_close b/scripts/pam_scripts_ses_close.ugly_ses_close new file mode 100755 index 00000000..eedb40ed --- /dev/null +++ b/scripts/pam_scripts_ses_close.ugly_ses_close @@ -0,0 +1,19 @@ +#!/bin/bash + +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/bin:/opt/openslx/sbin:/opt/openslx/usr/bin:/opt/openslx/usr/sbin" + +[ ! -z "$SLX_DEBUG" ] && echo "[$PAM_TYPE] Closing session for $PAM_USER" + +# TODO check if its the last session of the user. + +OPENSESSIONS=$(loginctl|grep $PAM_USER|wc -l) + +echo "User $PAM_USER has $OPENSESSIONS open sessions." + +if [ "x$OPENSESSIONS" == "x1" ]; then + # assume its last session, start watchdog in background + echo "Last session beeing closed..." + ( while true; do sleep 1; if [ "x$(loginctl |grep $PAM_USER)" == "x" ]; then [ $(id -g $PAM_USER) -ge 1000 ] && umount /home/s8jobaue; fi; done) & +fi + +[ $(id -g $PAM_USER) -ge 1000 ] && umount /home/$PAM_USER |