I wouldn’t do it like that.
I would support partial files.
If you introduce new fields, we have to diff the files every time. Although we only want to set a handful of fields.
I would make the changes in the env file itself.
In the end of the file would check for the bootfile, which doesn’t have to be the complete file. Run it and delete it.
@jofemodo
I would suggest the following.
In config-on-boot (I didn’t see your changes, when I fixed something else today, btw.)
UPDATE_SYS_FLAG_FILE="/zynthian_update_sys"
if [ -z "$ZYNTHIAN_CONFIG_DIR" ]; then
echo "running /zynthian/config/zynthian_envars.sh"
source /zynthian/config/zynthian_envars.sh
fi
BOOT_CONFIG_FILE="/boot/initial_zynthian_envars.sh"
TEMP_CONFIG_FILE="zynthian_envars.sh.tmp"
DEST_CONFIG_FILE="$ZYNTHIAN_CONFIG_DIR/zynthian_envars.sh"
if [ -f $BOOT_CONFIG_FILE ]; then
cat $BOOT_CONFIG_FILE $DEST_CONFIG_FILE | awk -F'[=]' '{ if (a[$1]++ == 0 || $1!~/^export/ ) print $0 ; }' | awk -F'[#]' '{ if (a[$2]++ == 0 || !$2 ) print $0 ; }' > $TEMP_CONFIG_FILE
mv $TEMP_CONFIG_FILE $DEST_CONFIG_FILE
rm $BOOT_CONFIG_FILE
touch $UPDATE_SYS_FLAG_FILE
fi
# If flag-file does exist, call update_zynthian_sys.sh ...
if [ -f $UPDATE_SYS_FLAG_FILE ]; then
echo "running update_zynthian.sys.sh after boot"
$ZYNTHIAN_SYS_DIR/scripts/update_zynthian_sys.sh
rm -f "$UPDATE_SYS_FLAG_FILE"
fi
You have to scroll to see the awk command.
The initial_zynthian_envars.sh needs to have the same header/comments, so that the result contains them as well in the beginning.
Therefore we should deliver a sample file containing the values of the latest kit. (maybe with a “template” in the name and a comment that it has to be renamed.
It doesn’t work with a copy of the config file. Simply copy your envars file to the boot directory as “initial_zynthian_envars.sh” and boot and run the config-on-boot.sh script …
… the merged result file is not OK ;-(
I think the best option is to use the already existing and well tested zynconf functions (python) to manipulate the config file:
I will implement it ASAP, but if you are in a hurry, feel free to go forward with it …
The webconf source code is plenty of examples of how to use the zynconf functions.
prerequisite for my solution is, that you only consider the static export statements.
I would have separated the static from the dynamic part anyways.
That’s why I haven’t called it /boot/zynthian_envars.sh to not mislead ppl to use the dynamic script.
Your zynthian’s configuration can be updated on boot by simply putting a “zynthian_envars.sh” file on the “/boot” directory, that is easily mountable on all systems (windows, max & linux).
You can put a full config file (i.e. a zynthian_envars.sh backup) or update a bunch of parameters, like:
Did you test partial files?
I will have the first 4 blocks in my file only and expect the algorithm to fill the rest.
This is important, because the hardware-dependent part will be created once and be used the next years although we introduce new fields later.
ok.
It’s worth a trial then.
Nevertheless I don’t understand, how the complete envars are set when I put a file in /boot, that only contains 3 export statements
Yep, it works.
Now we(@jofemodo) could implement the fallback.
When you use a false config (wrong kit like “CUSTOM” instead of “Custom”) you will see the error screen. (at least if you have a customized V2)
In this case we could cp the backup to /zynthian/config and reboot