]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/networking/functions.network
3 ########################################################################
6 # Description : A collection of functions for the IPFire network scripts
8 # Authors : IPFire Development Team <developers@ipfire.org>
14 ########################################################################
20 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/ethernet
/settings
)
21 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/dns
/settings
)
24 # This function returns the pid of a dhcpcd by a given
25 # network device, if a pidfile exists.
28 local pidfile
="/var/run/dhcpcd-${device}.pid"
30 # Check if a pid file exists.
31 if [ -f "${pidfile}" ] ; then
33 # Get the pid from the file.
34 local pid
="$(<"${pidfile}")"
41 # This functions checks if a dhcpcd is running by a given pid.
45 # Check if a dhcpcd is running.
46 if [ -n "${pid}" -a -d "/proc/${pid}" ]; then
47 # Return "0" (True) if a dhcpcd is running.
51 # Return 1 (False) no dhcpcd is running.
56 # This function will start a dhcpcd on a speciefied device.
61 boot_mesg
-n "Starting dhcpcd on the ${device} interface..."
63 # Check if a dhcpcd is already running.
64 local pid
="$(dhcpcd_get_pid "${device}")"
66 if dhcpcd_is_running
"${pid}"; then
67 boot_mesg
"dhcpcd already running!" ${WARNING}
72 # Check if a DHCP hostname has been set.
73 if [ -n "${RED_DHCP_HOSTNAME}" ]; then
74 dhcp_start
+="-h ${RED_DHCP_HOSTNAME}"
78 /sbin
/dhcpcd
"${device}" "${dhcp_start}" >/dev
/null
2>&1
81 if [ "${ret}" -eq 0 ]; then
82 .
/var
/ipfire
/dhcpc
/dhcpcd-
"${device}".info
85 boot_mesg
" DHCP Assigned Settings for ${device}:"
87 boot_mesg
" IP Address: $ip_address"
90 if [ -n "${RED_DHCP_HOSTNAME}" ]; then
91 boot_mesg
" Hostname: $RED_DHCP_HOSTNAME"
95 boot_mesg
" Subnet Mask: $subnet_mask"
97 boot_mesg
" Default Gateway: $routers"
99 boot_mesg
" DNS Server: $domain_name_servers"
109 # This function stops a previously started dhcpcd on a given device.
113 local leaseinfo
="/var/ipfire/dhcpc/dhcpcd-${device}.info"
115 boot_mesg
-n "Stopping dhcpcd on the ${device} interface..."
117 # Check if a dhcpcd is running.
118 local pid
="$(dhcpcd_get_pid "${device}")"
120 if ! dhcpcd_is_running
"${pid}"; then
121 boot_mesg
" Not running." ${WARNING}
127 /sbin
/dhcpcd
"${device}" "${dhcp_stop}" &> /dev
/null
130 # Wait until dhcpd has stopped.
131 while [ -d "/proc/${pid}" ]; do
135 # Display console message, depended on the exit code
136 # of the stopped dhcpcd.
137 if [ "${ret}" -eq 0 ]; then
140 elif [ "${ret}" -eq 1 ]; then
141 boot_mesg
"failed to stop dhcpcd!" ${WARNING}