Before a configuration is generated, an empty file is created to store
it in. (required by UCI)
If something happens during config generation
(power cut, interruption, ..) an empty file exists and it is never
regenerated again, causing some daemons to fail starting
(NTPD, logread, ..)
Fix this by also generating new configs if a critical file
is empty.
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
[ -n "$CFG" ] || CFG=/etc/board.json
-[ -d "/etc/board.d/" -a ! -f "$CFG" ] && {
+[ -d "/etc/board.d/" -a ! -s "$CFG" ] && {
for a in `ls /etc/board.d/*`; do
[ -x $a ] || continue;
$(. $a)
done
}
-[ -f "$CFG" ] || return 1
+[ -s "$CFG" ] || return 1
. /usr/share/libubox/jshn.sh
-[ -f $CFG ] || /bin/board_detect || exit 1
-[ -f /etc/config/network -a -f /etc/config/system ] && exit 0
+[ -s $CFG ] || /bin/board_detect || exit 1
+[ -s /etc/config/network -a -s /etc/config/system ] && exit 0
generate_static_network() {
uci -q batch <<-EOF
json_init
json_load "$(cat ${CFG})"
-if [ ! -f /etc/config/network ]; then
+if [ ! -s /etc/config/network ]; then
touch /etc/config/network
generate_static_network
for key in $keys; do generate_switch $key; done
fi
-if [ ! -f /etc/config/system ]; then
+if [ ! -s /etc/config/system ]; then
touch /etc/config/system
generate_static_system