From ea8b2bd65797914555663bb19ecfd38249fe346b Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 8 Feb 2023 16:10:56 +0100 Subject: [PATCH] motd: check only local filesystems To avoid to block connections if a remote share is unavailable. --- update-motd.d/10-filesystem | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/update-motd.d/10-filesystem b/update-motd.d/10-filesystem index 7351582..b32e7ce 100755 --- a/update-motd.d/10-filesystem +++ b/update-motd.d/10-filesystem @@ -18,7 +18,7 @@ BOLD='\033[1m' RESET='\033[0m' # ]]] # Vars definition [[[ -ROOT_PART_USAGE=$(df | grep -m1 "/$" | awk '{print $5}') +ROOT_PART_USAGE=$(df --local | grep -m1 "/$" | awk '{print $5}') # ]]] #+++++++++++++++++++: Disk Usage :+++++++++++++++++++ @@ -35,8 +35,8 @@ printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_ROOT_NAME}${RESET}${BLACKB}= ${CYAN}${R # Other partition for PART_NAME in /boot /home /opt /srv /tmp /tmp /usr /var /var/lib/docker /var/lib/vz; do ## "/...$" : $ to grep only the mount point and not sub-directories (/var: OK; /mnt/temp: nOK) - if (df | grep "${PART_NAME}$" > /dev/null); then - PART_USAGE=$(df | grep "${PART_NAME}$" | awk '{print $5}') + if (df --local | grep "${PART_NAME}$" > /dev/null); then + PART_USAGE=$(df --local | grep "${PART_NAME}$" | awk '{print $5}') PRINTF_PART_NAME=$(printf '%-22s' "${PART_NAME}") printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET}${BLACKB}= ${CYAN}${PART_USAGE}${RESET}\\n" fi @@ -50,12 +50,12 @@ if [ "$(command -v zpool)" ]; then printf '%b' " ${CYAN}${BOLD}ZFS${RESET} ${CYAN}Partition${RESET} " printf "${BLACKB}%33s${RESET}\\n" | tr ' ' - - NUMBER_PART=$(df -T | grep -c zfs) + NUMBER_PART=$(df --local --print-type | grep -c zfs) LINE=1 while [ "${LINE}" -le "${NUMBER_PART}" ]; do - DISK_USAGE=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}') - PART_NAME=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}') + DISK_USAGE=$(df --local --print-type | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}') + PART_NAME=$(df --local --print-type | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}') PRINTF_PART_NAME=$(printf '%-23s' "${PART_NAME}") printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET} ${CYAN}${DISK_USAGE}${RESET}\\n" LINE=$((LINE+1))