项目作者: iparaskev

项目描述 :
Simple daemon for automounting usb drives.
高级语言: C
项目地址: git://github.com/iparaskev/auto_mount.git
创建时间: 2018-12-24T22:52:15Z
项目社区:https://github.com/iparaskev/auto_mount

开源协议:

下载


auto_mount

Simple daemon for automounting usb drives. It creates a process that reads the output of

  1. udevadm monitor --udev -s block

and if there is a device addition it just runs

  1. udisksctl mount -b device_path

Create a systemd unit

For starting the program at startup and stoping any time you can create a simple systemd service.

Step 1: compile

Inside the project’s folder run

  1. make

Create a symbolic link for the program in the /usr/bin folder

  1. 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

  1. ln -s /home/$USER/path_to_project/scipts/auto_mount_stop /usr/bin/auto_mount_stop

Step 3: create the service file

Inside /etc/systemd/system folder add a file auto_mount@.service and write into it

  1. [Unit]
  2. Description=Auto mount devices
  3. [Service]
  4. User=%I
  5. Type=forking
  6. ExecStart=/usr/bin/auto_mount
  7. ExecStop=/usr/bin/auto_mount_stop
  8. RemainAfterExit=no
  9. [Install]
  10. WantedBy=multi-user.target

Step 4: enable the service

You can enable the service with

  1. sudo systemctl enable auto_mount@$USER

And whenever you want you can stop it with

  1. sudo systemctl stop auto_mount@$USER