base-files: rework config generation logic
Now that config_generate is able to generate the entire /etc/config/system from scratch we can apply the same logic as used for /etc/config/network; when the configuration file exists already then do not do anything, else generate it from the values provided by /etc/board.json . In order to facilitate that move the file existance checking inside /bin/config_generate and call it unconditionally from /bin/board_detect. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
		| @@ -8,7 +8,5 @@ | |||||||
| } | } | ||||||
|  |  | ||||||
| [ -f "/etc/board.json" ] || return 1 | [ -f "/etc/board.json" ] || return 1 | ||||||
| [ -f "/etc/config/network" ] || { |  | ||||||
| 	touch /etc/config/network |  | ||||||
| /bin/config_generate | /bin/config_generate | ||||||
| } |  | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ CFG=/etc/board.json | |||||||
| . /usr/share/libubox/jshn.sh | . /usr/share/libubox/jshn.sh | ||||||
|  |  | ||||||
| [ -f $CFG ] || exit 1 | [ -f $CFG ] || exit 1 | ||||||
|  | [ -f /etc/config/network -a -f /etc/config/system ] && exit 0 | ||||||
|  |  | ||||||
| generate_static_network() { | generate_static_network() { | ||||||
| 	uci -q batch <<-EOF | 	uci -q batch <<-EOF | ||||||
| @@ -398,6 +399,8 @@ generate_gpioswitch() { | |||||||
| json_init | json_init | ||||||
| json_load "$(cat ${CFG})" | json_load "$(cat ${CFG})" | ||||||
|  |  | ||||||
|  | if [ ! -f /etc/config/network ]; then | ||||||
|  | 	touch /etc/config/network | ||||||
| 	generate_static_network | 	generate_static_network | ||||||
|  |  | ||||||
| 	json_get_keys keys network | 	json_get_keys keys network | ||||||
| @@ -405,8 +408,10 @@ for key in $keys; do generate_network $key; done | |||||||
|  |  | ||||||
| 	json_get_keys keys switch | 	json_get_keys keys switch | ||||||
| 	for key in $keys; do generate_switch $key; done | 	for key in $keys; do generate_switch $key; done | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | if [ ! -f /etc/config/system ]; then | ||||||
|  | 	touch /etc/config/system | ||||||
| 	generate_static_system | 	generate_static_system | ||||||
|  |  | ||||||
| 	json_get_keys keys rssimon | 	json_get_keys keys rssimon | ||||||
| @@ -417,5 +422,4 @@ for key in $keys; do generate_gpioswitch $key; done | |||||||
|  |  | ||||||
| 	json_get_keys keys led | 	json_get_keys keys led | ||||||
| 	for key in $keys; do generate_led $key; done | 	for key in $keys; do generate_led $key; done | ||||||
|  |  | ||||||
| uci commit | uci commit | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jo-Philipp Wich
					Jo-Philipp Wich