diff options
author | Jo-Philipp Wich <jo@mein.io> | 2016-05-31 14:47:30 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2016-06-08 00:34:02 +0200 |
commit | b98f78b1c15f1593b508c58fc9a34f90b1e58081 (patch) | |
tree | a72ca575dab6a2c6398063589bdf872ab1d19e0d /package/base-files/files/bin | |
parent | 82768561c4709bab4c278c426fdf5ded14f4d5e8 (diff) | |
download | master-31e0f0ae-b98f78b1c15f1593b508c58fc9a34f90b1e58081.tar.gz master-31e0f0ae-b98f78b1c15f1593b508c58fc9a34f90b1e58081.tar.bz2 master-31e0f0ae-b98f78b1c15f1593b508c58fc9a34f90b1e58081.zip |
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>
Diffstat (limited to 'package/base-files/files/bin')
-rwxr-xr-x | package/base-files/files/bin/board_detect | 6 | ||||
-rwxr-xr-x | package/base-files/files/bin/config_generate | 32 |
2 files changed, 20 insertions, 18 deletions
diff --git a/package/base-files/files/bin/board_detect b/package/base-files/files/bin/board_detect index ee04b9e64d..beb7f4e659 100755 --- a/package/base-files/files/bin/board_detect +++ b/package/base-files/files/bin/board_detect @@ -8,7 +8,5 @@ } [ -f "/etc/board.json" ] || return 1 -[ -f "/etc/config/network" ] || { - touch /etc/config/network - /bin/config_generate -} + +/bin/config_generate diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index 428c6bd9de..fe5fa85c87 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -5,6 +5,7 @@ CFG=/etc/board.json . /usr/share/libubox/jshn.sh [ -f $CFG ] || exit 1 +[ -f /etc/config/network -a -f /etc/config/system ] && exit 0 generate_static_network() { uci -q batch <<-EOF @@ -398,24 +399,27 @@ generate_gpioswitch() { json_init json_load "$(cat ${CFG})" -generate_static_network +if [ ! -f /etc/config/network ]; then + touch /etc/config/network + generate_static_network -json_get_keys keys network -for key in $keys; do generate_network $key; done + json_get_keys keys network + for key in $keys; do generate_network $key; done -json_get_keys keys switch -for key in $keys; do generate_switch $key; done + json_get_keys keys switch + 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 + for key in $keys; do generate_rssimon $key; done -json_get_keys keys rssimon -for key in $keys; do generate_rssimon $key; done - -json_get_keys keys gpioswitch -for key in $keys; do generate_gpioswitch $key; done - -json_get_keys keys led -for key in $keys; do generate_led $key; done + json_get_keys keys gpioswitch + for key in $keys; do generate_gpioswitch $key; done + json_get_keys keys led + for key in $keys; do generate_led $key; done uci commit |