Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.9 KiB

  1. #!/bin/sh -
  2. #
  3. # $NetBSD: netstart,v 1.21 1995/10/08 18:11:40 thorpej Exp $
  4. # @(#)netstart 5.9 (Berkeley) 3/30/91
  5. # set these to "NO" to turn them off. otherwise, they're used as flags
  6. routed_flags=-q
  7. rarpd_flags=NO # for 'normal' use: rarpd_flags="-a"
  8. bootparamd_flags=NO # for 'normal' use: bootparamd_flags=""
  9. rbootd_flags=NO # for 'normal' use: rbootd_flags=""
  10. sendmail_flags=NO # for 'normal' use: sendmail_flags="-bd -q30m"
  11. named_flags=NO # for 'normal' use: named_flags=""
  12. timed_flags=
  13. # set the following to "YES" to turn them on
  14. rwhod=NO
  15. nfs_server=NO
  16. nfs_client=NO
  17. gated=NO
  18. kerberos_server=NO
  19. amd=NO
  20. # miscellaneous other flags
  21. # only used if the appropriate server is marked YES above
  22. gated_flags=
  23. amd_dir=/amd # AMD's mount directory
  24. amd_master=/etc/amd/master # AMD 'master' map
  25. # /etc/myname contains my symbolic name
  26. #
  27. hostname=`cat /etc/myname`
  28. hostname $hostname
  29. if [ -f /etc/defaultdomain ]; then
  30. domainname `cat /etc/defaultdomain`
  31. fi
  32. # configure all of the interfaces which we know about.
  33. # do this by reading /etc/hostname.* files, where * is the name
  34. # of a given interface.
  35. #
  36. # these files are formatted like the following, but with no # at the
  37. # beginning of the line
  38. #
  39. # addr_family hostname netmask broadcast_addr options
  40. # dest dest_addr
  41. #
  42. # addr_family is the address family of the interface, generally inet
  43. # hostname is the host name that belongs to the interface, in /etc/hosts.
  44. # netmask is the network mask for the interface.
  45. # broadcast_addr is the broadcast address for the interface
  46. # options are misc. options to ifconfig for the interface.
  47. #
  48. # dest is simply the string "dest" (no quotes, though) if the interface
  49. # has a "destination" (i.e. it's a point-to-point link, like SLIP).
  50. # dest_addr is the hostname of the other end of the link, in /etc/hosts
  51. #
  52. # the only required contents of the file are the addr_family field
  53. # and the hostname.
  54. (
  55. tmp="$IFS"
  56. IFS="$IFS."
  57. set -- `echo /etc/hostname*`
  58. IFS=$tmp
  59. unset tmp
  60. while [ $# -ge 2 ] ; do
  61. shift # get rid of "hostname"
  62. (
  63. read af name mask bcaddr extras
  64. read dt dtaddr
  65. if [ ! -n "$name" ]; then
  66. echo "/etc/hostname.$1: invalid network configuration file"
  67. exit
  68. fi
  69. cmd="ifconfig $1 $af $name "
  70. if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
  71. if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
  72. if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
  73. cmd="$cmd broadcast $bcaddr";
  74. fi
  75. cmd="$cmd $extras"
  76. $cmd
  77. ) < /etc/hostname.$1
  78. shift
  79. done
  80. )
  81. # set the address for the loopback interface
  82. ifconfig lo0 inet localhost
  83. # use loopback, not the wire
  84. route add $hostname localhost
  85. # /etc/mygate, if it exists, contains the name of my gateway host
  86. # that name must be in /etc/hosts.
  87. if [ -f /etc/mygate ]; then
  88. route add default `cat /etc/mygate`
  89. fi