Tuesday, December 11, 2018

Configure automount for usb drives using UDISK-GLUE and SUPERVISOR

#
#*******************************************************************************
# RASPBERRY PI 2 MODEL B ON DEBIAN STRETCH 9.6
#*******************************************************************************
#
# /etc/os-release
#
root@raspime:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
root@raspime:~# apt-get install udisks-glue policykit-1 supervisor


#
#*******************************************************************************
# UDISK-GLUE
#*******************************************************************************
#
# /etc/udisks-glue.conf
#
root@raspime:~# cat /etc/udisks-glue.conf
filter disks {
    optical = false
    partition_table = false
    usage = filesystem
}

match disks {
           automount = true
          # For NTFS mount with read and write
           automount_options = { sync, noatime, 'dmask=0000', 'fmask=0000', 'umask=0000' }
           post_mount_command = "mount-notify mounted %device_file %mount_point"
           post_unmount_command = "mount-notify unmounted %device_file %mount_point"
}


#
#*******************************************************************************
# SUPERVISOR
#*******************************************************************************
#
# /etc/supervisor/supervisord.conf
#
root@raspime:~# cat /etc/supervisor/supervisord.conf
[unix_http_server]

[supervisord]

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]

[include]
files = /etc/supervisor/conf.d/*.conf
[inet_http_server]

# For web accesses
port=*:9001
username=admin
password=admin

#
# /etc/supervisor/conf.d/udisks-glue.conf
#
root@raspime:~# cat /etc/supervisor/conf.d/udisks-glue.conf
[program:udisks-glue]
user = root
command = udisks-glue -f
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/udisks-glue-out.log
stderr_logfile = /var/log/supervisor/udisks-glue-err.log


root@raspime:~# ls -al /etc/supervisor/conf.d/
total 16
drwxr-xr-x 2 root root 4096 Dec  6 20:15 .
drwxr-xr-x 3 root root 4096 Dec  6 13:29 ..
-rw-r--r-- 1 root root  209 Dec  6 14:25 udisks-glue.conf

Restart service after create configuration file
root@raspime:~# /etc/init.d/supervisor restart
[ ok ] Restarting supervisor (via systemctl): supervisor.service.

Check if udisk-glue process from supervisor running or not
root@raspime:~# supervisorctl
udisks-glue                      RUNNING   pid 10260, uptime 0:01:45
supervisor>
* Type quit for quit

OR check via web

No comments: