2022-10-21 15:56:22 +00:00
# usbmount 0.0.24 and/or 0.0.25 (2022-02-08) should be investigated:
# https://github.com/iiab/iiab/issues/3409
2021-03-25 20:02:39 +00:00
# Official usbmount 0.0.22 (2011-08-08) documentation:
# https://github.com/rbrito/usbmount/releases
# https://github.com/hfuchs/usbmount/blob/master/README (2010-08-11)
# https://github.com/rbrito/usbmount/blob/master/README.md (2018-08-10)
# https://github.com/rbrito/usbmount/blob/master/usbmount.conf (2010-04-25)
2025-01-26 05:42:32 +00:00
# usb_lib_writable_sticks (e.g., in /etc/iiab/local_vars.yml) must be set to true in order for non-root users to be able to write to VFAT/FAT32, NTFS and exFAT USB sticks.
# If you are still not able to write to a mounted USB stick, try unmounting the drive (sudo umount <mountpoint>) and then remount it setting umask to 0000 manually (sudo mount -o umask=0000 <device name> <mountpoint>).
2023-05-27 07:26:04 +00:00
2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2020-10-30 09:06:30 +00:00
- name : Does systemd-udevd.service exist
stat :
path : "{{ systemd_location }}/systemd-udevd.service"
register : udev_unit
- name : Copy udevd service to /etc/systemd/system to modify
copy :
src : "{{ systemd_location }}/systemd-udevd.service"
dest : /etc/systemd/system/systemd-udevd.service
owner : root
group : root
mode : 0644
when : udev_unit.stat.exists is defined and udev_unit.stat.exists
- name : Change MountFlags from slave to shared
lineinfile :
backup : no
dest : /etc/systemd/system/systemd-udevd.service
regexp : '^MountFlags'
line : 'MountFlags=shared'
state : present
when : udev_unit.stat.exists is defined and udev_unit.stat.exists
- name : Ask systemd to reread unit files (daemon-reload) and restart so systemd recognizes the changes
systemd :
daemon_reload : yes
name : systemd-udevd
state : restarted
when : udev_unit.stat.exists is defined and udev_unit.stat.exists
2022-03-31 17:55:32 +00:00
# http://raspbian.raspberrypi.org/raspbian/pool/main/u/usbmount/usbmount_0.0.22_all.deb
2025-01-25 22:37:22 +00:00
#- name: Install {{ iiab_download_url }}/usbmount_0.0.22_all.deb, no longer supported by {RasPiOS, Debian, Ubuntu}
# apt:
# deb: "{{ iiab_download_url }}/usbmount_0.0.22_all.deb"
# # when: is_debian
2020-08-25 16:06:26 +00:00
2025-01-30 09:19:31 +00:00
- name : Install lockfile-progs util-linux for usbmount from OS repo
package :
name :
2025-01-30 15:52:41 +00:00
- lockfile-progs
- util-linux
2025-01-30 09:19:31 +00:00
state : present
2020-08-25 16:06:26 +00:00
2025-01-29 11:00:07 +00:00
- name : Add dir {{ doc_root }}/local_content, where USB drive links can appear (0775) owned by {{ apache_user }}:{{ apache_user }}
2020-02-13 20:11:35 +00:00
file :
state : directory
path : "{{ doc_root }}/local_content"
owner : "{{ apache_user }}"
2020-02-13 22:11:04 +00:00
group : "{{ apache_user }}" # 2020-02-13: changed from iiab_admin_user, after discussion on weekly call (#1228, #2222)
2021-07-07 05:46:01 +00:00
mode : 0775
2020-02-13 20:11:35 +00:00
2025-01-30 20:07:51 +00:00
- name : Set up dirs /etc/usbmount/mount.d, /etc/usbmount/umount.d, /media/usb0-7
2025-01-25 20:53:50 +00:00
file :
path : "{{ item }}"
# owner: root
# group: root
# mode: '0755'
2025-01-25 22:37:22 +00:00
mode : 0644
2025-01-25 20:53:50 +00:00
state : directory
with_items :
- /etc/usbmount/mount.d
- /etc/usbmount/umount.d
2025-01-30 17:59:15 +00:00
- /media/usb0
- /media/usb1
- /media/usb2
- /media/usb3
- /media/usb4
- /media/usb5
- /media/usb6
- /media/usb7
2025-01-25 20:53:50 +00:00
2025-01-25 22:37:22 +00:00
- name: '2025-01-25 : Copy files from files/usbmount to filesystem'
copy :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
with_items :
- { src: 'usbmount/usbmount.conf', dest: '/etc/usbmount/', mode : '0644' }
- { src: 'usbmount/usbmount', dest: '/usr/local/sbin/', mode : '0755' }
2025-01-30 20:07:51 +00:00
- name: 'Install from template : /etc/udev/rules.d/usbmount.rules, /etc/systemd/system/usbmount@.service, /usr/sbin/iiab-clean-usb.sh'
2020-02-13 20:11:35 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
mode : "{{ item.mode }}"
with_items :
2020-02-13 22:11:04 +00:00
- { src: 'usbmount.rules.j2', dest: '/etc/udev/rules.d/usbmount.rules', mode : '0644' }
2021-07-28 02:36:07 +00:00
- { src: 'usbmount@.service.j2', dest: '/etc/systemd/system/usbmount@.service', mode : '0644' }
2025-01-25 23:05:03 +00:00
- { src: 'iiab-clean-usb.sh', dest: '/usr/local/sbin/', mode : '0755' }
2020-02-13 20:11:35 +00:00
2025-01-27 02:18:30 +00:00
- name: '2025-01-05 : Add upload2usb app (#3875) directory to doc_root'
2025-01-06 03:46:28 +00:00
file :
state : directory
2025-01-27 02:18:30 +00:00
path : "{{ doc_root }}/upload2usb"
2025-01-06 03:46:28 +00:00
owner : "{{ apache_user }}"
2025-01-25 20:53:50 +00:00
group : "{{ apache_user }}"
2025-01-06 03:46:28 +00:00
mode : 0755
2025-01-28 01:17:44 +00:00
- name: '2025-01-05 : Copy upload2usb app (#3875) files from files/upload/ into {{ doc_root }}/upload2usb/'
2025-01-06 00:12:24 +00:00
copy :
src : "{{ item }}"
2025-01-28 01:17:44 +00:00
dest : "{{ doc_root }}/upload2usb/" # /library/www/html
2025-01-06 00:12:24 +00:00
with_fileglob :
2025-01-08 10:45:00 +00:00
- upload/*
2025-01-06 00:12:24 +00:00
2021-03-21 19:27:00 +00:00
# 2021-03-21: If usbmount is repackaged by apt as a result of Linux kernel 5.4+
# supporting exFAT, the stanza below (might) in future no longer be needed...
2023-06-27 21:02:11 +00:00
# SEE ALSO: https://github.com/iiab/iiab/blob/586bfc5cb1abf6b4333a21d3fa89695f115432dc/roles/2-common/tasks/packages.yml#L11-L12
2025-01-25 22:37:22 +00:00
#- name: Add ' exfat fuseblk ntfs' to FILESYSTEMS var in /etc/usbmount/usbmount.conf
# lineinfile:
# regexp: '^FILESYSTEMS=.*'
# line: 'FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus exfat fuseblk ntfs"'
# path: /etc/usbmount/usbmount.conf
#- name: Remove /etc/usbmount/mount.d/00_create_model_symlink
# file:
# path: /etc/usbmount/mount.d/00_create_model_symlink
# state: absent
2021-04-28 16:08:38 +00:00
2020-02-13 20:11:35 +00:00
# RECORD 'USB_LIB' AS INSTALLED
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'usb_lib_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : usb_lib
option : usb_lib_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2020-02-13 20:11:35 +00:00
- name : "Set 'usb_lib_installed: True'"
set_fact :
usb_lib_installed : True
- name : "Add 'usb_lib_installed: True' to {{ iiab_state_file }}"
lineinfile :
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp : '^usb_lib_installed'
line: 'usb_lib_installed : True '