Dash:
[t2.git] / package / network / udhcp / rocknet_udhcp.sh
blob0d9c77bf356264c6eda3783ef32e2938dc8a426a
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../udhcp/rocknet_udhcp.sh
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 public_udhcp() {
16 local opt_nodns=
17 local HOSTNAME="`hostname`" cmdline=
18 [ "$HOSTNAME" == "(none)" ] && HOSTNAME=
20 [ "$CANUSESERVICE" == "1" ] && cmdline="exec "
22 cmdline="$cmdline /usr/sbin/udhcpc ${HOSTNAME:+-h $HOSTNAME} -i $if"
23 cmdline="$cmdline -s /etc/udhcp/t2-default.script"
25 while [ $# -ge 1 ]; do
26 case "$1" in
27 nodns) opt_nodns=1 ;;
28 *) echo "WARNING: udhcp doesn't understand '$1'"
30 esac
31 shift
32 done
34 if [ "$opt_nodns" ]; then
35 cmdline="export UPDATE_RESOLVCONF=0;
36 $cmdline"
39 if [ "$CANUSESERVICE" == "1" ]; then
40 addcode up 5 1 "service_create $if '$cmdline -f' \
41 'sleep 2 ; ip link set $if down'"
42 addcode down 5 1 "service_destroy $if"
43 else
44 addcode up 5 5 "$cmdline"
45 addcode down 5 5 "killall -TERM udhcpc"
46 addcode down 5 5 "sleep 2 ; ip link set $if down"