summaryrefslogtreecommitdiffstats
path: root/etc/namedb/make-localhost
blob: 60fbe49441abd0daf43ce83dcd45a428c6e468de (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# $FreeBSD$
#
# make-localhost - edit the appropriate local information into
# /etc/namedb/localhost.rev
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
export PATH

if [ "`hostname -s`" != "`hostname`" ]; then
	# hostname must contain domain

	host=`hostname -s`
	fullhost=`hostname`
	domain=`echo $fullhost | sed "s/^$host\.//"`
else
	host=`hostname`

	if [ -z "$1" ]; then
		echo -n 'Enter your domain name: '
		read domain
	else
		domain="$1"
	fi

	# strip trailing dot, if any
	domain=`echo $domain | sed 's/\.$//'`
	fullhost="$host.$domain"
fi

date=`date +"%Y%m%d"`

mkdir -p master

mv -f master/localhost-v6.rev master/localhost-v6.rev.BAK 2>/dev/null

sed -e "s/@host@/$fullhost/g" \
	-e "s/@domain@/$domain/g" \
	-e "s/@date@/$date/g" \
	< PROTO.localhost-v6.rev > master/localhost-v6.rev

mv -f master/localhost.rev master/localhost.rev.BAK 2>/dev/null

exec sed -e "s/@host@/$fullhost/g" \
	-e "s/@domain@/$domain/g" \
	-e "s/@date@/$date/g" \
	< PROTO.localhost.rev > master/localhost.rev
OpenPOWER on IntegriCloud