From 8da479e698e3347654d5a0d969b52cc5caf91993 Mon Sep 17 00:00:00 2001 From: Liangbin Lian Date: Sun, 28 Apr 2024 11:46:46 +0800 Subject: [PATCH] istoreos: fix some grep patterns to limited syntax --- .../files/lib/functions/istoreos-boot.sh | 2 +- .../base-files/files/lib/upgrade/common.sh | 2 +- .../istoreos-files/files/etc/init.d/io_uring | 2 +- .../istoreos-files/files/etc/init.d/wan_drop | 2 +- .../files/etc/uci-defaults/09_istoreos | 2 +- .../files/usr/libexec/blockphy.sh | 22 +++++++++---------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package/base-files/files/lib/functions/istoreos-boot.sh b/package/base-files/files/lib/functions/istoreos-boot.sh index 1021da2935..4a4588baa6 100644 --- a/package/base-files/files/lib/functions/istoreos-boot.sh +++ b/package/base-files/files/lib/functions/istoreos-boot.sh @@ -43,7 +43,7 @@ _getpartofdisk() echo "$disk" else part="$disk" - echo "$part" | grep -q '^.*\d$' && part="${part}p" + echo "$part" | grep -q '^.*[0-9]$' && part="${part}p" part="${part}"$(( ${offset} )) if [ ! -b "/dev/$part" ]; then # lvm diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index eabde0f277..9078927b0c 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -236,7 +236,7 @@ export_partdevice() { return 0 else part="$BOOTDEV_DEVNAME" - echo "$part" | grep -q '^.*\d$' && part="${part}p" + echo "$part" | grep -q '^.*[0-9]$' && part="${part}p" part="${part}${offset}" if [ -b "/dev/$part" ]; then export "$var=$part" diff --git a/package/istoreos-files/files/etc/init.d/io_uring b/package/istoreos-files/files/etc/init.d/io_uring index a1051d9fca..7f67482013 100755 --- a/package/istoreos-files/files/etc/init.d/io_uring +++ b/package/istoreos-files/files/etc/init.d/io_uring @@ -9,7 +9,7 @@ check_kernel() { } boot() { - if check_kernel `uname -r | grep -Eo '\d+\.\d+' | sed 's/\./ /g'`; then + if check_kernel `uname -r | grep -Eo '[0-9]+\.[0-9]+' | sed 's/\./ /g'`; then if [ ! -f /usr/lib/samba/vfs/io_uring.so ]; then if [ -f /usr/lib/samba/vfs/io_uring.so.bak ]; then mv /usr/lib/samba/vfs/io_uring.so.bak /usr/lib/samba/vfs/io_uring.so diff --git a/package/istoreos-files/files/etc/init.d/wan_drop b/package/istoreos-files/files/etc/init.d/wan_drop index dc79cc51b5..36cb247595 100755 --- a/package/istoreos-files/files/etc/init.d/wan_drop +++ b/package/istoreos-files/files/etc/init.d/wan_drop @@ -8,7 +8,7 @@ start_service() { local PROTO=`uci get network.wan.proto` logger -t 'wan_drop' "current proto $PROTO" if [ "$PROTO" = "pppoe" ]; then - WAN_ZONE=`uci show firewall | egrep '^firewall\.@zone\[\d+\]\.name=' | grep wan | head -n1 | head -c -12` + WAN_ZONE=`uci show firewall | grep -E '^firewall\.@zone\[[0-9]+\]\.name=' | grep wan | head -n1 | head -c -12` if [ "`uci get ${WAN_ZONE}.input`" = "ACCEPT" ]; then logger -t 'wan_drop' "set firewall drop input from wan" uci -q batch <<-EOF >/dev/null diff --git a/package/istoreos-files/files/etc/uci-defaults/09_istoreos b/package/istoreos-files/files/etc/uci-defaults/09_istoreos index 40cedc17e5..d6c170411d 100644 --- a/package/istoreos-files/files/etc/uci-defaults/09_istoreos +++ b/package/istoreos-files/files/etc/uci-defaults/09_istoreos @@ -22,7 +22,7 @@ if [ ! -f /proc/device-tree/chosen/default-firewall ] || grep -qFw nas /proc/dev EOF if grep -qFw nas /proc/device-tree/chosen/default-firewall; then - WAN_ZONE=`uci show firewall | egrep '^firewall\.@zone\[\d+\]\.name=' | grep wan | head -n1 | head -c -12` + WAN_ZONE=`uci show firewall | grep -E '^firewall\.@zone\[[0-9]+\]\.name=' | grep wan | head -n1 | head -c -12` uci -q batch <<-EOF >/dev/null del_list dockerd.firewall.blocked_interfaces=wan set ${WAN_ZONE}.input=ACCEPT diff --git a/package/istoreos-files/files/usr/libexec/blockphy.sh b/package/istoreos-files/files/usr/libexec/blockphy.sh index 3290860de3..5ffb24e5b5 100755 --- a/package/istoreos-files/files/usr/libexec/blockphy.sh +++ b/package/istoreos-files/files/usr/libexec/blockphy.sh @@ -6,7 +6,7 @@ DEVNAME=${1#/dev/} getdisk() { local DISK=$1 local path=`readlink /sys/block/$DISK` - local usb=`echo "$path" | grep -oE '/usb\d+/[^:]+'` + local usb=`echo "$path" | grep -oE '/usb[0-9]+/[^:]+'` if [ -n "$usb" ]; then usb=${usb##*/} usb=${usb%%-1} @@ -15,7 +15,7 @@ getdisk() { fi case "$DISK" in mmcblk*) - echo "$path" | grep -oE '/mmc\d+/' + echo "$path" | grep -oE '/mmc[0-9]+/' return 0 ;; nvme*) @@ -24,38 +24,38 @@ getdisk() { ;; esac # sata - local sata=`echo "$path" | grep -oE '/ata\d+/host\d+/target\d+:\d+'` + local sata=`echo "$path" | grep -oE '/ata[0-9]+/host[0-9]+/target[0-9]+:[0-9]+'` if [ -n "$sata" ]; then - sata=`echo "$sata" | sed -r 's#/ata(\d+)/host\d+/target\d+:(\d+)#sata\1.\2#'` + sata=`echo "$sata" | sed -r 's#/ata([0-9]+)/host[0-9]+/target[0-9]+:([0-9]+)#sata\1.\2#'` sata=${sata%%.0} echo "/$sata/" return 0 fi # virtio - sata=`echo "$path" | grep -oE '/virtio\d+/host\d+/target\d+:\d+:\d+'` + sata=`echo "$path" | grep -oE '/virtio[0-9]+/host[0-9]+/target[0-9]+:[0-9]+:[0-9]+'` if [ -n "$sata" ]; then - sata=`echo "$sata" | sed -r 's#/virtio(\d+)/host\d+/target\d+:\d+:(\d+)#vio\1.\2#'` + sata=`echo "$sata" | sed -r 's#/virtio([0-9]+)/host[0-9]+/target[0-9]+:[0-9]+:([0-9]+)#vio\1.\2#'` sata=${sata%%.0} echo "/$sata/" return 0 fi # sas - sata=`echo "$path" | grep -oE '/host\d+/port-\d+:\d+'` + sata=`echo "$path" | grep -oE '/host[0-9]+/port-[0-9]+:[0-9]+'` if [ -n "$sata" ]; then - sata=`echo "$sata" | sed -r 's#/host(\d+)/port-\d+:(\d+)#sas\1.\2#'` + sata=`echo "$sata" | sed -r 's#/host([0-9]+)/port-[0-9]+:([0-9]+)#sas\1.\2#'` sata=${sata%%.0} echo "/$sata/" return 0 fi # scsi - sata=`echo "$path" | grep -oE '/host\d+/target\d+:\d+:\d+'` + sata=`echo "$path" | grep -oE '/host[0-9]+/target[0-9]+:[0-9]+:[0-9]+'` if [ -n "$sata" ]; then - sata=`echo "$sata" | sed -r 's#/host(\d+)/target\d+:\d+:(\d+)#scsi\1.\2#'` + sata=`echo "$sata" | sed -r 's#/host([0-9]+)/target[0-9]+:[0-9]+:([0-9]+)#scsi\1.\2#'` sata=${sata%%.0} echo "/$sata/" return 0 fi - echo "$path" | grep -oE '/host\d+/' | sed 's/host/sata/g' + echo "$path" | grep -oE '/host[0-9]+/' | sed 's/host/sata/g' return 0 }