Skip to content

Commit

Permalink
add a dhcp restart command; requested by Tom
Browse files Browse the repository at this point in the history
  • Loading branch information
stspdotname committed Sep 25, 2023
1 parent eb5d12f commit 16a04e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions ctl.c
Expand Up @@ -89,6 +89,7 @@ void install_crontab(char *);
void edit_motd(char *);
void call_editor(char *, char **, char *);
void start_dhcpd(char *, char *, char *, char *, char *);
void restart_dhcpd(char *, char *, char *, char *, char *);
int edit_file(char *, mode_t, char *, char **);
void ctl_symlink(char *, char *, char *);
int rule_writeline(char *, mode_t, char *);
Expand Down Expand Up @@ -450,6 +451,9 @@ struct ctl2 ctl_dhcp[] = {
{ "config-test", "test staged DHCPd config",
{ DHCPD, "-nc", REQTEMP, "-l", DHCPLEASES, NULL }, { NULL, },
NULL, 0, T_EXEC },
{ "restart", "restart DHCPd daemon",
{ DHCPD, "-c", REQTEMP, "-l", DHCPLEASES, NULL }, { NULL, },
restart_dhcpd, DB_X_ENABLE, T_HANDLER },
{ NULL, NULL, { NULL }, { NULL }, NULL, 0, 0 }
};

Expand Down Expand Up @@ -819,6 +823,16 @@ ctlhandler(int argc, char **argv, char *modhvar)
return rv;
}

void
restart_dhcpd(char *arg0, char *arg1, char *arg2, char *arg3, char *arg4)
{
char *argv_pkill[] = { PKILL, table, "dhcpd", NULL };

cmdargs(argv_pkill[0], argv_pkill);
sleep(1);
start_dhcpd(arg0, arg1, arg2, arg3, arg4);
}

/*
* Copy arguments from fillargs to tmp_args with temporary filenames
* expanded. Return the number of arguments stored in tmp_args.
Expand Down
8 changes: 6 additions & 2 deletions nsh.8
Expand Up @@ -1319,11 +1319,12 @@ nsh(config-p)/sasync
.Tg dhcpd
.Tg dhcp
.Ic dhcp
.Op Cm \&? | enable | disable | edit
.Op Cm \&? | enable | disable | edit | restart
.Pp
Enable or disable or configure the
Enable, disable, configure, or restart the
.Xr dhcpd 8
Dynamic Host Configuration Protocol daemon.
This daemon acts as a DHCP server.
The configuration of
.Ic dhcp
daemon can be edited with
Expand All @@ -1332,6 +1333,9 @@ command, the configuration syntax of
.Ic dhcp
daemon is documented in
.Xr dhcpd.conf 5 .
Configuration file changes will not take effect until
.Xr dhcpd 8
is restarted.
.Pp
.Tg snmpd
.Tg snmp
Expand Down

0 comments on commit 16a04e0

Please sign in to comment.