Giter Site home page Giter Site logo

openwisp / openwisp-config Goto Github PK

View Code? Open in Web Editor NEW
372.0 26.0 56.0 425 KB

OpenWRT configuration agent for OpenWISP Controller

Home Page: http://openwisp.org

License: GNU General Public License v3.0

Makefile 2.67% Shell 35.07% Lua 62.27%
openwisp openwrt lede configuration-management networking wifi-configuration hacktoberfest

openwisp-config's Introduction

openwisp-config

ci build support chat

OpenWISP Controller agent for OpenWrt.

Want to help OpenWISP? Find out how to help us grow here.

Want a quick overview of OpenWISP? Try the OpenWISP Demo.


Install precompiled package

First run:

opkg update

Then install one of the latest builds:

opkg install <URL>

Where <URL> is the URL of the precompiled openwisp-config package.

For a list of the latest built images, take a look at downloads.openwisp.io/?prefix=openwisp-config/.

If you need to compile the package yourself, see Compiling openwisp-config and Compiling a custom OpenWRT image.

Once installed openwisp-config needs to be configured (see Configuration options) and then started with:

/etc/init.d/openwisp-config start

To ensure the agent is working correctly find out how to perform debugging in the Debugging section.

Configuration options

UCI configuration options must go in /etc/config/openwisp.

  • url: url of controller, eg: https://controller.openwisp.org
  • interval: time in seconds between checks for changes to the configuration, defaults to 120
  • management_interval: time in seconds between the management ip discovery attempts, defaults to $interval/12
  • registration_interval: time in seconds between the registration attempts, defaults to $interval/4
  • verify_ssl: whether SSL verification must be performed or not, defaults to 1
  • shared_secret: shared secret, needed for Automatic registration
  • consistent_key: whether Consistent key generation is enabled or not, defaults to 1
  • merge_config: whether Merge configuration is enabled or not, defaults to 1
  • tags: template tags to use during registration, multiple tags separated by space can be used, for more information see Template Tags
  • test_config: whether a new configuration must be tested before being considered applied, defaults to 1
  • test_retries: maximum number of retries when doing the default configuration test, defaults to 3
  • test_script: custom test script, read more about this feature in Configuration test
  • uuid: unique identifier of the router configuration in the controller application
  • key: key required to download the configuration
  • hardware_id_script: custom script to read out a hardware id (e.g. a serial number), read more about this feature in Hardware ID
  • hardware_id_key: whether to use the hardware id for key generation or not, defaults to 1
  • bootup_delay: maximum value in seconds of a random delay after bootup, defaults to 10, see Bootup Delay
  • unmanaged: list of config sections which won't be overwritten, see Unmanaged Configurations
  • capath: value passed to curl --capath argument, by default is empty; see also curl capath argument
  • cacert: value passed to curl --cacert argument, by default is empty; see also curl cacert argument
  • connect_timeout: value passed to curl --connect-timeout argument, defaults to 15; see curl connect-timeout argument
  • max_time: value passed to curl --max-time argument, defaults to 30; see curl max-time argument
  • mac_interface: the interface from which the MAC address is taken when performing automatic registration, defaults to eth0
  • management_interface: management interface name (both openwrt UCI names and linux interface names are supported), it's used to collect the management interface ip address and send this information to the OpenWISP server, for more information please read how to make sure OpenWISP can reach your devices
  • default_hostname: if your firmware has a custom default hostname, you can use this configuration option so the agent can recognize it during registration and replicate the standard behavior (new device will be named after its mac address, to avoid having many new devices with the same name), the possible options are to either set this to the value of the default hostname used by your firmware, or set it to * to always force to register new devices using their mac address as their name (this last option is useful if you have a firmware which can work on different hardware models and each model has a different default hostname)
  • pre_reload_hook: path to custom executable script, see pre-reload-hook
  • post_reload_hook: path to custom executable script, see post-reload-hook
  • post_reload_delay: delay in seconds to wait before the post-reload-hook and any configuration test, defaults to 5
  • post_registration_hook: path to custom executable script, see post-registration-hook
  • respawn_threshold: time in seconds used as procd respawn threshold, defaults to 3600
  • respawn_timeout: time in seconds used as procd respawn timeout, defaults to 5
  • respawn_retry: number of procd respawn retries (use 0 for infinity), defaults to 5
  • checksum_max_retries: maximum number of retries for checksum requests which fail with 404, defaults to 5, after these failures the agent will assume the device has been deleted from OpenWISP Controller and will exit; please keep in mind that due to respawn_retry, procd will try to respawn the agent after it exits, so the total number of attempts which will be tried has to be calculated as: checksum_max_retries * respawn_retry
  • checksum_retry_delay: time in seconds between retries, defaults to 6

