Keepass and autofs

I am running xubuntu 24.04 and xfce 4.20.

What I am trying to do is set up keepassXC security to only work when my laptop is at my home and connected to my autofs mount. What I have is the pass code for the keepassXC stored on the automounted drive. So, ideally, at boot time, after login, keepassXC is launched and it’s database open.
I tried putting my keepass script in the .config/autostart folder. It works but, it runs before autofs does so the keepass database open fails.

Is there a way to run my script after the autofs mounts complete?

Thanks in advance.

Could have a script that run and checks the file system is mounted. You can check the existence of the database file in bash. If that exists then run the application…otherwise don’t launch the application

Unfortunately, its not a if then else situation. I need a script to run after autofs completes.

@makitso this is not my area of expertise but we want to try and help you find a solution.

Please also note that I am not able to test this to confirm whether it would work or not.

However, there are some options I can suggest:

  • Add a wait loop to your script so it only opens the KeePassXC database after the autofs-mounted file is available.
  • Force autofs to mount by accessing the mount path at the start of your script (e.g., ls /path/to/mount) before trying to open the database.
  • Alternatively, create a systemd user service that runs after login and waits for the required file before launching KeePassXC.

If you share your script here, we can review it and suggest the best way to make it work for your setup.

1 Like

OK, I think I have found a solution that works for me. I have a desktop file in .config/autostart that contains:

[Desktop Entry]
Version=1.0
Type=Application
Name=launcher
Comment=
Exec=/home/rob/Desktop/keepass2.sh &
# Exec=/home/rob/Desktop/test.sh 
Icon=applications-biology
Path=
Terminal=false
StartupNotify=false code here

The keepass2.sh script is:

#! /bin/bash
keepassxc /home/rob/user1/Passwords.kdbx --pw-stdin < /NAS/nfs-rob/password-file > /dev/null &

Have you tested it?

Is everything now working as expected/desired?

The scripts that I have seem to have solved my original problem - i.e. keepass authentication after autofs mount. In practice, when my wifes xubuntu laptop boots up, keepass is launched and authenticated. She opens Firefox and sites are now authenticated by the keepass plugin.