]> git.pld-linux.org Git - packages/mnogosearch.git/blob - mnogosearch-gethostnames
- ftp->FTP
[packages/mnogosearch.git] / mnogosearch-gethostnames
1 #!/bin/sh
2 # Script for automagic finding&using hostnames/aliases of sites which are held
3 # on this server. 
4 # Based on mnogosearch spec file.
5 # Adapted for pld by hunter@pld.org.pl, 8/09/2001
6
7 if [ -d /etc/httpd/httpd.conf ]; then
8     VHOSTS=/etc/httpd/httpd.conf/20_mod_vhost_alias.conf
9     HTTPCF=/etc/httpd/httpd.conf/10_httpd.conf
10 else
11     VHOSTS=/etc/httpd/mod_vhost_alias.conf
12     HTTPCF=/etc/httpd/httpd.conf
13 fi
14 IDXRCF=/etc/mnogosearch/indexer.conf
15 TMPFILE=/tmp/mnogo.tmp
16 TMPFILE2=/tmp/mnogo2.tmp
17 ENTRIES="index.html index.htm index.php index.php3 index.shtml default.htm"
18
19 rm -f $TMPFILE $TMPFILE2
20
21 # First check for local sites in this file:
22 for i in `cat /etc/mnogosearch/locals`; do 
23         echo $i >> $TMPFILE 2&1>/dev/null
24 done
25
26 #Then extract from $VHOSTS file
27 if [ -x $VHOSTS ]; then 
28         for i in ; do echo $i >> $TMPFILE; done
29 fi
30
31 #Determine localhost name
32 SERVERNAME="`cat $HTTPCF| grep -v "#" |  grep ServerName| awk '{printf($2)}'`"
33 [ -z "$SERVERNAME" ] && SERVERNAME="`uname -n`"
34 #IF the two above fail use localhost
35 [ -z "$SERVERNAME" ] && SERVERNAME="localhost"
36
37 if [ -f $TMPFILE ]; then
38         for i in `cat $TMPFILE`; do echo "$i" >> $TMPFILE2; done 
39 fi
40 echo 'http://'$SERVERNAME >> $TMPFILE2
41 mv $TMPFILE2 $TMPFILE
42
43 cat $IDXRCF | grep -v -e Server -e URL -e "#Added by"> $TMPFILE2 
44 echo "#Added by $0, on `date`" >> $TMPFILE2
45 for i in `cat $TMPFILE`; do
46         echo "Server $i" >> $TMPFILE2 
47 done
48
49 #Get url entries for hostnames 
50 for i in `cat $TMPFILE`; do 
51         for j in $ENTRIES; do
52         echo "URL $i/$j" >> $TMPFILE2;
53         done
54 done
55
56 mv -f $TMPFILE2 $IDXRCF
57 rm -f $TMPFILE
This page took 0.024187 seconds and 3 git commands to generate.