Automatic registration

When the agent starts, if both uuid and key are not defined, it will consider the router to be unregistered and it will attempt to perform an automatic registration.

The automatic registration is performed only if shared_secret is correctly set.

The device will choose as name one of its mac addresses, unless its hostname is not OpenWrt, in the latter case it will simply register itself with the current hostname.

When the registration is completed, the agent will automatically set uuid and key in /etc/config/openwisp.

To enable this feature by default on your firmware images, follow the procedure described in Compiling a custom OpenWRT image.

Consistent key generation

When using Automatic registration, this feature allows devices to keep the same configuration even if reset or reflashed.

The key is generated consistently with an operation like md5sum(mac_address + shared_secret); this allows the controller application to recognize that an existing device is registering itself again.

The mac_interface configuration key specifies which interface is used to calculate the mac address, this setting defaults to eth0. If no eth0 interface exists, the first non-loopback, non-bridge and non-tap interface is used. You won't need to change this setting often, but if you do, ensure you choose a physical interface which has constant mac address.

The "Consistent key generation" feature is enabled by default, but must be enabled also in the controller application in order to work.

Merge configuration

By default the remote configuration is merged with the local one. This has several advantages:

  • less boilerplate configuration stored in the remote controller
  • local users can change local configurations without fear of losing their changes

It is possible to turn this feature off by setting merge_config to 0 in /etc/config/openwisp.

Details about the merging behavior:

  • if a configuration option or list is present both in the remote configuration and in the local configuration, the remote configurations will overwrite the local ones
  • configuration options that are present in the local configuration but are not present in the remote configuration will be retained
  • configuration files that were present in the local configuration and are replaced by the remote configuration are backed up and eventually restored if the modifications are removed from the controller

Configuration test

When a new configuration is downloaded, the agent will first backup the current running configuration, then it will try to apply the new one and perform a basic test, which consists in trying to contact the controller again;

If the test succeeds, the configuration is considered applied and the backup is deleted.

If the test fails, the backup is restored and the agent will log the failure via syslog (see Debugging for more information on auditing logs).

Disable testing

To disable this feature, set the test_config option to 0, then reload/restart openwisp-config.

Define custom tests

If the default test does not satisfy your needs, you can define your own tests in an executable script and indicate the path to this script in the test_script config option.

If the exit code of the executable script is higher than 0 the test will be considered failed.

Hardware ID

It is possible to use a unique hardware id for device identification, for example a serial number.

If hardware_id_script contains the path to an executable script, it will be used to read out the hardware id from the device. The hardware id will then be sent to the controller when the device is registered.

If the above configuration option is set then the hardware id will also be used for generating the device key, instead of the mac address. If you use a hardware id script but prefer to use the mac address for key generation then set hardware_id_key to 0.

See also the related hardware ID settings in OpenWISP Controller.

Bootup Delay

The option bootup_delay is used to delay the initialization of the agent for a random amount of seconds after the device boots.

The value specified in this option represents the maximum value of the range of possible random values, the minimum value being 0.

The default value of this option is 10, meaning that the initialization of the agent will be delayed for a random number of seconds, this random number being comprised between 0 and 10.

This feature is used to spread the load on the OpenWISP server when a large amount of devices boot up at the same time after a blackout.

Large OpenWISP installations may want to increase this value.

Unmanaged Configurations

In some cases it could be necessary to ensure that some configuration sections won't be overwritten by the controller.

These settings are called "unmanaged", in the sense that they are not managed remotely. In the default configuration of openwisp-config there are no unmanaged settings.

Example unmanaged settings:

