Skip site navigation (1)Skip section navigation (2)


| raw e-mail | index | archive | help
Regards.

Below is the script.

#!/bin/sh
case "${0##*/}" in
pkgbuild.sh)
	case "${1}" in	# (
	success|failed)
		if ! [ ${LOCKF_HOOK_TMPFS:+1} ] ; then
			shopt="${-}"
			LOCKF_HOOK_TMPFS=1 lockf -k "${LOG}/.tmpfs.log" /bin/sh ${shopt:+"-${-}"} "${0}" ${1+"${@}"}
		elif [ ${MY_JOBID:+1} ] ; then
			# jq was installed by package textproc/jq
			if JQ=$(which jq 2>&${OUTPUT_REDIRECTED_STDERR:-2}) ; then
				realpath=$(realpath "${MASTERMNT}/../${MY_JOBID}/")
				pour_xo_sauce_on_df=$(
					mount -t tmpfs -p |
					cut -f 2 -w |
					grep -e "^${realpath}" |
					xargs df -b --libxo json |
					${JQ} -c -r '[.["storage-system-information"].filesystem[].["used-blocks"]]|add//-0'
					)
				tmpfs_at_end=$(
					echo "${pour_xo_sauce_on_df}" |
					awk '{ x += $0; } END { printf "%s %.2f %s", "TMPFS:", x*512/(1024**3), "GiB" }'
					)
			elif ! tmpfs_at_end="$(env BLOCKSIZE=512 df -t tmpfs \
					${MASTERMNT}/../${MY_JOBID}/ \
					${MASTERMNT}/../${MY_JOBID}/.p/ \
					${MASTERMNT}/../${MY_JOBID}/usr/local/ \
					2>/dev/null | tail -3 \
					| awk '{ tmpfs_use += $3; } END { printf "%s %.2f %s", "TMPFS:", tmpfs_use*512/(1024**3), "GiB" }')" ; then
				tmpfs_at_end="TMPFS: -0. GiB"
			fi
			if true ; then
				# output to stdout
				echo "${2} | ${3}: ${tmpfs_at_end}" >&${OUTPUT_REDIRECTED_STDOUT:-1}
			fi
			if false ; then
				# output to stderr
				echo "${2} | ${3}: ${tmpfs_at_end}" >&${OUTPUT_REDIRECTED_STDERR:-2}
			fi
			if true && [ ${OUTPUT_REDIRECTED:-0} -eq 1 ] ; then
				# output to ${LOG}/logs/${3}.log file
				echo "${tmpfs_at_end}" >&2
			fi
			if true ; then
				# append to file
				echo "${2} | ${3}: ${tmpfs_at_end}" >>"${LOG}/.tmpfs.log"
			fi
		fi
		;;	# (
	*)
	esac
	;;	# (
*)
esac
return 0
# end of script




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>