diff --git a/packages/blobs/desktop/chromium.conf b/packages/blobs/desktop/chromium.conf index 4db302579c01..6e5e3f8a266c 100644 --- a/packages/blobs/desktop/chromium.conf +++ b/packages/blobs/desktop/chromium.conf @@ -9,6 +9,6 @@ CHROMIUM_FLAGS="--disable-smooth-scrolling \ --profiler-timing=0 \ --disable-composited-antialiasing \ --disk-cache-dir=/tmp/${USER}-cache \ ---disk-cache-size=$(findmnt --target /tmp -n -o AVAIL -b | awk '{printf ("%0.0f",$1*0.3); }') \ +--disk-cache-size=$(findmnt --noheadings --output AVAIL --bytes --target "/tmp" --uniq | awk '{printf ("%0.0f",$1*0.3); }') \ --no-sandbox \ --test-type" diff --git a/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup index cdef1a473667..e395f08f35aa 100755 --- a/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup +++ b/packages/bsp/common/etc/kernel/postinst.d/xx-initramfs-cleanup @@ -23,7 +23,7 @@ for f in $files; do done check_boot_dev (){ - available_size_boot_device=$(df -h | awk '/boot$/{print $4}') + available_size_boot_device=$(df --output="avail" -h "/boot" | awk 'END{print $1}') echo "Free space after deleting the package $DPKG_MAINTSCRIPT_PACKAGE in /boot: $available_size_boot_device" >&2 } mountpoint -q /boot && check_boot_dev diff --git a/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup b/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup index c4c94725b25b..2d99ff217d03 100755 --- a/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup +++ b/packages/bsp/common/etc/kernel/postrm.d/xx-initramfs-cleanup @@ -31,7 +31,7 @@ for f in $files; do done check_boot_dev (){ - available_size_boot_device=$(df -h | awk '/boot$/{print $4}') + available_size_boot_device=$(df --output="avail" -h "/boot" | awk 'END{print $1}') echo "Free space after deleting the package $DPKG_MAINTSCRIPT_PACKAGE in /boot: $available_size_boot_device" >&2 } mountpoint -q /boot && check_boot_dev diff --git a/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo b/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo index abd85bab7acf..ee666ce344fd 100755 --- a/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo +++ b/packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo @@ -73,15 +73,16 @@ function get_ip_addresses() { function storage_info() { # storage info - RootInfo=$(df -h /) - root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g') - root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo}) - StorageInfo=$(df -h $STORAGE 2>/dev/null | grep $STORAGE) - if [[ -n "${StorageInfo}" && ${RootInfo} != *$STORAGE* ]]; then - storage_usage=$(awk '/\// {print $(NF-1)}' <<<${StorageInfo} | sed 's/%//g') - storage_total=$(awk '/\// {print $(NF-4)}' <<<${StorageInfo}) + local RootInfo=$(df --output=source,size,pcent --human-readable "/" | tail -n1) + local root_device="$(awk '{print $1}' <<<${RootInfo})" + root_total=$(awk '{print $2}' <<<${RootInfo}) + root_usage=$(awk '{print $3}' <<<${RootInfo} | sed 's/%//g') + if [[ "${root_device}" != "${STORAGE}" && -b "${STORAGE}" ]]; then + local StorageInfo=$(df --output=size,pcent --human-readable "${STORAGE}" | tail -n1) + storage_total=$(awk '{print $1}' <<<${StorageInfo}) + storage_usage=$(awk '{print $2}' <<<${StorageInfo} | sed 's/%//g') if [[ -n "$(command -v smartctl)" ]]; then - DISK="${STORAGE::-1}" + DISK="/dev/$(lsblk --noheadings --nodeps --output PKNAME "${STORAGE}")" storage_temp+=$(smartctl -l scttempsts $DISK 2> /dev/null | grep -i 'Current Temperature:' | awk '{print $(NF-1)}') fi fi diff --git a/packages/bsp/common/usr/bin/armbianmonitor b/packages/bsp/common/usr/bin/armbianmonitor index 8caa10138234..0377707ea4d0 100755 --- a/packages/bsp/common/usr/bin/armbianmonitor +++ b/packages/bsp/common/usr/bin/armbianmonitor @@ -1039,11 +1039,11 @@ ShowDeviceWarning() { } # ShowDeviceWarning GetDevice() { - TestPath=$(findmnt "$1" | awk -F" " '/\/dev\// {print $2"\t"$3}') - if [[ -z ${TestPath} && -n "${1%/*}" ]]; then - GetDevice "${1%/*}" - elif [[ -z ${TestPath} && -z "${1%/*}" ]]; then - findmnt / | awk -F" " '/\/dev\// {print $2"\t"$3}' + TestPath=$(findmnt --noheadings --output SOURCE,FSTYPE "$1" --uniq) + if [[ -z ${TestPath} ]]; then + [[ -n "${1%/*}" ]] \ + && GetDevice "${1%/*}" \ + || GetDevice "/" else echo "${TestPath}" fi diff --git a/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization b/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization index 1ad3fff937b2..31b51b4f75ee 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization +++ b/packages/bsp/common/usr/lib/armbian/armbian-hardware-optimization @@ -46,7 +46,7 @@ set_io_scheduler() { prepare_board() { - CheckDevice=$(for i in /var/log /var /; do findmnt -n -o SOURCE $i && break; done) + CheckDevice=$(for i in /var/log /var /; do findmnt --noheadings --output SOURCE --target "$i" --uniq && break; done) # adjust logrotate configs if [[ "${CheckDevice}" == *"/dev/zram"* || "${CheckDevice}" == "armbian-ramlog" ]]; then for ConfigFile in /etc/logrotate.d/*; do sed -i -e "s/\/var\/log\//\/var\/log.hdd\//g" "${ConfigFile}"; done diff --git a/packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem b/packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem index a6e79ec0a8cf..8e3450ccbe12 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem +++ b/packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem @@ -208,7 +208,7 @@ do_expand_filesystem() local partdev=$1 local mountpoint=$2 - local fstype=$(findmnt -n -o FSTYPE $mountpoint) # i.e. ext4 or btrfs + local fstype=$(findmnt --noheadings --output FSTYPE --target "$mountpoint" --uniq) # i.e. ext4 or btrfs echo -e "\n### [resize2fs] Trying to resize $fstype filesystem on $partdev:\n" @@ -231,7 +231,7 @@ do_expand_filesystem() # check whether reboot is necessary for resize2fs to take effect local devsize=$(lsblk -n -b -o SIZE $partdev | head -1) - local fssize=$(findmnt -n -b -o SIZE --target $mountpoint) + local fssize=$(findmnt --noheadings --output SIZE --bytes --target "$mountpoint" --uniq) if [[ $(( 100 * $fssize / $devsize )) -lt 90 ]]; then echo -e "\n### [resize2fs] Automated reboot needed to finish the resize procedure" touch /var/run/resize2fs-reboot @@ -254,8 +254,8 @@ main() KERNELID=$(uname -r) echo "$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" - # trim any btrfs subvolume identifier given in square brackets (e.g. /dev/mapper/armbian-root[/@]) - local rootdev=$(findmnt -n -o SOURCE / | sed 's~\[.*\]~~') # i.e. /dev/mmcblk0p1, /dev/sda1 or /dev/mapper/armbian-root + # Use `--nofsroot` to trim any btrfs subvolume identifier given in square brackets (e.g. /dev/mapper/armbian-root[/@]) + local rootdev=$(findmnt --noheadings --output SOURCE --nofsroot --target "/" --uniq) # i.e. /dev/mmcblk0p1, /dev/sda1 or /dev/mapper/armbian-root # check for crypt local cryptname="" diff --git a/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs b/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs index a573e6e71610..062468873b06 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs +++ b/packages/bsp/common/usr/lib/armbian/armbian-truncate-logs @@ -20,7 +20,7 @@ if [ -z "`grep ^Storage=volatile /etc/systemd/journald.conf`" -a -z "$(ls -A /ru journalctl --relinquish-var # make sure to do volatile logging until the next flush fi -logusage=$(df /var/log/ --output=pcent | tail -1 |cut -d "%" -f 1) +logusage=$(df --output=pcent "/var/log/" | awk 'END{print $1}' | sed 's/%//') if [ $logusage -ge $treshold ]; then # remove journal backup files created by armbian-ramdisk in case of duplicate journals directories rm -rf /var/log.hdd/journal-* diff --git a/packages/bsp/common/usr/sbin/armbian-install b/packages/bsp/common/usr/sbin/armbian-install index 7ea51647c2d7..f4c590c105f4 100755 --- a/packages/bsp/common/usr/sbin/armbian-install +++ b/packages/bsp/common/usr/sbin/armbian-install @@ -125,8 +125,8 @@ create_armbian() echo "Root: \$2 $2 $FilesystemChoosen" >> $logfile # calculate usage and see if it fits on destination - USAGE=$(df -BM | grep ^/dev | head -1 | awk '{print $3}' | tr -cd '[0-9]. \n') - DEST=$(df -BM | grep ^/dev | grep "${TempDir}"/rootfs | awk '{print $4}' | tr -cd '[0-9]. \n') + USAGE=$(df --output="used" --block-size=1M "/" | awk 'END{print $1}') + DEST=$(df --output="avail" --block-size=1M "${TempDir}/rootfs" | awk 'END{print $1}') if [[ $USAGE -gt $DEST ]]; then dialog --title "$title" --backtitle "$backtitle" --colors --infobox\ "\n\Z1Partition too small.\Zn Needed: $USAGE MB Avaliable: $DEST MB" 5 60 @@ -391,7 +391,7 @@ create_armbian() dd if=/dev/zero of="${TempDir}"/rootfs/swapfile bs=$(cat /proc/meminfo | awk '/MemTotal/ {print $2}') count=1024 conv=notrunc mkswap "${TempDir}"/rootfs/swapfile chmod 0600 "${TempDir}"/rootfs/swapfile - sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"$/ resume=UUID=$(findmnt -no UUID -T "${TempDir}"/rootfs/swapfile) resume_offset=$(filefrag -v "${TempDir}"/rootfs/swapfile |grep " 0:"| awk '{print $4}' | cut -d"." -f1)\"/" "${TempDir}"/rootfs/etc/default/grub.d/98-armbian.cfg + sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"$/ resume=UUID=$(findmnt --noheadings --output UUID --target "${TempDir}/rootfs/swapfile" --uniq) resume_offset=$(filefrag -v "${TempDir}"/rootfs/swapfile |grep " 0:"| awk '{print $4}' | cut -d"." -f1)\"/" "${TempDir}"/rootfs/etc/default/grub.d/98-armbian.cfg echo "GRUB_DISABLE_OS_PROBER=false" >> "${TempDir}"/rootfs/etc/default/grub.d/98-armbian.cfg diff --git a/packages/bsp/common/usr/sbin/ddbr b/packages/bsp/common/usr/sbin/ddbr index 36a7bfdf9584..817070155893 100755 --- a/packages/bsp/common/usr/sbin/ddbr +++ b/packages/bsp/common/usr/sbin/ddbr @@ -242,7 +242,7 @@ image=BACKUP-arm-64-emmc.img if [ "$wantsbackup" = true ] then - rootfree=$(df | grep /$ | awk '{print $4}') + rootfree=$(df --output="avail" "/" | awk 'END{print $1}') [ $rootfree -le $intsize ] && echo -e "$_r NOT ENOUGH FREE SPACE! \n FORCING COMPRESSION MODE $_x" && compress=true else echo "$_b AVAILABLE DEVICES: "$_g"$(echo $avail)""$_x" diff --git a/packages/bsp/h3disp b/packages/bsp/h3disp index 470c7833081c..05697a011000 100755 --- a/packages/bsp/h3disp +++ b/packages/bsp/h3disp @@ -405,7 +405,7 @@ PatchScriptBin() { # try to find location of script.bin Path2ScriptBin=/boot if [ ! -f "${Path2ScriptBin}/script.bin" ]; then - Path2ScriptBin="$(df | awk -F" " '/^\/dev\/mmcblk0p1/ {print $6}')" + Path2ScriptBin="$(findmnt --noheadings --output TARGET --source "/dev/mmcblk0p1" --uniq)" if [ ! -f "${Path2ScriptBin}/script.bin" ]; then echo -e "Aborted\nCan not find script.bin. Ensure boot partition is mounted" >&2 logger "Can not find script.bin. Ensure boot partition is mounted"