#!/bin/sh

. /lib/functions.sh

fix_description() {
	local section="$1"
	local config="$2"
	local description _description proto
	config_get "proto" "$section" "proto"
	[ "$config" = "network" ] && [ "$proto" != "l2tp" ] && return
	config_get "description" "$section" "description"
	config_get "_name" "$section" "_name"
	[ -z "$description" ] && uci_set "$config" "$section" "description" "$section"
	[ -n "$_name" ] && uci_remove "$config" "$section" "_name"
}

config_load "network"
config_foreach "fix_description" "interface" "network"
uci_commit "network"
config_load "xl2tpd"
config_foreach "fix_description" "service" "xl2tpd"
uci_commit "xl2tpd"

exit 0
