ifupdown: Debian users contributed improvement to it
This commit is contained in:
parent
2e864cd219
commit
1c3577f91d
@ -452,45 +452,48 @@ static int static_down(struct interface_defn_t *ifd, execfn *exec)
|
|||||||
|
|
||||||
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
|
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
|
||||||
{
|
{
|
||||||
int i;
|
if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
|
||||||
|
"[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
|
||||||
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < ifd->n_options; i++) {
|
/* 2006-09-30: The following are deprecated, and should eventually be
|
||||||
if (strcmp(ifd->option[i].name, "dhcp-start-cmd") == 0) {
|
* removed. For non-busybox (i.e., other than udhcpc) clients, use
|
||||||
return execute(ifd->option[i].value, ifd, exec);
|
* 'iface foo inet manual' in /etc/network/interfaces, and supply
|
||||||
}
|
* start/stop commands explicitly via up/down. */
|
||||||
}
|
|
||||||
|
|
||||||
if (execute("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i "
|
if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
|
||||||
"%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec)) return 1;
|
ifd, exec)) return 1;
|
||||||
if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]", ifd, exec)) return 1;
|
if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
|
||||||
if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%", ifd, exec)) return 1;
|
ifd, exec)) return 1;
|
||||||
if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
|
if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
|
||||||
"[[-l %leasetime%]] %iface%", ifd, exec)) return 1;
|
"[[-l %leasetime%]] %iface%", ifd, exec)) return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
|
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
|
||||||
{
|
{
|
||||||
int i;
|
if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
|
||||||
|
ifd, exec)) return 1;
|
||||||
|
|
||||||
for (i = 0; i < ifd->n_options; i++) {
|
/* 2006-09-30: The following are deprecated, and should eventually be
|
||||||
if (strcmp(ifd->option[i].name, "dhcp-stop-cmd") == 0) {
|
* removed. For non-busybox (i.e., other than udhcpc) clients, use
|
||||||
return execute(ifd->option[i].value, ifd, exec);
|
* 'iface foo inet manual' in /etc/network/interfaces, and supply
|
||||||
}
|
* start/stop commands explicitly via up/down. */
|
||||||
}
|
|
||||||
|
|
||||||
/* SIGUSR2 forces udhcpc to release the current lease and go inactive,
|
|
||||||
* and SIGTERM causes udhcpc to exit. Signals are queued and processed
|
|
||||||
* sequentially so we don't need to sleep */
|
|
||||||
if (execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec)
|
|
||||||
|| execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec))
|
|
||||||
return 1;
|
|
||||||
if (execute("pump -i %iface% -k", ifd, exec)) return 1;
|
if (execute("pump -i %iface% -k", ifd, exec)) return 1;
|
||||||
if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec)) return 1;
|
if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
|
||||||
|
ifd, exec)) return 1;
|
||||||
if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;
|
if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;
|
||||||
|
|
||||||
return static_down(ifd, exec);
|
return static_down(ifd, exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int manual_up_down(struct interface_defn_t *ifd, execfn *exec)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int bootp_up(struct interface_defn_t *ifd, execfn *exec)
|
static int bootp_up(struct interface_defn_t *ifd, execfn *exec)
|
||||||
{
|
{
|
||||||
return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% "
|
return execute("bootpc [[--bootfile %bootfile%]] --dev %iface% "
|
||||||
@ -521,6 +524,7 @@ static int wvdial_down(struct interface_defn_t *ifd, execfn *exec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct method_t methods[] = {
|
static const struct method_t methods[] = {
|
||||||
|
{ "manual", manual_up_down, manual_up_down, },
|
||||||
{ "wvdial", wvdial_up, wvdial_down, },
|
{ "wvdial", wvdial_up, wvdial_down, },
|
||||||
{ "ppp", ppp_up, ppp_down, },
|
{ "ppp", ppp_up, ppp_down, },
|
||||||
{ "static", static_up, static_down, },
|
{ "static", static_up, static_down, },
|
||||||
|
Loading…
Reference in New Issue
Block a user