mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 11:13:24 +02:00
Move network initscripts to src/initscripts/networking
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
This commit is contained in:
90
src/initscripts/networking/dhcpcd.exe
Normal file
90
src/initscripts/networking/dhcpcd.exe
Normal file
@@ -0,0 +1,90 @@
|
||||
########################################################################
|
||||
# Begin
|
||||
#
|
||||
# Description : DHCP Client Script
|
||||
#
|
||||
# Authors : Arne Fitzenreiter - arne_f@ipfire.org
|
||||
#
|
||||
# Version : 02.00
|
||||
#
|
||||
# Notes :
|
||||
#
|
||||
########################################################################
|
||||
|
||||
. /etc/sysconfig/rc
|
||||
. $rc_functions
|
||||
|
||||
|
||||
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
|
||||
eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
|
||||
|
||||
dhcpcd_up()
|
||||
{
|
||||
set | grep "^new_" | sed "s|^new_||g" | \
|
||||
sort > /var/ipfire/dhcpc/dhcpcd-$interface.info
|
||||
|
||||
#Check if this was the Red device...
|
||||
if [ ! "$interface" == "$RED_DEV" ]; then
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# Only if RED_TYPE=DHCP update /var/ipfire/red
|
||||
if [ "$RED_TYPE" == "DHCP" ]; then
|
||||
|
||||
#Check if we have to restart the services at update
|
||||
[ ! -e "/var/ipfire/red/active" ] && update=1;
|
||||
if [ "$old_domain_name_service" != "$new_domain_name_service" ]; then
|
||||
update=1;
|
||||
fi
|
||||
if [ "$old_ip_address" != "$new_ip_address" ]; then
|
||||
update=1;
|
||||
fi
|
||||
if [ "$old_routers" != "$new_routers" ]; then
|
||||
update=1;
|
||||
fi
|
||||
|
||||
#Get DNS from dhcp
|
||||
if [ -n "$DNS0" ] && [ -n "$DNS1" ]; then
|
||||
logger -p local0.info -t dhcpcd.exe[$$] "Overwritting DNS-Server addresses with ${DNS0},${DNS1}"
|
||||
echo -n ${DNS0} > /var/ipfire/red/dns1
|
||||
echo -n ${DNS1} > /var/ipfire/red/dns2
|
||||
else
|
||||
echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1
|
||||
echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2
|
||||
fi
|
||||
|
||||
#Get IP Address
|
||||
echo -n "$new_ip_address" > /var/ipfire/red/local-ipaddress
|
||||
|
||||
#Get default gateway
|
||||
grep -v -E "\<gateway\>" /etc/hosts > /tmp/hosts
|
||||
echo "$new_routers gateway" >> /tmp/hosts
|
||||
mv /tmp/hosts /etc/hosts
|
||||
|
||||
fi
|
||||
if [ $update ]; then
|
||||
[ -e "/var/ipfire/red/active" ] || touch /var/ipfire/red/active
|
||||
echo -n "$new_routers" > /var/ipfire/red/remote-ipaddress
|
||||
logger -p local0.info -t dhcpcd.exe[$$] "$interface has been (re)configured with IP=$new_ip_address"
|
||||
run_subdir ${rc_base}/init.d/networking/red.up/
|
||||
touch /var/ipfire/red/active
|
||||
fi
|
||||
}
|
||||
|
||||
dhcpcd_down()
|
||||
{
|
||||
set | grep "^new_" | sed "s|^new_||g" | \
|
||||
sort > /var/ipfire/dhcpc/dhcpcd-$interface.info
|
||||
|
||||
# Only if RED_TYPE=DHCP update /var/ipfire/red
|
||||
if [ "$RED_TYPE" == "DHCP" ]; then
|
||||
logger -p local0.info -t dhcpcd.exe[$$] "${interface} has been brought down"
|
||||
rm -f /var/ipfire/red/active
|
||||
run_subdir ${rc_base}/init.d/networking/red.down/
|
||||
fi
|
||||
}
|
||||
|
||||
case "$reason" in
|
||||
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) dhcpcd_up;;
|
||||
PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) dhcpcd_down;;
|
||||
esac
|
||||
Reference in New Issue
Block a user