You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The agent is at first sight a bit confusing.
I found it difficult to read in there. How everything works.
So I would like to make some changes to improve the maintainability.
I have already staged a pullrequest for refactoring the init script. The refactoring of agent is a little more difficult. So I would like to share my plans first.
The agent is at first sight a bit confusing.
I found it difficult to read in there. How everything works.
So I would like to make some changes to improve the maintainability.
I have already staged a pullrequest for refactoring the init script. The refactoring of agent is a little more difficult. So I would like to share my plans first.
The following lines should go into a new function to parse the command line arguments https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/openwisp.agent#L4-L37
The following lines should go into a new function called main. This is the agent it self. This is more or less C style. https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/openwisp.agent#L608-L658 The new main function is called at the end of the script with
main "$@"
All log messages are encapsulated in a new function. This makes the code clearer.
If the functions have correct names (which is most the case) then unnecessary comments can be removed. This also makes the code clearer.
And I would like to check the code with the tool shellcheck and fix the warnings.
The ubus call returns json so we should use in the following lines the json wrapper from openwrt to parse the output.
https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/openwisp.agent#L115-L117
Those would be my first thoughts. I don't think that's the last.
I'm asking for feedback on what you guys think about that.
The text was updated successfully, but these errors were encountered: