aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:20 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:20 -0800
commitd97c47cad830d00c9da685cc4ea157d6185f6c97 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /dhcpcd-hooks
parent4c5a5fb53bccceff331bae70f748bf9b4609fe0a (diff)
downloadexternal_dhcpcd-d97c47cad830d00c9da685cc4ea157d6185f6c97.zip
external_dhcpcd-d97c47cad830d00c9da685cc4ea157d6185f6c97.tar.gz
external_dhcpcd-d97c47cad830d00c9da685cc4ea157d6185f6c97.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'dhcpcd-hooks')
-rw-r--r--dhcpcd-hooks/01-test7
-rw-r--r--dhcpcd-hooks/10-mtu5
-rw-r--r--dhcpcd-hooks/20-dns.conf32
-rw-r--r--dhcpcd-hooks/20-resolv.conf107
-rw-r--r--dhcpcd-hooks/29-lookup-hostname34
-rw-r--r--dhcpcd-hooks/30-hostname28
-rw-r--r--dhcpcd-hooks/50-dhcpcd-compat31
-rw-r--r--dhcpcd-hooks/50-ntp.conf82
-rw-r--r--dhcpcd-hooks/50-yp.conf49
-rw-r--r--dhcpcd-hooks/90-NetworkManager8
-rw-r--r--dhcpcd-hooks/95-configured26
-rw-r--r--dhcpcd-hooks/Makefile13
12 files changed, 0 insertions, 422 deletions
diff --git a/dhcpcd-hooks/01-test b/dhcpcd-hooks/01-test
deleted file mode 100644
index 609b3a1..0000000
--- a/dhcpcd-hooks/01-test
+++ /dev/null
@@ -1,7 +0,0 @@
-# Just echo our DHCP options we have
-
-case ${reason} in
-TEST) set | grep "^\(interface\|metric\|pid\|reason\|skip_hooks\)=" | sort
- set | grep "^\(new_\|old_\)" | sort
- ;;
-esac
diff --git a/dhcpcd-hooks/10-mtu b/dhcpcd-hooks/10-mtu
deleted file mode 100644
index 4265b48..0000000
--- a/dhcpcd-hooks/10-mtu
+++ /dev/null
@@ -1,5 +0,0 @@
-# Configure the MTU for the interface
-
-if [ -n "${new_interface_mtu}" ]; then
- ifconfig "${interface}" mtu "${new_interface_mtu}"
-fi
diff --git a/dhcpcd-hooks/20-dns.conf b/dhcpcd-hooks/20-dns.conf
deleted file mode 100644
index a92e91d..0000000
--- a/dhcpcd-hooks/20-dns.conf
+++ /dev/null
@@ -1,32 +0,0 @@
-# Set net.<iface>.dnsN properties that contain the
-# DNS server addresses given by the DHCP server.
-
-set_dns_props()
-{
- case "${new_domain_name_servers}" in
- "") return 0;;
- esac
-
- count=1
- for i in 1 2 3 4; do
- setprop dhcp.${interface}.dns${i} ""
- done
-
- count=1
- for dnsaddr in ${new_domain_name_servers}; do
- setprop dhcp.${interface}.dns${count} ${dnsaddr}
- count=$(($count + 1))
- done
-}
-
-unset_dns_props()
-{
- for i in 1 2 3 4; do
- setprop dhcp.${interface}.dns${i} ""
- done
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;;
-EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;;
-esac
diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf
deleted file mode 100644
index e757ddf..0000000
--- a/dhcpcd-hooks/20-resolv.conf
+++ /dev/null
@@ -1,107 +0,0 @@
-# Generate /etc/resolv.conf
-# Support resolvconf(8) if available
-# We can merge other dhcpcd resolv.conf files into one like resolvconf,
-# but resolvconf is preferred as other applications like VPN clients
-# can readily hook into it.
-# Also, resolvconf can configure local nameservers such as bind
-# or dnsmasq. This is important as the libc resolver isn't that powerful.
-
-resolv_conf_dir="${state_dir}/resolv.conf"
-
-build_resolv_conf()
-{
- local cf="/etc/resolv.conf.${interface}"
- local interfaces= header= search= srvs= servers= x=
-
- # Build a list of interfaces
- interfaces=$(list_interfaces "${resolv_conf_dir}")
-
- # Build the resolv.conf
- if [ -n "${interfaces}" ]; then
- # Build the header
- for x in ${interfaces}; do
- header="${header}${header:+, }${x}"
- done
-
- # Build the search list
- search=$(cd "${resolv_conf_dir}"; \
- key_get_value "search " ${interfaces})
- [ -n "${search}" ] && search="search $(uniqify ${search})\n"
-
- # Build the nameserver list
- srvs=$(cd "${resolv_conf_dir}"; \
- key_get_value "nameserver " ${interfaces})
- for x in $(uniqify ${srvs}); do
- servers="${servers}nameserver ${x}\n"
- done
- fi
- header="${signature_base}${header:+ ${from} }${header}"
-
- # Assemble resolv.conf using our head and tail files
- [ -f "${cf}" ] && rm -f "${cf}"
- echo "${header}" > "${cf}"
- if [ -f /etc/resolv.conf.head ]; then
- cat /etc/resolv.conf.head >> "${cf}"
- else
- echo "# /etc/resolv.conf.head can replace this line" >> "${cf}"
- fi
- printf "${search}${servers}" >> "${cf}"
- if [ -f /etc/resolv.conf.tail ]; then
- cat /etc/resolv.conf.tail >> "${cf}"
- else
- echo "# /etc/resolv.conf.tail can replace this line" >> "${cf}"
- fi
- mv -f "${cf}" /etc/resolv.conf
-}
-
-add_resolv_conf()
-{
- local x= conf="${signature}\n"
-
- # If we don't have any configuration, remove it
- if [ -z "${new_domain_name_servers}" -a \
- -z "${new_domain_name}" -a \
- -z "${new_domain_search}" ]; then
- remove_resolv_conf
- return $?
- fi
-
- if [ -n "${new_domain_search}" ]; then
- conf="${conf}search ${new_domain_search}\n"
- elif [ -n "${new_domain_name}" ]; then
- conf="${conf}search ${new_domain_name}\n"
- fi
- for x in ${new_domain_name_servers}; do
- conf="${conf}nameserver ${x}\n"
- done
- if type resolvconf >/dev/null 2>&1; then
- printf "${conf}" | resolvconf -a "${interface}"
- return $?
- fi
-
- if [ -e "${resolv_conf_dir}/${interface}" ]; then
- rm -f "${resolv_conf_dir}/${interface}"
- fi
- if [ ! -d "${resolv_conf_dir}" ]; then
- mkdir -p "${resolv_conf_dir}"
- fi
- printf "${conf}" > "${resolv_conf_dir}/${interface}"
- build_resolv_conf
-}
-
-remove_resolv_conf()
-{
- if type resolvconf >/dev/null 2>&1; then
- resolvconf -d "${interface}" -f
- else
- if [ -e "${resolv_conf_dir}/${interface}" ]; then
- rm -f "${resolv_conf_dir}/${interface}"
- fi
- build_resolv_conf
- fi
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) add_resolv_conf;;
-PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_resolv_conf;;
-esac
diff --git a/dhcpcd-hooks/29-lookup-hostname b/dhcpcd-hooks/29-lookup-hostname
deleted file mode 100644
index 3dfade3..0000000
--- a/dhcpcd-hooks/29-lookup-hostname
+++ /dev/null
@@ -1,34 +0,0 @@
-# Lookup the hostname in DNS if not set
-
-lookup_hostname()
-{
- [ -z "${new_ip_address}" ] && return 1
- local h=
- # Silly ISC programs love to send error text to stdout
- if type dig >/dev/null 2>&1; then
- h=`dig +short -x ${new_ip_address}`
- if [ $? = 0 ]; then
- echo "${h}" | sed 's/\.$//'
- return 0
- fi
- elif type host >/dev/null 2>&1; then
- h=`host ${new_ip_address}`
- if [ $? = 0 ]; then
- echo "${h}" \
- | sed 's/.* domain name pointer \(.*\)./\1/'
- return 0
- fi
- fi
- return 1
-}
-
-set_hostname()
-{
- if [ -z "${new_host_name}" -a -z "${new_fqdn_name}" ]; then
- export new_host_name="$(lookup_hostname)"
- fi
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_hostname;;
-esac
diff --git a/dhcpcd-hooks/30-hostname b/dhcpcd-hooks/30-hostname
deleted file mode 100644
index b2e5fc8..0000000
--- a/dhcpcd-hooks/30-hostname
+++ /dev/null
@@ -1,28 +0,0 @@
-# Set the hostname from DHCP data if required
-
-need_hostname()
-{
- case "$(hostname)" in
- ""|"(none)"|localhost|localhost.localdomain)
- [ -n "${new_host_name}" -o -n "${new_fqdn_name}" ];;
- "${old_host_name}"|"${old_fqdn_name}")
- true;;
- *)
- false;;
- esac
-}
-
-set_hostname()
-{
- if need_hostname; then
- if [ -n "${new_host_name}" ]; then
- hostname "${new_host_name}"
- else
- hostname "${new_fqdn_name}"
- fi
- fi
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_hostname;;
-esac
diff --git a/dhcpcd-hooks/50-dhcpcd-compat b/dhcpcd-hooks/50-dhcpcd-compat
deleted file mode 100644
index cba40a4..0000000
--- a/dhcpcd-hooks/50-dhcpcd-compat
+++ /dev/null
@@ -1,31 +0,0 @@
-# Compat enter hook shim for older dhcpcd versions
-
-IPADDR=${new_ip_address}
-INTERFACE=${interface}
-NETMASK=${new_subnet_mask}
-BROADCAST=${new_broadcast_address}
-NETWORK=${new_network_number}
-DHCPSID=${new_dhcp_server_identifier}
-GATEWAYS=${new_routers}
-DNSSERVERS=${new_domain_name_servers}
-DNSDOMAIN=${new_domain_name}
-DNSSEARCH=${new_domain_search}
-NISDOMAIN=${new_nis_domain}
-NISSERVERS=${new_nis_servers}
-NTPSERVERS=${new_ntp_servers}
-
-GATEWAY=
-for x in ${new_routers}; do
- GATEWAY="${GATEWAY}${GATEWAY:+,}${x}"
-done
-DNS=
-for x in ${new_domain_name_servers}; do
- DNS="${DNS}${DNS:+,}${x}"
-done
-
-x="down"
-case "${reason}" in
-RENEW) x="up";;
-BOUND|INFORM|REBIND|REBOOT|TEST|TIMEOUT|IPV4LL) x="new";;
-esac
-set -- "" "${x}"
diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf
deleted file mode 100644
index 536f14e..0000000
--- a/dhcpcd-hooks/50-ntp.conf
+++ /dev/null
@@ -1,82 +0,0 @@
-# Sample dhcpcd hook script for ntp
-# Like our resolv.conf hook script, we store a database of ntp.conf files
-# and merge into /etc/ntp.conf
-
-# Detect OpenRC or BSD rc
-# Distributions may want to just have their command here instead of this
-if type rc-service >/dev/null 2>&1 && rc-service --exists ntpd; then
- ntpd_restart_cmd="rc-service ntpd -- --ifstarted --quiet restart"
-elif [ -x /etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/etc/rc.d/ntpd restart"
-elif [ -x /usr/local/etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/usr/local/etc/rc.d/ntpd restart"
-fi
-
-ntp_conf_dir="${state_dir}/ntp.conf"
-
-build_ntp_conf()
-{
- local cf="/etc/ntp.conf.${interface}"
- local interfaces= header= srvs= servers= x=
-
- # Build a list of interfaces
- interfaces=$(list_interfaces "${ntp_conf_dir}")
-
- if [ -n "${interfaces}" ]; then
- # Build the header
- for x in ${interfaces}; do
- header="${header}${header:+, }${x}"
- done
-
- # Build a server list
- srvs=$(cd "${ntp_conf_dir}";
- key_get_value "server " ${interfaces})
- if [ -n "${srvs}" ]; then
- for x in $(uniqify ${srvs}); do
- servers="${servers}server ${x}\n"
- done
- fi
- fi
-
- # Merge our config into ntp.conf
- [ -e "${cf}" ] && rm -f "${cf}"
- remove_markers "${signature_base}" "${signature_base_end}" \
- /etc/ntp.conf > "${cf}"
- if [ -n "${servers}" ]; then
- echo "${signature_base}${header:+ ${from} }${header}" >> "${cf}"
- printf "${search}${servers}" >> "${cf}"
- echo "${signature_base_end}${header:+ ${from} }${header}" >> "${cf}"
- fi
-
- # If we changed anything, restart ntpd
- if change_file /etc/ntp.conf "${cf}"; then
- [ -n "${ntpd_restart_cmd}" ] && ${ntpd_restart_cmd}
- fi
-}
-
-add_ntp_conf()
-{
- local cf="${ntp_conf_dir}/${interface}" x=
-
- [ -e "${cf}" ] && rm "${cf}"
- [ -d "${ntp_conf_dir}" ] || mkdir -p "${ntp_conf_dir}"
- if [ -n "${new_ntp_servers}" ]; then
- for x in ${new_ntp_servers}; do
- echo "server ${x}" >> "${cf}"
- done
- fi
- build_ntp_conf
-}
-
-remove_ntp_conf()
-{
- if [ -e "${ntp_conf_dir}/${interface}" ]; then
- rm "${ntp_conf_dir}/${interface}"
- fi
- build_ntp_conf
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) add_ntp_conf add;;
-PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_ntp_conf del;;
-esac
diff --git a/dhcpcd-hooks/50-yp.conf b/dhcpcd-hooks/50-yp.conf
deleted file mode 100644
index a2296eb..0000000
--- a/dhcpcd-hooks/50-yp.conf
+++ /dev/null
@@ -1,49 +0,0 @@
-# Sample dhcpcd hook for ypbind
-# This script is only suitable for the Linux version.
-
-ypbind_pid()
-{
- [ -s /var/run/ypbind.pid ] && cat /var/run/ypbind.pid
-}
-
-make_yp_conf()
-{
- [ -z "${new_nis_domain}" -a -z "${new_nis_servers}" ] && return 0
- local cf=/etc/yp.conf."${interface}" prefix= x= pid=
- rm -f "${cf}"
- echo "${signature}" > "${cf}"
- if [ -n "${new_nis_domain}" ]; then
- domainname "${new_nis_domain}"
- if [ -n "${new_nis_servers}" ]; then
- prefix="domain ${new_nis_domain} server "
- else
- echo "domain ${new_nis_domain} broadcast" >> "${cf}"
- fi
- else
- prefix="ypserver "
- fi
- for x in ${new_nis_servers}; do
- echo "${prefix}${x}" >> "${cf}"
- done
- save_conf /etc/yp.conf
- mv -f "${cf}" /etc/yp.conf
- pid="$(ypbind_pid)"
- if [ -n "${pid}" ]; then
- kill -HUP "${pid}"
- fi
-}
-
-restore_yp_conf()
-{
- [ -n "${old_nis_domain}" ] && domainname ""
- restore_conf /etc/yp.conf || return 0
- local pid="$(ypbind_pid)"
- if [ -n "${pid}" ]; then
- kill -HUP "${pid}"
- fi
-}
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) make_yp_conf;;
-EXPIRE|FAIL|IPV4LL|RELEASE|STOP) restore_yp_conf;;
-esac
diff --git a/dhcpcd-hooks/90-NetworkManager b/dhcpcd-hooks/90-NetworkManager
deleted file mode 100644
index c4d69fe..0000000
--- a/dhcpcd-hooks/90-NetworkManager
+++ /dev/null
@@ -1,8 +0,0 @@
-# Hook for NetworkManager-0.7.0
-# NOTE: NetworkManager will override the script dhcpcd calls, so this hook
-# only makes sense if NetworkManager is patched NOT to override the
-# script dhcpcd would call.
-
-if [ -x /usr/libexec/nm-dhcp-client.action ]; then
- /usr/libexec/nm-dhcp-client.action
-fi
diff --git a/dhcpcd-hooks/95-configured b/dhcpcd-hooks/95-configured
deleted file mode 100644
index 93f1c43..0000000
--- a/dhcpcd-hooks/95-configured
+++ /dev/null
@@ -1,26 +0,0 @@
-# This script runs last, after all network configuration
-# has completed. It sets a property to let the framework
-# know that setting up the interface is complete.
-
-# For debugging:
-setprop dhcp.${interface}.reason "${reason}"
-
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)
- setprop dhcp.${interface}.ipaddress "${new_ip_address}"
- setprop dhcp.${interface}.gateway "${new_routers%% *}"
- setprop dhcp.${interface}.mask "${new_subnet_mask}"
- setprop dhcp.${interface}.leasetime "${new_dhcp_lease_time}"
- setprop dhcp.${interface}.server "${new_dhcp_server_identifier}"
-
- setprop dhcp.${interface}.result "ok"
- ;;
-
-EXPIRE|FAIL|IPV4LL|STOP)
- setprop dhcp.${interface}.result "failed"
- ;;
-
-RELEASE)
- setprop dhcp.${interface}.result "released"
- ;;
-esac
diff --git a/dhcpcd-hooks/Makefile b/dhcpcd-hooks/Makefile
deleted file mode 100644
index cfb19f7..0000000
--- a/dhcpcd-hooks/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-LIBEXECDIR?= ${PREFIX}/libexec
-HOOKDIR= ${LIBEXECDIR}/dhcpcd-hooks
-SYSTEMSCRIPTS= 01-test 10-mtu 20-resolv.conf 30-hostname
-FILES= ${SYSTEMSCRIPTS} ${HOOKSCRIPTS}
-FILESDIR= ${HOOKDIR}
-
-all:
-
-MK= ../mk
-include ${MK}/os.mk
-include ${MK}/sys.mk
-include ${MK}/files.mk
-install: _filesinstall