Blame samples/auto.net

Packit 8480eb
#!/bin/bash
Packit 8480eb
Packit 8480eb
# This file must be executable to work! chmod 755!
Packit 8480eb
Packit 8480eb
# Look at what a host is exporting to determine what we can mount.
Packit 8480eb
# This is very simple, but it appears to work surprisingly well
Packit 8480eb
Packit 8480eb
key="$1"
Packit 8480eb
Packit 8480eb
# add "nosymlink" here if you want to suppress symlinking local filesystems
Packit 8480eb
# add "nonstrict" to make it OK for some filesystems to not mount
Packit 8480eb
opts="-fstype=nfs,hard,intr,nodev,nosuid"
Packit 8480eb
Packit 8480eb
for P in /bin /sbin /usr/bin /usr/sbin
Packit 8480eb
do
Packit 8480eb
	for M in showmount kshowmount
Packit 8480eb
	do
Packit 8480eb
		if [ -x $P/$M ]
Packit 8480eb
		then
Packit 8480eb
			SMNT=$P/$M
Packit 8480eb
			break 2
Packit 8480eb
		fi
Packit 8480eb
	done
Packit 8480eb
done
Packit 8480eb
Packit 8480eb
[ -x $SMNT ] || exit 1
Packit 8480eb
Packit 8480eb
# Newer distributions get this right
Packit 8480eb
SHOWMOUNT="$SMNT --no-headers -e $key"
Packit 8480eb
Packit 8480eb
$SHOWMOUNT | LC_ALL=C cut -d' ' -f1 | LC_ALL=C sort -u | \
Packit 8480eb
	awk -v key="$key" -v opts="$opts" -- '
Packit 8480eb
	BEGIN	{ ORS=""; first=1 }
Packit 8480eb
		{ if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
Packit 8480eb
	END	{ if (!first) print "\n"; else exit 1 }
Packit 8480eb
	' | sed 's/#/\\#/g'