aboutsummaryrefslogtreecommitdiff
path: root/utils/watchcat/files/migrate-watchcat
blob: 6a0528717702518c45aad3eaf6de898c5a25c8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

. /lib/functions.sh

upgrade_watchcat() {
	local cfg="$1"

	config_get period "$cfg" period
	config_get mode "$cfg" mode
	config_get pinghosts "$cfg" pinghosts
	config_get forcedelay "$cfg" forcedelay

	[ -f "/etc/config/watchcat" ] || touch /etc/config/watchcat
	uci_add watchcat watchcat
	uci_set watchcat @watchcat[-1] period "$period"
	uci_set watchcat @watchcat[-1] mode "$mode"
	uci_set watchcat @watchcat[-1] pinghosts "$pinghosts"
	uci_set watchcat @watchcat[-1] forcedelay "$forcedelay"

	uci_remove system "$cfg"
}

config_load system
config_foreach upgrade_watchcat watchcat

uci_commit watchcat
uci commit system