Basically we just read in the config, parsing the passed command line options (so we set the new value for he passed options) and writing the config back.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/dhcp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/src/hooks/configs/dhcp b/src/hooks/configs/dhcp index 8bb6aa9..98ef5e3 100644 --- a/src/hooks/configs/dhcp +++ b/src/hooks/configs/dhcp @@ -83,6 +83,46 @@ hook_new() { exit ${EXIT_OK} }
+hook_edit() { + local zone=${1} + local config=${2} + shift 2 + + if ! device_exists ${zone}; then + error "Zone '${zone}' doesn't exist." + exit ${EXIT_ERROR} + fi + + local ${HOOK_CONFIG_SETTINGS} + + # If reading the config fails we cannot go on + if ! zone_config_settings_read "${zone}" "${config}"; then + log ERROR "Could read the config ${config} for zone ${upl0}" + return ${EXIT_ERROR} + fi + + if ! hook_parse_cmdline $@; then + # Return an error if the parsing of the cmd line fails + return ${EXIT_ERROR} + fi + + # Check if the user disabled ipv4 and ipv6 + if ! enabled ENABLE_IPV6 && ! enabled ENABLE_IPV4; then + log ERROR "You disabled IPv6 and IPv4. At least one must be enabled" + return ${EXIT_ERROR} + fi + + local hook="${config//.[[:digit:]]/}" + local id="${config//"${hook}."/}" + + if ! zone_config_settings_write "${zone}" "${hook}" ${id}; then + log ERROR "Could not write config settings file ${config} for ${zone}" + return ${EXIT_ERROR} + fi + + exit ${EXIT_OK} +} + hook_up() { local zone=${1} local config=${2}