xref: /netbsd-src/external/mpl/dhcp/dist/client/scripts/nextstep (revision 6fb29d29285c26a62fae51364e3aa9f51d403424)
1*6fb29d29Schristos#!/bin/sh
2*6fb29d29Schristos#
3*6fb29d29Schristos# simplified dhclient-script for NeXTSTEP/OPENSTEP
4*6fb29d29Schristos#
5*6fb29d29Schristos# removed a lot of the cruft from the netbsd version since NeXTSTEP doesn't
6*6fb29d29Schristos# support aliases and lots of things were breaking for no good reason
7*6fb29d29Schristos#
8*6fb29d29Schristos# 14 Sep 1997, David W. Young
9*6fb29d29Schristos#
10*6fb29d29Schristosif [ x$reason = xPREINIT ]; then
11*6fb29d29Schristos  ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 up >/dev/null 2>&1
12*6fb29d29Schristos  exit 0
13*6fb29d29Schristosfi
14*6fb29d29Schristosif [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
15*6fb29d29Schristos   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
16*6fb29d29Schristos  current_hostname=`hostname`
17*6fb29d29Schristos  if [ x$current_hostname = x ] || \
18*6fb29d29Schristos     [ x$current_hostname = x$old_host_name ]; then
19*6fb29d29Schristos    if [ x$current_hostname = x ] || \
20*6fb29d29Schristos       [ x$new_host_name != x$old_host_name ]; then
21*6fb29d29Schristos      hostname $new_host_name
22*6fb29d29Schristos    fi
23*6fb29d29Schristos  fi
24*6fb29d29Schristos
25*6fb29d29Schristos  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
26*6fb29d29Schristos   then
27*6fb29d29Schristos    ifconfig $interface $new_ip_address netmask $new_subnet_mask \
28*6fb29d29Schristos			>/dev/null 2>&1
29*6fb29d29Schristos    route add $new_ip_address 127.1 0 >/dev/null 2>&1
30*6fb29d29Schristos    for router in $new_routers ; do
31*6fb29d29Schristos      route add default $router 1 >/dev/null 2>&1
32*6fb29d29Schristos    done
33*6fb29d29Schristos  fi
34*6fb29d29Schristos  if [ x"$new_domain_name_servers" != x ]; then
35*6fb29d29Schristos    cat /dev/null > /etc/resolv.conf.dhclient
36*6fb29d29Schristos    if [ "x$new_domain_search" != x ]; then
37*6fb29d29Schristos      echo search $new_domain_search >> /etc/resolv.conf.dhclient
38*6fb29d29Schristos    elif [ "x$new_domain_name" != x ]; then
39*6fb29d29Schristos      # Note that the DHCP 'Domain Name Option' is really just a domain
40*6fb29d29Schristos      # name, and that this practice of using the domain name option as
41*6fb29d29Schristos      # a search path is both nonstandard and deprecated.
42*6fb29d29Schristos      echo search $new_domain_name >> /etc/resolv.conf.dhclient
43*6fb29d29Schristos    fi
44*6fb29d29Schristos    for nameserver in $new_domain_name_servers; do
45*6fb29d29Schristos      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
46*6fb29d29Schristos    done
47*6fb29d29Schristos
48*6fb29d29Schristos    mv /etc/resolv.conf.dhclient /etc/resolv.conf
49*6fb29d29Schristos  fi
50*6fb29d29Schristos  exit 0
51*6fb29d29Schristosfi
52*6fb29d29Schristosif [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
53*6fb29d29Schristos   || [ x$reason = xSTOP ]; then
54*6fb29d29Schristos  if [ x$old_ip_address != x ]; then
55*6fb29d29Schristos    route delete $old_ip_address 127.1 >/dev/null 2>&1
56*6fb29d29Schristos    for $router in $old_routers ; do
57*6fb29d29Schristos      route delete default $router >/dev/null 2>&1
58*6fb29d29Schristos    done
59*6fb29d29Schristos  fi
60*6fb29d29Schristos  exit 0
61*6fb29d29Schristosfi
62