config controller 'http'
        ...
        list unmanaged 'system.@led'
        list unmanaged 'network.loopback'
        list unmanaged 'network.@switch'
        list unmanaged 'network.@switch_vlan'
        ...

Note the lines with the @ sign; this syntax means any UCI section of the specified type will be unmanaged.

In the previous example, the loopback interface, all led settings, all switch and switch_vlan directives will never be overwritten by the remote configuration and will only be editable via SSH or via the web interface.

Hooks

Below are described the available hooks in openwisp-config.

pre-reload-hook

Defaults to /etc/openwisp/pre-reload-hook; the hook is not called if the path does not point to an executable script file.

This hook is called each time openwisp-config applies a configuration, but before services are reloaded, more precisely in these situations:

  • after a new remote configuration is downloaded and applied
  • after a configuration test failed (see Configuration test) and a previous backup is restored

You can use this hook to perform custom actions before services are reloaded, eg: to perform auto-configuration with LibreMesh.

Example configuration:

config controller 'http'
        ...
        option pre_reload_hook '/usr/sbin/my-pre-reload-hook'
        ...

Complete example:

# set hook in configuration
uci set openwisp.http.pre_reload_hook='/usr/sbin/my-pre-reload-hook'
uci commit openwisp
# create hook script
cat <<EOF > /usr/sbin/my-pre-reload-hook
#!/bin/sh
# put your custom operations here
EOF
# make script executable
chmod +x /usr/sbin/my-pre-reload-hook
# reload openwisp-config by using procd's convenient utility
reload_config

post-reload-hook

Defaults to /etc/openwisp/post-reload-hook; the hook is not called if the path does not point to an executable script file.

Same as pre_reload_hook but with the difference that this hook is called after the configuration services have been reloaded.

post-registration-hook

Defaults to /etc/openwisp/post-registration-hook;

Path to an executable script that will be called after the registration is completed.

Hotplug Events

The agent sends the following Hotplug events:

  • After the registration is successfully completed: post-registration
  • After the registration failed: registration-failed
  • When the agent first starts after the bootup of the device: bootup
  • After any subsequent restart: restart
  • After the configuration has been successfully applied: config-applied
  • After the previous configuration has been restored: config-restored
  • Before services are reloaded: pre-reload
  • After services have been reloaded: post-reload
  • After the agent has finished its check cycle, before going to sleep: end-of-cycle

If a hotplug event is sent by openwisp-config then all scripts existing in /etc/hotplug.d/openwisp/ will be executed. In scripts the type of event is visible in the variable $ACTION. For example, a script to log the hotplug events, /etc/hotplug.d/openwisp/01_log_events, could look like this:

#!/bin/sh

logger "openwisp-config sent a hotplug event. Action: $ACTION"

It will create log entries like this:

Wed Jun 22 06:15:17 2022 user.notice root: openwisp-config sent a hotplug event. Action: registration-failed

For more information on using these events refer to the Hotplug Events OpenWrt Documentation.

Compiling openwisp-config

The following procedure illustrates how to compile openwisp-config and its dependencies:

git clone https://github.com/openwrt/openwrt.git openwrt
cd openwrt
git checkout <openwrt-branch>

# configure feeds
echo "src-git openwisp https://github.com/openwisp/openwisp-config.git" > feeds.conf
cat feeds.conf.default >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
# any arch/target is fine because the package is architecture indipendent
arch="ar71xx"
echo "CONFIG_TARGET_$arch=y" > .config;
echo "CONFIG_PACKAGE_openwisp-config=y" >> .config
make defconfig
make tools/install
make toolchain/install
make package/openwisp-config/compile

Alternatively, you can configure your build interactively with make menuconfig, in this case you will need to select openwisp-config by going to Administration > openwisp:

git clone https://github.com/openwrt/openwrt.git openwrt
cd openwrt
git checkout <openwrt-branch>

# configure feeds
echo "src-git openwisp https://github.com/openwisp/openwisp-config.git" > feeds.conf
cat feeds.conf.default >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
# go to Administration > openwisp and select the variant you need interactively
make -j1 V=s

Compiling a custom OpenWRT image

