mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
shellcheck
This commit is contained in:
parent
06eb5dde45
commit
412cbd655c
1 changed files with 19 additions and 19 deletions
|
@ -24,8 +24,8 @@ exec > /dev/null 2>&1
|
|||
# Log a string via the syslog facility.
|
||||
log()
|
||||
{
|
||||
if [ $1 != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
|
||||
logger -p user.$1 -t "usbmount[$$]" -- "$2"
|
||||
if [ "$1" != debug ] || expr "$VERBOSE" : "[yY]" > /dev/null; then
|
||||
logger -p user."$1" -t "usbmount[$$]" -- "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -90,12 +90,12 @@ if [ "$1" = add ]; then
|
|||
# Grab device information from device and "divide it"
|
||||
# FIXME: improvement: implement mounting by label (notice that labels
|
||||
# can contain spaces, which makes things a little bit less comfortable).
|
||||
DEVINFO=$(/sbin/blkid -p $DEVNAME)
|
||||
DEVINFO=$(/sbin/blkid -p "$DEVNAME")
|
||||
FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
|
||||
UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\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" | grep -Eq "(filesystem|disklabel)"; then
|
||||
log debug "/$DEVNAME does not contain a filesystem or disklabel"
|
||||
lockfile-remove /var/run/usbmount/.mount
|
||||
exit
|
||||
|
@ -109,26 +109,26 @@ if [ "$1" = add ]; then
|
|||
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"
|
||||
if [ "$BOOTFW_DEV" = /"$DEVNAME" ]; then
|
||||
log debug "skipping BOOTFW_DEV $BOOTFW_DEV mounted at /boot/firmware"
|
||||
lockfile-remove /var/run/usbmount/.mount
|
||||
exit
|
||||
elif [ $ROOT_DEV = /$DEVNAME ]; then
|
||||
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
|
||||
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 grep -Eq "^[[:blank:]]*$DEVNAME" /etc/fstab; then
|
||||
log debug "skipping /$DEVNAME exit"
|
||||
lockfile-remove /var/run/usbmount/.mount
|
||||
exit
|
||||
elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
||||
elif grep -Eq "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
|
||||
log debug "skipping $UUID"
|
||||
lockfile-remove /var/run/usbmount/.mount
|
||||
exit
|
||||
|
@ -166,25 +166,25 @@ if [ "$1" = add ]; then
|
|||
# Determine vendor and model.
|
||||
vendor=
|
||||
if [ -r "/sys$DEVPATH/device/vendor" ]; then
|
||||
vendor="`cat \"/sys$DEVPATH/device/vendor\"`"
|
||||
vendor="$(cat \"/sys"$DEVPATH"/device/vendor\")"
|
||||
elif [ -r "/sys$DEVPATH/../device/vendor" ]; then
|
||||
vendor="`cat \"/sys$DEVPATH/../device/vendor\"`"
|
||||
vendor="$(cat \"/sys"$DEVPATH"/../device/vendor\")"
|
||||
elif [ -r "/sys$DEVPATH/device/../manufacturer" ]; then
|
||||
vendor="`cat \"/sys$DEVPATH/device/../manufacturer\"`"
|
||||
vendor="$(cat \"/sys"$DEVPATH"/device/../manufacturer\")"
|
||||
elif [ -r "/sys$DEVPATH/../device/../manufacturer" ]; then
|
||||
vendor="`cat \"/sys$DEVPATH/../device/../manufacturer\"`"
|
||||
vendor="$(cat \"/sys"$DEVPATH"/../device/../manufacturer\")"
|
||||
fi
|
||||
vendor="$(echo "$vendor" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
||||
|
||||
model=
|
||||
if [ -r "/sys$DEVPATH/device/model" ]; then
|
||||
model="`cat \"/sys$DEVPATH/device/model\"`"
|
||||
model="$(cat \"/sys"$DEVPATH"/device/model\")"
|
||||
elif [ -r "/sys$DEVPATH/../device/model" ]; then
|
||||
model="`cat \"/sys$DEVPATH/../device/model\"`"
|
||||
model="$(cat \"/sys"$DEVPATH"/../device/model\")"
|
||||
elif [ -r "/sys$DEVPATH/device/../product" ]; then
|
||||
model="`cat \"/sys$DEVPATH/device/../product\"`"
|
||||
model="$(cat \"/sys"$DEVPATH"/device/../product\")"
|
||||
elif [ -r "/sys$DEVPATH/../device/../product" ]; then
|
||||
model="`cat \"/sys$DEVPATH/../device/../product\"`"
|
||||
model="$(cat \"/sys"$DEVPATH"/../device/../product\")"
|
||||
fi
|
||||
model="$(echo "$model" | sed 's/^[[:blank:]]\+//; s/[[:blank:]]\+$//')"
|
||||
|
||||
|
@ -208,7 +208,7 @@ elif [ "$1" = remove ]; then
|
|||
|
||||
# A block or partition device has been removed.
|
||||
# Test if it is mounted.
|
||||
while read device mountpoint fstype remainder; do
|
||||
while read -r device mountpoint fstype; do
|
||||
if [ "/$DEVNAME" = "$device" ]; then
|
||||
log debug "umount device is $device"
|
||||
# If the mountpoint and filesystem type are maintained by
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue