1

I've had my first dabble with bash and got a working script going for each user on session start which checks if a NAS share is mounted and if it is unmounts it and mounts as the current user. This works great but now I have a problem, on the first "Switch User" the script is executed as the session for the new user starts. Switching back however the drive is mounted as the previous user, running the script works so it appears that what works for the session start (.config/autostart) doesn't handle this user switching and I guess that makes sense.

Question is, how to run my little script again when a session restarts for each user after a "Switch User" happens?

  • Please explain on the first "Switch User" the script is executed as the session for the new user starts. Switching back however the drive is mounted as the previous user, running the script works a more broadly/clearly. Also add your script to the question. – heemayl Apr 10 '15 at 19:36
  • This sounds unnecessarily complicated. Can you not mount it rw for everybody? – glenn jackman Apr 10 '15 at 19:41
  • @heemayl Ok, So, I log in as user A, my .config/autostart shizzle runs and the NAS is mounted as User A. Then I switch to user B, again, .config/autostart for that user runs the script and the NAS is mounted as user B. Then I SWITCH BACK to user A, and the script IS NOT EXECUTED, the NAS is still mounted as user B. My script itself is irrelevent, I'm asking where to put a script or how to call a script when a "switch user" event happens. That clearer? – Tom Rhodes Apr 10 '15 at 19:43
  • @glenn jackman, ahah, yeah I could, but this NAS has a cool feature in that it gives a home directory to all users, other parts of it I mount for everyone. but Home is unique to different users so I'd like to just mount "NAS Home" for everyone based on who they are... – Tom Rhodes Apr 10 '15 at 19:44
  • 2
    You can still "automount", but each user has his own mountpoint. Then it doesn't matter if you switch users because A and B no longer clash. Unless your tools hardcode a single mountpoint, in which case you're screwed. – glenn jackman Apr 10 '15 at 19:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.