If you are managing many devices and customizing your openwisp-config configuration by hand on each new device, you should switch to using a custom OpenWRT firmware image that includes openwisp-config and its precompiled configuration file, this strategy has a few important benefits:

  • you can save yourself the effort of installing and configuring openwisp-config on each device
  • you can enable Automatic registration by setting shared_secret, hence saving extra time and effort to register each device on the controller app
  • if you happen to reset the firmware to initial settings, these precompiled settings will be restored as well

The following procedure illustrates how to compile a custom OpenWRT image with a precompiled minimal /etc/config/openwisp configuration file:

git clone https://github.com/openwrt/openwrt.git openwrt
cd openwrt
git checkout <openwrt-branch>

# include precompiled file
mkdir -p files/etc/config
cat <<EOF > files/etc/config/openwisp
config controller 'http'
    # change the values of the following 2 options
    option url 'https://openwisp2.mydomain.com'
    option shared_secret 'mysharedsecret'
EOF

# configure feeds
echo "src-git openwisp https://github.com/openwisp/openwisp-config.git" > feeds.conf
cat feeds.conf.default >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
# replace with your desired arch target
arch="ar71xx"
echo "CONFIG_TARGET_$arch=y" > .config
echo "CONFIG_PACKAGE_openwisp-config=y" >> .config
make defconfig
# compile with verbose output
make -j1 V=s

Automate compilation for different organizations

If you are working with OpenWISP, there are chances you may be compiling several images for different organizations (clients or non-profit communities) and use cases (full featured, mesh, 4G, etc).

Doing this by hand without tracking your changes can lead you into a very disorganized and messy situation.

To alleviate this pain you can use ansible-openwisp2-imagegenerator.

Debugging

Debugging openwisp-config can be easily done by using the logread command:

logread

Use grep to filter out any other log message:

logread | grep openwisp

If you are in doubt openwisp-config is running at all, you can check with:

ps | grep openwisp

You should see something like:

3800 root      1200 S    {openwisp-config} /bin/sh /usr/sbin/openwisp-config --url https://openwisp2.mydomain.com --verify-ssl 1 --consistent-key 1 ...

You can inspect the version of openwisp-config currently installed with:

openwisp-config --version

Quality Assurance Checks

We use LuaFormatter and shfmt to format lua files and shell scripts respectively.

First of all, you will need install the lua packages mentioned above, then you can format all files with:

./qa-format

To run quality assurance checks you can use the run-qa-checks script:

# install openwisp-utils QA tools first
pip install openwisp-utils[qa]

# run QA checks before committing code
./run-qa-checks

Run tests

To run the unit tests, you must install the required dependencies first; to do this, you can take a look at the install-dev.sh script.

You can run all the unit tests by launching the dedicated script:

./runtests

Alternatively, you can run specifc tests, eg:

cd openwisp-config/tests/
lua test_utils.lua -v

Contributing

Please read the OpenWISP contributing guidelines.

Changelog

See CHANGELOG.

License

See LICENSE.

Support

See OpenWISP Support Channels.

openwisp-config's People

Contributors

agabellini avatar aryamanz29 avatar atb00ker avatar cappe87 avatar codesankalp avatar devkapilbansal avatar feckert avatar glassen avatar hargovindarora avatar keulu avatar klukonin avatar nemesifier avatar okraits avatar pandafy avatar pawelplsi avatar ppabcd avatar sch-m avatar tabakocl avatar talha-p avatar vishalx360 avatar waleko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openwisp-config's Issues

[BUG!] Invalid configuration is not spotted and openwisp-config can brick a device

In some (hopefully rare) cases, it is possible that a configuration which has invalid UCI syntax is downloaded and applied.

