-1

I was able to get a windows share to mount when users ssh into our server in a sub-dir in ~. I now want it so that when they disconnect, the mount unmounts. I added this to /etc/bash.bashrc but it doesn't seem to work.

finish() {
    sudo /usr/local/bin/disconnect_mount.sh
}

trap finish EXIT

In the shell script I have this:

if ["$PAM_TYPE" = "close_session" ]; then
        sudo umount ~/D
fi
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
TL_Arwen
  • 21
  • 1
  • 6

1 Answers1

0

Created this script:

    #!/bin/sh

sudo umount ~/D

Then in /etc/bash.bashrc:

#Disconnect mount on session close
finish() {
 sudo /etc/bash.bash_logout
}
trap finish SIGHUP

And in /etc/sudoers:

ALL     ALL=(root) NOPASSWD: /usr/local/bin/disconnect_mount.sh
TL_Arwen
  • 21
  • 1
  • 6