Adding New Configuration Options to netkit.conf
When adding new configuration options to netkit.conf, adding the configuration option to netkit.conf is not sufficient. You must also add additional scripting to support updating user's existing configurations on reinstall.
This process is completed inside the netkit-jh-build/core/setup_scripts/handle_config.sh
script.
Let's look at adding a new option TUTORIAL_OPTION
. Firstly, we'll update the netkit.conf
file.
We've appended our new option to the end of the document. We'll also need to update bin/script_utils
with new defaults for our option.
Now, we need to look at the handle_config.sh
script. Notably, we can use the V1 -> V2 upgrade as a template.
As we've added a new option, we need to increment the CONFIG_VERSION to 3. This ensures that whenever a user installs a new version of Netkit-JH with an older config, the new options are added to their configuration.
note
You only need to increment the CONFIG_VERSION if a new Netkit-JH version has been fully released since the last config version update. Otherwise, you can add your changes into the existing version increment. If you are unsure, increment the version anyways and it will be checked before your changes are merged into master.
We've copied the V1 -> V2 section, replacing any instances of 2 with a 3, and any instances of a 1 with a 2. We can now look at actually updating the configuration now.
As we have a new option, we can simply append the string from in netkit.conf
Let's look at the entire update function together.
That's it! For new options, you will want to append a string to the end of the file. For removing options or modifying options, sed -i
is your friend.