Because of the fact that the update process fails, the device remains in an inconsistent state, with part of the configuration in /etc/config/ deleted (actually it's stored in /etc/openwisp/remote/etc/config).

I think we need to add some logic which checks that the UCI files contained in the downloaded configuration are all valid and readable before attempting to apply it.

We should also ensure that if the process fails for some reason the backed up configuration is restored.

register might not succeed at first boot and procd will kill openwisp_config

register might not succeed at first boot because the network is not configured yet. In that case the agent will keep crashing and after 6 attempts procd will kill the agent.

It might be an acceptable solution to expect a possible failure, start a loop, check if the network is up: if it's up it will try to register, if not it will wait a bit before trying again.

Add smarter configuration merge mechanism

We need a smarter configuration merging mechanism that does the following:

  • does not cause issue #17
  • separates the remote configuration from the local one
  • merges the remote configuration on the local one by default (with the optional possibility to overwrite instead of merging)
  • removes configuration that were added but then later removed

Official lede package feeds unintentionally gets priority

See mailing list discussion:
https://groups.google.com/d/msg/openwisp/3mK05ARz5Lk/dBIpwDiwAQAJ

An older version of openwisp-config is installed on LEDE, even if users add this repo in their feeds.

This is happening because recently openwisp-config has been added to the official LEDE packages, so the lede packages feed has priority over the custom openwisp-config feed.

Updating the LEDE package is less easy than updating this repo, therefore we should find a solution to avoid slowing down development unnecessarily.

@riblo is helping out to find a solution.

Automatic renaming of anonymous sections

In order to increase compatibility with the incoming backward conversion feature that will be soon incldued in OpenWISP 2 (see openwisp/netjsonconfig#70), we need to improve the openwisp-uci-autoname script so that it can perform the following:

  • ensure system config types in /etc/config/system are always named system
  • ensure globals config types in /etc/config/network are always named globals
  • rename anonymous switches according to the netjsonconfig switch rendering output
  • ensure anonymous wifi interfaces are named wifi_<ifname>
  • ensure routes are named progressively, eg: route1, route2, route3
  • ensure rules are named progressively, eg: rule1, rule2, rule3
  • ensure leds are named as led_<lowercase_name>
  • any other configuration item should be named as <type><number>, for example in case of /etc/config/firewall, the first forwarding rule will be named: forwarding1

Custom reload_config command

We need a reload_config command that takes into account the fact that some init.d script do not use service_triggers.

[logging] Add possibility to log to file

Until now we have been using the logger function available in OpenWRT/LEDE, but we now face the need of logging also to a file.

We need to add a wrapper function which calls logger and also appends to a log file.

[idea] Update HW and firmware info in openwisp server

When upgrading the firmware of a device, the distribution/release info is not updated in OpenWISP.

When the daemon starts, it could compare the information the server has (but there's no API to do this yet, it will need to be added) with the location information, if they don't match it should update the information again (also this will need an API).

[update-config] order of sections is modified

This is an issue similar to #60 and #64. openwisp-update-config.lua modifies the order of sections in uci files. This can lead to unwanted behaviour especially in the firewall configuration where the order of the sections is critical.

I noticed it when I tried to modify a section which was not created by openwisp-config. After the first modification the order is still the same, but it changes with the second modification.

Preserve /etc/config/system and /etc/config/network

When setting up both the controller and a new device type for the first time, it is annoying that /etc/config/system and /etc/config/network are overwritten by the configuration downloaded from the controller, this requires unnecessary duplication in maintaining the ntp configuration, led settings, and the basic ethernet configuration both on the device and on the controller.

A possible solution would be to store the original system and network configurations and merge them with the configuration downloaded by the controller.

This feature could be enabled by default but it could be possible to disable it if needed (like #10).

Registration: wrong URL not detected

If a wrong URL is set in /etc/config/openwisp, the register() function does not abort and keeps going ahead.

It should instead abort and report the issue.

Verify SSL certificates

Ensure SSL certificates are verified. Probably needs the ca-certificates package or something similar.

Provide a way to disable verification.

manually push configs?

I was just wondering, is there a way someone could manually push configs
to a device with openwisp-config without having an openwisp-controller
instance? I'm thinking in terms of perhaps someone already has a sort of
controller software for other stuff and want to integrate openwisp support
into it.

Makefile

  • Ensure the packages compiles
  • Ensure it installs with opkg (after setting up a custom feed)

[auto-registration] Failed auto-registration but configuration is downloaded and applied anyway

This rare bug happened yesterday openwisp/django-netjsonconfig#64, in which an auto-registration failed but the device was created anyway.

And here something totally unexpected happened, openwisp-config downloaded and applied the configuration anyway, which should not happen.

It's a rare bug, but it's nevertheless worth taking note that it can be triggered and would be better to fix it in the near future.

Agent may be reloaded before performing "report_status"

If the configuration of the agent itself is provided via the controller, the agent will be reloaded by procd before it performs the report_status phase.

This bug has other possible negative consequences, for example it could prevent the restore of a backup in case of a bad configuration.

[docs] Document template tags

I just noticed the template tags featue (#34) is not mentioned in the README.

It would be appropiate to mention the config option in the beginning of the README as well as dedicate a brief section to explain how it works.

[registration] Extensible registration action

After registration we could have an option to configure a path to a script which could be called to send further information to new openwisp2 modules / third party openwisp2 extensions / openwisp2 forks / other network management systems.

This would allow to implement many features without the need of brutally forking the agent each time new information is requested for a new feature.

[feature] new Hook post-reload-hook.

hello guys

my problem is quite simle, i want to do some stuf when everything is ok and after a new configuration is applied and services reloaded.

Send message to slack, check openvpn, check coova (and/or restart if necessary, and maybe do other things)

i think with a post reload hook script, we can adjust what the agent can't do.

pre_reload_hook
/usr/sbin/openwisp-reload-config
**post_reload_hook**
sleep $sleep_time

i can send you a pull request if you think it is a good idea.

[update-config] Avoid removing all sections installed via openwisp before reapplying them

This proposal should help to fix #69 as well.

The current update configuration algorithm uses a (dangerous) shortcut - totally my fault.

In order to remove specific UCI configuration that may be removed from the OpenWISP web interface, it loops over a stored copy of the previous UCI configuration downloaded from openwisp and removes all those options from the current active configuration. This basically removes everything that was sent via OpenWISP.
Once that is done, it applies the new configuration, adding all the options present in the new downloaded conf to the active conf of the device.

This is causing #69 but can may also cause unexpected problems if the process halts for some reason, although this case is now be prevented by da41186, but still, there are very good reasons to make this algorithm smarter.

I think the following should work:

  • loop over the sections and options (for each section also loop over its options) of the previous ow2 configuration (in /etc/openwisp/stored)
  • look for each specific section and its options in the new configuration that has just been downloaded from OpenWISP and if one of these is not found it means that section/option has been removed from the OpenWISP web UI and it can be safely removed from the current active configuration

Unmanaged configurations

Remove merge_default in favour of unmanaged configurations which can accept named configs (specific config options that are not overwritten by the controller) or general types (config types that cannot be overwritten by the controller).

[feature] Hardware ID / serial number

We should add a new configuration option like "serial_number" or "serial_number_script", which is a path to a script which if exists will be used to retrieve the serial number, which will then be sent to ow2 during registration.

We could add another boolean config option like "serial_number_key" which if true uses the serial number to generate the device key.
The default value of this config option could be true if "serial_number_script" is defined and exists, false otherwise.
It would basically mean the key is generated from the serial number by default when this feature is used, but it can be turned off if needed.

The actual names of the config options may be different than those proposed here if we find better ones.

[auto-registration] Unable to show multi-line error message in logread

When rare auto-registration failure like the ones described in openwisp/django-netjsonconfig#64 happen, the output in logread shows something like:

[daemon.openwisp] Auto-registration failed! }

Note the } at the end. That is the last line of a json error message.
openwisp-config expects the error message to be only one line, but sometimes this is not the case.

I don't have a clear idea of how to solve this issue now, I'll leave this issue open to find a solution in the future.

Name anonymous sections

UCI anonymous sections are hard to handle because it is not possible to add data to them.

We need to add a procedure that will rename any anonymous section.

openwisp-uci-autoname.lua: preserve order of options in each section when deleting and re-creating sections

The script openwisp-uci-autoname.lua eliminates anonymous sections by deleting and replacing them with named sections. The order of options in each section is not preserved. Thus if you look at a config file before and after openwisp-uci-autoname.lua has run , all the options are jumbled up, which is not nice.

The problem in the code is: when iterating over the items in a table, the order is arbitrary:

https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/lib/openwisp/utils.lua#L78

Maybe there is a way to fix this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.