A simple Bash script that implements a custom shell with automount and auto-unmount functionality. Whenever the user accesses a directory specified in a configuration file, the script mounts it automatically if not already mounted. After a configurable lifetime and no active usage, the script will unmount it.
- Custom prompt:
amsh> - Internal
cdcommand that:- Detects if the target directory is a special “mountpoint” from the config file.
- Executes
mount(or other mount commands likesshfs,tmpfs, etc.) if needed.
- External commands are invoked via
sh -c; the shell detects any paths that might need automount. - Auto-unmount after
lifetimeseconds, if no process is using that directory (checked vialsof +D).
- amsh.sh
The main script:- Reads the config file (
amsh_fstab.conf). - Displays the
amsh>prompt. - Implements the logic for auto-mount and auto-unmount.
- Reads the config file (
- amsh_fstab.conf
Defines the special directories:<source> <mountpoint> <filesystem_type> <lifetime_in_seconds>