home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / www / src / WWW / Daemon / Implementation / install.csh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1993-01-12  |  4.8 KB  |  180 lines

  1. #! /bin/csh
  2. #
  3. #            Install HTTP daemon
  4. #
  5. #  This script works for regular BSD unix systems.  It will not
  6. #  necessarily work with fancy bells and whistles.
  7. #  Check all the places where BSD is mentioned for differences for sys V
  8. #  If your inted doesn't support running a daemon under otherthan root,
  9. #    change the format of the inted.conf entry near the bottom
  10. #  Tested on: NeXT_3.0
  11. #
  12. #  Supposed to work with NeXT netinfo.
  13. #  Supposed to work with yp
  14. #
  15. #  Read first then run it as root
  16. #  Assumes binaries are in WWW_MACH directories parallel with Implementation/
  17. #  Running it more than once won't harm anything.
  18. #  You can run it if the server is already partially installed,
  19. #  and it will try to fix up what is missing.
  20.  
  21. set prod = httpd
  22. set service = www
  23. set port = 80
  24.  
  25. set yes = 1
  26. set no = 0
  27. set signal_inetd = $no
  28.  
  29. #        Copy over daemon
  30.  
  31.  
  32. if ( "$WWW_MACH" == "" ) then
  33.     echo You must first setenv WWW_MACH to give your machine type
  34.     exit
  35. endif
  36.  
  37. if ( -e ../$WWW_MACH/$prod ) then
  38.     cp ../$WWW_MACH/$prod /usr/etc/$prod
  39. else
  40.     echo There is no ../$WWW_MACH/$prod daemon executable file for $WWW_MACH
  41.     echo Try making it first.
  42.     exit 2
  43. endif
  44.  
  45. #        Make configuration file
  46.  
  47. if ("$prod" == "httpd") then
  48.  
  49.     if ( -e /etc/httpd.conf ) then
  50.     echo The configuration file /etc/httpd.conf already exists.
  51.     set ans =
  52.     while (("$ans" != "y") && ("$ans" != "n"))
  53.         glob "Overwrite with default version? (y or n) "
  54.         set ans = $<
  55.     end
  56.     if ($ans == "n") goto conf_done
  57.     if ( ! -e /etc/httpd.conf.bak ) then
  58.         mv /etc/httpd.conf /etc/httpd.conf.bak
  59.     else
  60.         rm -f /etc/httpd.conf
  61.     endif
  62.     
  63.     else
  64.     cat <<EOF >> /etc/httpd.conf
  65.     #    Configuration file for World Wide Web server
  66.     map   /     /welcome.html
  67.     map   /*     /Public/*
  68.     pass  /Public/*
  69.     fail  *
  70.     EOF
  71.     endif
  72.     
  73.     conf_done:
  74.  
  75. #        Make home page
  76.  
  77.     if ( ! -r /Public ) mkdir /Public
  78.     if (   -r /Public/welcome.html ) then
  79.     echo /Public/welcome.html already exists .. not overwritten.
  80.     else
  81.     echo "<title>Welcome to" `hostname`" W3 server</title>" \
  82.         >/Public/welcome.html
  83.     echo "<h1>Welcome to" `hostname` "</h1>" >>/Public/welcome.html
  84.     cat <<EOF >>/Public/welcome.html
  85.     This server has just been installed, and no local
  86.     data is currently available. Edit me!
  87.     Watch this space...
  88.     <h2>Information elsewhere</h2>
  89.     For other information,
  90.     <a href=http://info.cern.ch/>select this link</a>.
  91.     <p>
  92.     <address>Server Manager<address>
  93.     EOF
  94.     endif
  95.  
  96. endif
  97.  
  98. #   Put $service into netinfo or /etc/service if necessary
  99.  
  100. #   netinfo services:
  101. if ( -d /etc/netinfo ) then
  102.     echo You have netinfo, so we will use that.
  103.     niutil -read . services/$service >/dev/null
  104.     if ($status == 0) then
  105.         echo Service $service defined already
  106.     else
  107.         niutil -create . services/$service
  108.     signal_inetd = $yes
  109.     endif
  110.     niutil -createprop . services/$service port 80
  111.     niutil -createprop . services/$service protocol tcp
  112. else
  113. #    real  /etc/services file
  114.     grep "^[^ \t]*[ \t]*$port/tcp" /etc/services >/dev/null
  115.     if ($status == 0) then
  116.     set service = ( `grep "^[^ \t]*[ \t]*$port/tcp" /etc/services` )
  117.     set service = $service[1]
  118.     echo "  Port 80 service is already defined as" $service
  119.     else
  120.     echo "Adding service $service on port $port"
  121.     echo "$service    $port/tcp    # World-Wide Web information service" /
  122.          >> /etc/services
  123.     if ( -r /var/yp ) then
  124.         echo You seem to have yellow pages. Rebuilding yp for services
  125.         ( cd /var/yp; make )
  126.         echo If this doesn't work, try a reboot :-)
  127.     endif
  128.     endif
  129. endif
  130.  
  131. #           Put httpd into inetd.conf if not in already
  132.  
  133. grep "^${service}" /etc/inetd.conf > /dev/null
  134. if ($status == 0) then
  135.     set server = ( `grep "^${service}" /etc/inetd.conf` )
  136. #   check the index 6 below if not bsd
  137.     echo $service daemon already defined to be $server[6]
  138. else
  139.     cat <<EOF >> /etc/inetd.conf
  140. #  WorldWide Web service
  141. $service    stream    tcp    nowait    nobody    /usr/etc/$prod prod
  142. EOF
  143.     echo The daemon has been added to the inetd configuration file.
  144.     signal_inetd = $yes
  145. endif
  146.  
  147. #           Send singal to inetd to make it reread inetd.conf
  148.  
  149.  
  150. if ( $signal_inetd ) then
  151.     echo 
  152. #   @@@ BSD only: check which column the process number is in from ps aux!
  153. #   @@@ BSD and the aux should be -es or someting in SysV
  154.     set inetd = ( `ps aux | grep inetd | grep -v grep` )
  155.     echo Sending HUP signal to inetd process $inetd[2] 
  156.     kill -HUP $inetd[2]
  157. endif
  158.  
  159. #        Test it ... requires www to be installed.
  160.  
  161. if ( -x ../../LineMode/$WWW_MACH/www ) then
  162.     echo Testing new server...
  163.     set here = `hostname`
  164.     ../../LineMode/$WWW_MACH/www -n http://$here/
  165.     if ($status != 0) then
  166.     echo "****" TEST FAILED
  167.     exit 3
  168.     else
  169.     echo WWW3 server on `hostname` Tested aparently OK.
  170.     endif
  171. else
  172.     echo Can't test it: no www in ../../LineMode/$WWW_MACH
  173. endif
  174.  
  175. #        Log it to www team at cern to keep some statistics.
  176.  
  177. mail -s "$here installed W3 server " \
  178.     www-log@info.cern.ch < $0
  179. exit
  180.