motd: check only local filesystems
To avoid to block connections if a remote share is unavailable.
This commit is contained in:
		
							parent
							
								
									daada7a1db
								
							
						
					
					
						commit
						ea8b2bd657
					
				| 
						 | 
				
			
			@ -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))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue