| 1 | #!/bin/bash |
| 2 | # Steven Shiau <[email protected]> |
| 3 | # License: GPL |
| 4 | # Description: To clean the dhcpd.leases then restart dhcpd |
| 5 | |
| 6 | # Load DRBL setting and functions |
| 7 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 8 | |
| 9 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 10 | |
| 11 | # |
| 12 | check_if_root |
| 13 | |
| 14 | # find the path of dhcpd.leases ($DHCPDLEASE_DIR), such as /var/lib/dhcp3 in debian or /var/lib/dhcp in FC1-4. |
| 15 | get_dhcpdlease_dir |
| 16 | |
| 17 | # drcp_srv_name is loaded from conf/drbl.conf |
| 18 | if is_systemd_init; then |
| 19 | /bin/systemctl stop $DHCP_SRV_NAME.service || /etc/init.d/$DHCP_SRV_NAME stop |
| 20 | fi |
| 21 | [ -f "$DHCPDLEASE_DIR/dhcpd.leases" ] && rm -f $DHCPDLEASE_DIR/dhcpd.leases |
| 22 | [ -f "$DHCPDLEASE_DIR/dhcpd.leases~" ] && rm -f $DHCPDLEASE_DIR/dhcpd.leases~ |
| 23 | touch $DHCPDLEASE_DIR/dhcpd.leases |
| 24 | if is_systemd_init; then |
| 25 | /bin/systemctl start $DHCP_SRV_NAME.service || /etc/init.d/$DHCP_SRV_NAME start |
| 26 | else |
| 27 | service $DHCP_SRV_NAME restart |
| 28 | fi |