Initial import from FreeBSD RELENG_4:
[dragonfly.git] / etc / namedb / make-localhost
1 #!/bin/sh
2 #
3 # $FreeBSD: src/etc/namedb/make-localhost,v 1.4.2.2 2002/02/04 18:24:21 ume Exp $
4 #
5 # make-localhost - edit the appropriate local information into
6 # /etc/namedb/localhost.rev
7 #
8
9 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
10 export PATH
11
12 if [ "`hostname -s`" != "`hostname`" ]; then
13         # hostname must contain domain
14
15         host=`hostname -s`
16         fullhost=`hostname`
17         domain=`echo $fullhost | sed "s/^$host\.//"`
18 else
19         host=`hostname`
20
21         if [ -z "$1" ]; then
22                 echo -n 'Enter your domain name: '
23                 read domain
24         else
25                 domain="$1"
26         fi
27
28         # strip trailing dot, if any
29         domain=`echo $domain | sed 's/\.$//'`
30         fullhost="$host.$domain"
31 fi
32
33 date=`date +"%Y%m%d"`
34
35 mv -f localhost-v6.rev localhost-v6.rev.BAK 2>/dev/null
36
37 sed -e "s/@host@/$fullhost/g" \
38         -e "s/@domain@/$domain/g" \
39         -e "s/@date@/$date/g" \
40         < PROTO.localhost-v6.rev > localhost-v6.rev
41
42 mv -f localhost.rev localhost.rev.BAK 2>/dev/null
43
44 exec sed -e "s/@host@/$fullhost/g" \
45         -e "s/@domain@/$domain/g" \
46         -e "s/@date@/$date/g" \
47         < PROTO.localhost.rev > localhost.rev