Simple daemon for automounting usb drives. It creates a process that reads the output of
udevadm monitor --udev -s block
and if there is a device addition it just runs
udisksctl mount -b device_path
For starting the program at startup and stoping any time you can create a simple systemd service.
Inside the project's folder run
make
Create a symbolic link for the program in the /usr/bin folder
ln -s /home/$USER/path_to_project/bin/auto_mount /usr/bin/auto_mount
Also if you want you can create a link for the auto_mount_stop script for killing the daemon
ln -s /home/$USER/path_to_project/scipts/auto_mount_stop /usr/bin/auto_mount_stop
Inside /etc/systemd/system folder add a file auto_mount@.service and write into it
[Unit]
Description=Auto mount devices
[Service]
User=%I
Type=forking
ExecStart=/usr/bin/auto_mount
ExecStop=/usr/bin/auto_mount_stop
RemainAfterExit=no
[Install]
WantedBy=multi-user.target
You can enable the service with
sudo systemctl enable auto_mount@$USER
And whenever you want you can stop it with
sudo systemctl stop auto_mount@$USER