some shellcheck fixes (#4013)

* bsp: remove useless cats treewide

Signed-off-by: Rosen Penev <rosenp@gmail.com>

* bsp: replace egrep with grep -E

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2022-07-25 02:39:11 -07:00
committed by GitHub
parent 63795262e1
commit fdf73a025b
12 changed files with 28 additions and 28 deletions

View File

@@ -393,8 +393,8 @@ PreRequisits() {
ParseDVFSTable() {
# extract DRAM and dvfs settings from script.bin
bin2fex <"${Path2ScriptBin}/script.bin" 2>/dev/null | \
egrep "^LV._|^LV_|extrem|boot_clock|_freq|^dram_" | \
egrep -v "cpu_freq|dram_freq" | while read ; do
grep -E "^LV._|^LV_|extrem|boot_clock|_freq|^dram_" | \
grep -Ev "cpu_freq|dram_freq" | while read ; do
echo "# ${REPLY}"
done >/tmp/dvfs-table

View File

@@ -7,7 +7,7 @@
MOTD_DISABLE=""
ONE_WIRE=""
HIDE_IP_PATTERN="^dummy0|^lo"
PRIMARY_INTERFACE="$(ls -1 /sys/class/net/ | grep -v lo | egrep "enp|eth" | head -1)"
PRIMARY_INTERFACE="$(ls -1 /sys/class/net/ | grep -v lo | grep -E "enp|eth" | head -1)"
PRIMARY_DIRECTION="rx"
STORAGE=/dev/sda1

View File

@@ -8,12 +8,12 @@
# only do this for interactive shells
if [ "$-" != "${-#*i}" ]; then
OutstandingPackages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs 2>/dev/null)"
OutstandingPackages="$(grep -Ev "linux-base|linux-image" /var/run/reboot-required.pkgs 2>/dev/null)"
if [ -f "/var/run/.reboot_required" ]; then
printf "\n[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
elif [ "X${OutstandingPackages}" != "X" ]; then
# No kernel update involved, just regular packages like e.g. dbus require a reboot
Packages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs | sort | uniq | tr '\n' ',' | sed -e 's/,/, /g' -e 's/,\ $//')"
Packages="$(grep -Ev "linux-base|linux-image" /var/run/reboot-required.pkgs | sort | uniq | tr '\n' ',' | sed -e 's/,/, /g' -e 's/,\ $//')"
OlderThanOneDay=$(find /var/run/reboot-required -mtime +1)
if [ "X${OlderThanOneDay}" = "X" ]; then
printf "\n[\e[0;92m some packages require a reboot (${Packages})\x1B[0m ]\n\n"

View File

@@ -14,8 +14,8 @@ MOTD_DISABLE=""
[[ -f /etc/armbian-release ]] && . /etc/armbian-release
[[ -f /etc/armbian-distribution-status ]] && . /etc/armbian-distribution-status
[[ -f /etc/lsb-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(cat /etc/lsb-release | grep CODENAME | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(cat /etc/armbian-distribution-status | grep $DISTRIBUTION_CODENAME | cut -d"=" -f2)
[[ -f /etc/os-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(cat /etc/armbian-distribution-status | grep $DISTRIBUTION_CODENAME | cut -d"=" -f2)
[[ -f /etc/lsb-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(grep $DISTRIBUTION_CODENAME /etc/armbian-distribution-status | cut -d"=" -f2)
[[ -f /etc/os-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(grep $DISTRIBUTION_CODENAME /etc/armbian-distribution-status | cut -d"=" -f2)
[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd
for f in $MOTD_DISABLE; do
@@ -26,7 +26,7 @@ done
KERNELID=$(uname -r)
# Odroid N2 exception
[[ -f /proc/device-tree/model ]] && [[ -n $(cat /proc/device-tree/model | tr -d '\000' | grep ODROID | grep Plus) ]] && BOARD_NAME+="+"
[[ -f /proc/device-tree/model ]] && [[ -n $(tr -d '\000' < /proc/device-tree/model | grep ODROID | grep Plus) ]] && BOARD_NAME+="+"
TERM=linux toilet -f standard -F metal $(echo $BOARD_NAME | sed 's/Orange Pi/OPi/' | sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')
echo -e "Welcome to \e[0;91mArmbian ${VERSION} ${DISTRIBUTION_CODENAME^}\x1B[0m with $([[ $BRANCH == edge ]] && echo -e "\e[0;91mbleeding\x1B[0m edge " )\e[0;91mLinux $KERNELID\x1B[0m\n"

View File

@@ -867,7 +867,7 @@ CollectSupportInfo() {
lspci >/dev/null 2>&1 && (echo -e "\n### lspci:\n" ; lspci ${VERBOSE} 2>/dev/null)
nvme >/dev/null 2>&1 && (echo -e "\n### nvme:\n" ; nvme list 2>/dev/null)
[ -z $SUDO_USER ] || echo -e "\n### Group membership of $(groups $SUDO_USER)"
echo -e "\n### Userland:\n\n$(cat /etc/os-release | grep PRETTY_NAME)"
echo -e "\n### Userland:\n\n$(grep PRETTY_NAME /etc/os-release)"
echo -e "\n### Installed packages:\n\n$(dpkg -l | grep -E "openmediavault|armbian| linux-")"
KernelVersion=$(awk -F" " '{print $3}' < /proc/version)
case ${KernelVersion} in

View File

@@ -8,7 +8,7 @@
# read distribution status
[[ -f /etc/lsb-release ]] && . /etc/lsb-release
[[ -n "$DISTRIB_CODENAME" && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_STATUS=$(cat /etc/armbian-distribution-status | grep "$DISTRIB_CODENAME" | cut -d"=" -f2)
[[ -n "$DISTRIB_CODENAME" && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_STATUS=$(grep "$DISTRIB_CODENAME" /etc/armbian-distribution-status | cut -d"=" -f2)
. /etc/armbian-release
@@ -70,7 +70,7 @@ read_password()
set_shell()
{
optionsAudits=($(cat /etc/shells | grep "zsh\|/bash" | sed 's/\/bin\///g' | sed 's/\/usr//g' | uniq))
optionsAudits=($(grep "zsh\|/bash" /etc/shells | sed 's/\/bin\///g' | sed 's/\/usr//g' | uniq))
USER_SHELL="bash"
if [[ "${#optionsAudits[@]}" -gt 1 ]]; then

View File

@@ -81,7 +81,7 @@ case "$1" in
case $LINUXFAMILY in
sun7i|sun8i)
# set some mac address for BT
[[ -n $(lsmod | egrep "dhd|brcmfmac" ) ]] && \
[[ -n $(lsmod | grep -E "dhd|brcmfmac" ) ]] && \
(MACADDR=$(printf '43:29:B1:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]) ; \
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/brcm40183 ;\
sed -i "s/^MAC_ADDR=.*/MAC_ADDR=${MACADDR}/" /etc/default/ap6212 \

View File

@@ -76,26 +76,26 @@ do_firstrun_automated_user_configuration()
# find eth[0-9]
for ((i=0; i<=9; i++))
do
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "eth$i") )); then
if (( $(grep -ci -m1 "eth$i" "$fp_ifconfig_tmp") )); then
eth_index=eth${i}
break
fi
done
# Predictable Network Interface Names
[[ -z $eth_index ]] && eth_index=$(cat "$fp_ifconfig_tmp" | grep -m1 "en" | cut -f1 -d":" | head -1)
[[ -z $eth_index ]] && eth_index=$(grep -m1 "en" "$fp_ifconfig_tmp" | cut -f1 -d":" | head -1)
# find wlan[0-9]
for ((i=0; i<=9; i++))
do
if (( $(cat "$fp_ifconfig_tmp" | grep -ci -m1 "wlan$i") )); then
if (( $(grep -ci -m1 "wlan$i" "$fp_ifconfig_tmp") )); then
wlan_index=wlan${i}
break
fi
done
# Predictable Network Interface Names
[[ -z $wlan_index ]] && wlan_index=$(cat "$fp_ifconfig_tmp" | grep -m1 "wl" | cut -f1 -d":" | head -1)
[[ -z $wlan_index ]] && wlan_index=$(grep -m1 "wl" "$fp_ifconfig_tmp" | cut -f1 -d":" | head -1)
rm "$fp_ifconfig_tmp"

View File

@@ -91,17 +91,17 @@ log_hardware_info() {
echo -e "### partitions:\n" >>${Log}
grep -v " ram" /proc/partitions >>${Log}
echo -e "\n### df:\n" >>${Log}
df -h | egrep '^udev|^tmpfs|^/dev/|log2ram|folder2ram' >>${Log}
df -h | grep -E '^udev|^tmpfs|^/dev/|log2ram|folder2ram' >>${Log}
command -v zpool >/dev/null 2>&1 && echo -e "\n### zpools:\n\n$(zpool list)\n\n### zfs datasets:\n\n$(zfs list)" >>${Log}
echo -e "\n### lsblk:\n" >>${Log}
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,UUID | grep -v "SWAP" >>${Log}
command -v zramctl >/dev/null 2>&1 && echo -e "\n### zramctl:\n\n$(zramctl)" >>${Log}
echo -e "\n### mtab:\n" >>${Log}
egrep '^/dev/|\ zfs\ ' /etc/mtab | egrep -v "log2ram|folder2ram" | sort >>${Log}
grep -E '^/dev/|\ zfs\ ' /etc/mtab | grep -Ev "log2ram|folder2ram" | sort >>${Log}
[[ -e /boot/script.bin ]] && echo -e "\n### /boot/script.bin --> $(readlink /boot/script.bin)" >>${Log}
get_flash_information >>${Log}
echo -e "\n### Boot system health:\n" >>${Log}
armbianmonitor -s | egrep "^Time|^[0-9]" >>${Log}
armbianmonitor -s | grep -E "^Time|^[0-9]" >>${Log}
} # log_hardware_info
get_flash_information() {

View File

@@ -110,8 +110,8 @@ prepare_board() {
echo 2 >/proc/irq/$(awk -F":" "/xhci-hcd/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
echo 3 >/proc/irq/$(awk -F":" "/eth0/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
# mainline kernel might lack those
[[ -n $(cat /proc/interrupts | grep "rdma") ]] && echo 4 >/proc/irq/$(awk -F":" "/rdma/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
[[ -n $(cat /proc/interrupts | grep "osd-vsync") ]] && echo 5 >/proc/irq/$(awk -F":" "/ osd-vsync/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
[[ -n $(grep "rdma" /proc/interrupts) ]] && echo 4 >/proc/irq/$(awk -F":" "/rdma/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
[[ -n $(grep "osd-vsync" /proc/interrupts) ]] && echo 5 >/proc/irq/$(awk -F":" "/ osd-vsync/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity_list
# test fan on Odroid N2 plus - spin it up shortly
if [[ -f /sys/devices/virtual/thermal/thermal_zone0/trip_point_4_temp ]]; then
@@ -405,8 +405,8 @@ branch_naming_workaround()
# Once we rework kernel packages, this can be done better
{
if [[ -z $(cat /etc/armbian-release | grep BRANCH) ]]; then
BRANCH=$(dpkg -l | egrep "linux-image" | egrep "current|legacy|edge" | awk '{print $2}' | cut -d"-" -f3 | head -1)
if grep -q BRANCH /etc/armbian-release; then
BRANCH=$(dpkg -l | grep -E "linux-image" | grep -E "current|legacy|edge" | awk '{print $2}' | cut -d"-" -f3 | head -1)
[[ -n ${BRANCH} ]] && echo "BRANCH=$BRANCH" >> /etc/armbian-release
fi
}

View File

@@ -235,7 +235,7 @@ then
exit 1
fi
intsize=$(fdisk -s /dev/$emmc)
#image=$(echo $(cat /proc/cpuinfo | egrep '(Hardware|Revision)' | awk '{print $3}') | sed "s/ /-/g")-emmc.img
#image=$(echo $(grep -E '(Hardware|Revision)' /proc/cpuinfo | awk '{print $3}') | sed "s/ /-/g")-emmc.img
image=BACKUP-arm-64-emmc.img
### BACKUP ONLY CHECKS

View File

@@ -426,8 +426,8 @@ PrintActiveSettings() {
# USB ports active or disabled
echo -e "usb ports $(awk -F" " '/^usb_used/ {print $3}' <"${FexSettings}" | head -n 1 | sed -e 's/1/active/' -e 's/0/off/')\n"
# network
ethtool eth0 >/dev/null 2>&1 && echo -e "eth0 $(ethtool eth0 | egrep "Speed|Link d|Duplex" | tr "\n" " " | awk '{print $2"/"$4", Link: "$7}')\n"
ListOfWiFis=$(iwconfig 2>&1 | egrep -v "lo|tunl0|eth0" | grep -v "^ " | awk -F" " '{print $1}')
ethtool eth0 >/dev/null 2>&1 && echo -e "eth0 $(ethtool eth0 | grep -E "Speed|Link d|Duplex" | tr "\n" " " | awk '{print $2"/"$4", Link: "$7}')\n"
ListOfWiFis=$(iwconfig 2>&1 | grep -Ev "lo|tunl0|eth0" | grep -v "^ " | awk -F" " '{print $1}')
for i in ${ListOfWiFis} ; do
iwconfig $i
done
@@ -499,7 +499,7 @@ FinalizeSettings() {
if [ -s "${RCLocalContents}" ];then
# Adjust /etc/rc.local contents if necessary, first create clean file without h3consumption
# additions
egrep -v "exit\s*0|h3consumption|sun8i-corekeeper" /etc/rc.local | sed '/^\s*$/d' >"${FexSettings}"
grep -Ev "exit\s*0|h3consumption|sun8i-corekeeper" /etc/rc.local | sed '/^\s*$/d' >"${FexSettings}"
echo -e "\n### do NOT edit the following lines, always use h3consumption instead ###" >>"${FexSettings}"
cat "${RCLocalContents}" | while read ; do
echo -e "${REPLY} # h3consumption" >>"${FexSettings}"