Wireless Access Point Setup

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.

As i explained above, it’s not perfect, but it works right now. I would improve the “feature” for parsing and merging with the system’s config file.

@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.

1 Like

Hi @mheidt!

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.

Regards,

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.

But I can wait for your solution.

It’s ready:

I hope you didn’t await too much :yum:

Resuming, @zynthianers:

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:

export ZYNTHIAN_UI_SWITCH_BOLD_MS="200"
export ZYNTHIAN_UI_SWITCH_LONG_MS="600"
export ZYNTHIAN_UI_SHOW_CPU_STATUS="1"

Of course:

  • A backup is done on “/zynthian/config/zynthian_envars_backup.sh” before updating the config
  • The “/boot/zynthian_envars.sh” file is deleted after updating the config

I hope this little new feature will help to ease zynthian configuration process.

Enjoy!

P.S: A wiki entry should be added … some volunteer in da house? :wink:

1 Like

why did you remove this?

if [ -z “$ZYNTHIAN_CONFIG_DIR” ]; then
echo “running /zynthian/config/zynthian_envars.sh”
source /zynthian/config/zynthian_envars.sh
fi

This is needed for

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.

It shouldn’t be needed. I included the $ZYNTHIAN_CONFIG_DIR envar in the service file.

Of course. I’ve explained this in my post above:

Regards,

ZYNTHIAN_CONFIG_DIR was empty. I debugged it.
See what I wrote in the github issue

why are you calling exit, when the file in boot is taken?
Isn’t the update_sys not needed?
Especially to correct the AudioInjector amixer settings?

I fixed this problem yesterday, adding the envar to the service file.

Regards,

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

update_envars.py (that uses the zynconf library) call zynthian_update_sys.sh after saving the config file, so no need to call it twice.

Check this out:

It uses the zynconf library, same as the webconf.

Regards,

Yes, I overlooked, that the 3rd parameter of save is empty

Didn’t you test it yet??? :scream_cat: :scream_cat:

Of course not.
I didn’t know about " adding the envar to the service file."
:slight_smile:

It must be empty for this case …

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