mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
Merge branch 'umnt3' of https://github.com/jvonau/iiab into jerry
This commit is contained in:
commit
728704b250
3 changed files with 35 additions and 14 deletions
|
@ -18,7 +18,7 @@ function getTargetUSBDriveLocation () {
|
||||||
// lsblk --output NAME,TRAN,RM,MOUNTPOINT --pairs |grep RM=\"1\" | grep -v MOUNTPOINT=\"\" | cut -d " " -f 4 | cut -d "=" -f 2
|
// lsblk --output NAME,TRAN,RM,MOUNTPOINT --pairs |grep RM=\"1\" | grep -v MOUNTPOINT=\"\" | cut -d " " -f 4 | cut -d "=" -f 2
|
||||||
|
|
||||||
# error if 1<>usb sticks are installed
|
# error if 1<>usb sticks are installed
|
||||||
$rmv_usb_path_count = shell_exec('lsblk --output NAME,TRAN,RM,MOUNTPOINT --pairs |grep RM=\"1\" | grep -v MOUNTPOINT=\"\" | cut -d " " -f 4 | wc -l');
|
$rmv_usb_path_count = shell_exec('lsblk --output NAME,TRAN,RM,MOUNTPOINT --pairs |grep RM=\"1\" | grep -v MOUNTPOINT=\"\" | cut -d " " -f 4 | grep media | wc -l');
|
||||||
if ($rmv_usb_path_count == 0) {
|
if ($rmv_usb_path_count == 0) {
|
||||||
throw new RuntimeException('0 USB sticks found. <br/><br/>');
|
throw new RuntimeException('0 USB sticks found. <br/><br/>');
|
||||||
} elseif ($rmv_usb_path_count > 1) {
|
} elseif ($rmv_usb_path_count > 1) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
# PARTICULAR PURPOSE.
|
# PARTICULAR PURPOSE.
|
||||||
# https://github.com/iiab/iiab/blob/master/roles/usb_lib/files/usbmount/copyright
|
# https://github.com/iiab/iiab/blob/master/roles/usb_lib/files/usbmount/copyright
|
||||||
# https://github.com/rbrito/usbmount/blob/master/debian/copyright
|
# https://github.com/rbrito/usbmount/blob/master/debian/copyright
|
||||||
set -e
|
#set -e
|
||||||
exec > /dev/null 2>&1
|
exec > /dev/null 2>&1
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -96,22 +96,43 @@ if [ "$1" = add ]; then
|
||||||
USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
||||||
|
|
||||||
if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then
|
if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then
|
||||||
log info "$DEVNAME does not contain a filesystem or disklabel"
|
log debug "/$DEVNAME does not contain a filesystem or disklabel"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try to use specifications in /etc/fstab first.
|
log debug "/$DEVNAME contains filesystem type $FSTYPE"
|
||||||
|
BOOTFW_DEV=$(/usr/bin/findmnt -no source /boot/firmware)
|
||||||
|
log debug "BOOTFW_DEV $BOOTFW_DEV"
|
||||||
|
ROOT_DEV=$(/usr/bin/findmnt -no source /)
|
||||||
|
log debug "ROOT_DEV $ROOT_DEV"
|
||||||
|
BOOT_DEV=$(/usr/bin/findmnt -no source /boot)
|
||||||
|
log debug "BOOT_DEV $BOOT_DEV"
|
||||||
|
|
||||||
|
if [ $BOOTFW_DEV = /$DEVNAME ]; then
|
||||||
|
log debug "skipping BOOTFS_DEV $BOOTFS_DEV mounted at /boot/firmware"
|
||||||
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
|
exit
|
||||||
|
elif [ $ROOT_DEV = /$DEVNAME ]; then
|
||||||
|
log debug "skipping ROOT_DEV $ROOT_DEV mounted at /"
|
||||||
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
|
exit
|
||||||
|
elif [ $BOOT_DEV = /$DEVNAME ]; then
|
||||||
|
log debug "skipping BOOT_DEV $BOOT_DEV mount as /boot"
|
||||||
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try to use specifications in /etc/fstab to skip.
|
||||||
if egrep -q "^[[:blank:]]*$DEVNAME" /etc/fstab; then
|
if egrep -q "^[[:blank:]]*$DEVNAME" /etc/fstab; then
|
||||||
log info "executing command: mount $DEVNAME"
|
log debug "skipping /$DEVNAME exit"
|
||||||
mount $DEVNAME || log err "mount by DEVNAME with $DEVNAME wasn't successful; return code $?"
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
|
exit
|
||||||
elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
||||||
log info "executing command: mount -U $UUID"
|
log debug "skipping $UUID"
|
||||||
mount -U $UUID || log err "mount by UUID with $UUID wasn't successful; return code $?"
|
lockfile-remove /var/run/usbmount/.mount
|
||||||
|
exit
|
||||||
else
|
else
|
||||||
log debug "$DEVNAME contains filesystem type $FSTYPE"
|
log debug "/$DEVNAME contains filesystem type $FSTYPE"
|
||||||
|
|
||||||
fstype=$FSTYPE
|
fstype=$FSTYPE
|
||||||
# Test if the filesystem type is in the list of filesystem
|
# Test if the filesystem type is in the list of filesystem
|
||||||
# types to mount.
|
# types to mount.
|
||||||
|
@ -120,7 +141,7 @@ if [ "$1" = add ]; then
|
||||||
for v in $MOUNTPOINTS; do
|
for v in $MOUNTPOINTS; do
|
||||||
if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then
|
if [ -d "$v" ] && ! grep -q "^[^ ][^ ]* *$v " /proc/mounts; then
|
||||||
mountpoint="$v"
|
mountpoint="$v"
|
||||||
log debug "mountpoint $mountpoint is available for $DEVNAME"
|
log debug "mountpoint $mountpoint is available for /$DEVNAME"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
# deb: "{{ iiab_download_url }}/usbmount_0.0.22_all.deb"
|
# deb: "{{ iiab_download_url }}/usbmount_0.0.22_all.deb"
|
||||||
# # when: is_debian
|
# # when: is_debian
|
||||||
|
|
||||||
- name: Install lockfile-progs and util-linux for usbmount from OS repo
|
- name: Install lockfile-progs and util-linux (findmnt blkid) for usbmount from OS repo
|
||||||
package:
|
package:
|
||||||
name:
|
name:
|
||||||
- lockfile-progs
|
- lockfile-progs
|
||||||
|
|
Loading…
Reference in a new issue