aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/fixrmtab.in
blob: a1fbebf615078b2ddc839736a5628a899cd64d08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#
# Invalidate /etc/rmtab entries for hosts named.
# Restart mountd for changes to take effect.
#
# usage: fixrmtab host1 host2 ...
#
# Package:	am-utils-6.x
# Author:	Andreas Stolcke <stolcke@icsi.berkeley.edu>

#set -x

# allow user to pass RMTAB file name from environment
if test -z "${RMTAB}" ; then
	RMTAB=/etc/rmtab
fi

if [ ! -f "$RMTAB" ]; then
	exit 0
fi

TMP="$(mktemp ${RMTAB}.XXXXXX)"
if [ -z "$TMP" ]; then
	exit 1
fi

trap "rm -f $TMP" 0 1 2 3 15

for host
do
	sed -e "/^$host:/s/^./#/" "$RMTAB" > "$TMP" && cp "$TMP" "$RMTAB"
done