* Add this nice filesystem testing tool that I've recently
[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 # $DragonFly: src/etc/namedb/make-localhost,v 1.2 2003/06/17 04:24:48 dillon Exp $
5 #
6 # make-localhost - edit the appropriate local information into
7 # /etc/namedb/localhost.rev
8 #
9
10 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
11 export PATH
12
13 if [ "`hostname -s`" != "`hostname`" ]; then
14         # hostname must contain domain
15
16         host=`hostname -s`
17         fullhost=`hostname`
18         domain=`echo $fullhost | sed "s/^$host\.//"`
19 else
20         host=`hostname`
21
22         if [ -z "$1" ]; then
23                 echo -n 'Enter your domain name: '
24                 read domain
25         else
26                 domain="$1"
27         fi
28
29         # strip trailing dot, if any
30         domain=`echo $domain | sed 's/\.$//'`
31         fullhost="$host.$domain"
32 fi
33
34 date=`date +"%Y%m%d"`
35
36 mv -f localhost-v6.rev localhost-v6.rev.BAK 2>/dev/null
37
38 sed -e "s/@host@/$fullhost/g" \
39         -e "s/@domain@/$domain/g" \
40         -e "s/@date@/$date/g" \
41         < PROTO.localhost-v6.rev > localhost-v6.rev
42
43 mv -f localhost.rev localhost.rev.BAK 2>/dev/null
44
45 exec sed -e "s/@host@/$fullhost/g" \
46         -e "s/@domain@/$domain/g" \
47         -e "s/@date@/$date/g" \
48         < PROTO.localhost.rev > localhost.rev