Source in all available os.conf files

This commit is contained in:
Calin Crisan 2019-01-11 13:29:12 +02:00
parent df44e16f88
commit 3a06cf48de
4 changed files with 16 additions and 62 deletions

View File

@ -5,8 +5,6 @@ test -n "$os_version" || source /etc/init.d/base
sys_version_file="/etc/version"
version_file="/data/etc/version"
post_upgrade_dir="/usr/share/post-upgrade"
sys_os_conf="/etc/os.conf"
os_conf="/data/etc/os.conf"
hash=$(md5sum $version_file 2>/dev/null | cut -d ' ' -f 1)
sys_hash=$(md5sum $sys_version_file 2>/dev/null | cut -d ' ' -f 1)
@ -38,23 +36,10 @@ function run_post_upgrade() {
done
}
function update_os_conf() {
source $sys_os_conf
sys_vars=$(cat $sys_os_conf | cut -d '=' -f 1)
for var in $sys_vars; do
if ! grep "$var=" $os_conf &>/dev/null; then
msg_begin "Adding $var to os.conf"
echo "$var=\"${!var}\"" >> $os_conf
msg_done
fi
done
}
case "$1" in
start)
run_post_upgrade
cp $sys_version_file $version_file
update_os_conf
;;
stop)

View File

@ -12,36 +12,12 @@ sys_watch_conf="/etc/watch.conf"
boot_watch_conf="/boot/watch.conf"
watch_conf="/data/etc/watch.conf"
if ! [[ -f $watch_conf ]]; then
if [[ -f $boot_watch_conf ]]; then
cp $boot_watch_conf $watch_conf
elif [[ -f $sys_watch_conf ]]; then
cp $sys_watch_conf $watch_conf
fi
fi
prepare_conf $watch_conf $sys_watch_conf $boot_watch_conf
source $watch_conf
if [[ -f $boot_conf ]]; then
cp -f $boot_conf $conf
grep -E "/boot .*ro[\s,]" /proc/mounts
RO=$?
test $RO == 0 && mount -o remount,rw /boot
rm -f $boot_conf
test $RO == 0 && mount -o remount,ro /boot
fi
if ! [[ -f $conf ]]; then
if [[ -f $sys_conf ]]; then
cp $sys_conf $conf
fi
fi
prepare_conf $conf $sys_conf $boot_conf
test -f $conf || exit 0
# we want only Unix newlines here
sed -i 's/\r//g' $conf
ssid=$(cat $conf | grep ssid | grep -v scan_ssid | cut -d '"' -f 2)
test -n "$ssid" || exit 0

View File

@ -2,28 +2,20 @@
_sys_conf="/etc/os.conf"
_boot_conf="/boot/os.conf"
_conf="/data/etc/os.conf"
_data_conf="/data/etc/os.conf"
if ! [[ -d /data/etc ]]; then
# use boot/system variants if we don't have the data partition mounted
if [[ -f $_boot_conf ]]; then
source $_boot_conf
elif [[ -f $_sys_conf ]]; then
# source in all conf files in order of precedence
if [[ -f $_sys_conf ]]; then
source $_sys_conf
fi
return
fi
if ! [[ -f $_conf ]]; then
if [[ -f $_boot_conf ]]; then
cp $_boot_conf $_conf
elif [[ -f $_sys_conf ]]; then
cp $_sys_conf $_conf
fi
if [[ -f $_data_conf ]]; then
source $_data_conf
fi
if [[ -f $_conf ]]; then
source $_conf
if [[ -f $_boot_conf ]]; then
source $_boot_conf
fi
unset _sys_conf _boot_conf _data_conf

View File

@ -35,7 +35,6 @@ fi
SYS_VERSION_FILE=/etc/version
SYS_BOARD_FILE=/etc/board
OS_CONF=/data/etc/os.conf
MIN_FREE_DISK=$((500*1024)) # 500 MB
VER_FILE=version
@ -78,7 +77,8 @@ fi
#### versions ####
function show_versions() {
source $OS_CONF
source /etc/init.d/conf # we need this for the os_ vars
board=$(cat $SYS_BOARD_FILE)
show_json=$1
@ -144,7 +144,8 @@ function do_download() {
fi
fi
source $OS_CONF
source /etc/init.d/conf # we need this for the os_ vars
board=$(cat $SYS_BOARD_FILE)
url=$1
version=$1