-
-
Notifications
You must be signed in to change notification settings - Fork 97
Add status of installed suites, plus interrogation of state with JSON results. #13
Conversation
The hassbian-config script is a framework for configuring the installed packages on the system. It utilises the install scripts with minor modifications for inclusion into the framework. hassbian-config defines three operations: install, show and info install will install the named software package (hassbian-config calls this a "suite") show will show all available installers. info will show information about the suite selected. As of this version, there is no kind of state kept by hassbian-config; this will likely need to be changed.
… available suites.
…sh to be "just" another suite.
Correct /bin/sh stanza which precludes the "function" keyword Restore old functionality if installer is run standalone.
IMPLEMENTATION DETAIL: Change individual installer scripts to return an error in the install functions rather than exit the script hassbian-config has new command "state" implemented. hassbian-config state returns JSON formatted data about the state of all suites for use by API clients. hassbian-config state <suite> returns JSON formatted data about the state of an individual suite. concurrent access to the database is locked using flock; running from frontend and shell at the same time shouldn't cause any issues with data integrity. Ideally, default format for returned data would be plain text; it may be possible (but messy) to implement this, and have a --format=json parameter. Maybe better served by adding suite state to info command?
As far as I understand it, the code looks good 👍 |
From what I can read, it looks like this, is this correct? {
"suites": [
{
"openzwave": [
{
"state": "installed"
},
{
"description": "This is the description"
}
]
}
]
} |
I would prefer a more compact version, ie: {
"suites": {
"openzwave": {
"state": "installed",
"description": "This is the description"
}
}
} |
THe JSON is actually returned as a one line string of text thus: It's the online parsers that "pretty-print" it into the expanded version. I can add newlines and other whitespace as needed, but my initial concern was making the JSON syntactically correct; it never occurred to me to make it human friendly ;) I've now got it returning something a lot more like what you wanted: {
"suites":{
"libcec":{
"state":"Uninstalled",
"description":"Installs the libcec package for controlling CEC devices from this Pi"
},
"mosquitto":{
"state":"failed",
"description":"Installs the Mosquitto package for setting up a local MQTT server"
},
"openzwave":{
"state":"Uninstalled",
"description":"Installs the Open Z-wave package for setting up your zwave network"
},
"samba":{
"state":"installing",
"description":"Installs the samba package for sharing the hassbian configuration files over the Pi's network."
}
}
} although I'm still returning it as one line of text - no embedded carriage returns; the above is the output of a pretty printer :) The basic problem - for which I apologise - is that I come from a C background (I write C for embedded systems professionally) and so JSON is completely alien to me - when I think of a load of objects in sequence, my brain is trained to think of an array. Hence all the arrays in the returned JSON. |
Newlines and spaces in JSON are optional so it's all good. The new format is a lot nicer 👍 thanks |
* Implement unified interface to install scripts (#11) * Initial commit for hassbian-config script. The hassbian-config script is a framework for configuring the installed packages on the system. It utilises the install scripts with minor modifications for inclusion into the framework. hassbian-config defines three operations: install, show and info install will install the named software package (hassbian-config calls this a "suite") show will show all available installers. info will show information about the suite selected. As of this version, there is no kind of state kept by hassbian-config; this will likely need to be changed. * Add documentation for hassbian-config. * Added comment as to why the homeassistant suite is not in the list of available suites. * Attempt to commit all local changes (I'm not familiar with git, sorry). * Added stanzas to all suite installers; updated install_homeassistant.sh to be "just" another suite. * Untab file - somehow tabs had crept in, not spaces. * Fixup tabs Correct /bin/sh stanza which precludes the "function" keyword Restore old functionality if installer is run standalone. * Change package long info text to reflect reality. * Remove local testing variable. * Typo in HASSbian scripts documentation (#16) * Add status of installed suites, plus interrogation of state with JSON results. (#13) * Initial commit for hassbian-config script. The hassbian-config script is a framework for configuring the installed packages on the system. It utilises the install scripts with minor modifications for inclusion into the framework. hassbian-config defines three operations: install, show and info install will install the named software package (hassbian-config calls this a "suite") show will show all available installers. info will show information about the suite selected. As of this version, there is no kind of state kept by hassbian-config; this will likely need to be changed. * Add documentation for hassbian-config. * Added comment as to why the homeassistant suite is not in the list of available suites. * Attempt to commit all local changes (I'm not familiar with git, sorry). * Added stanzas to all suite installers; updated install_homeassistant.sh to be "just" another suite. * Untab file - somehow tabs had crept in, not spaces. * Fixup tabs Correct /bin/sh stanza which precludes the "function" keyword Restore old functionality if installer is run standalone. * Change package long info text to reflect reality. * Remove local testing variable. * FEATURE: Add a persistent database of suite states. IMPLEMENTATION DETAIL: Change individual installer scripts to return an error in the install functions rather than exit the script hassbian-config has new command "state" implemented. hassbian-config state returns JSON formatted data about the state of all suites for use by API clients. hassbian-config state <suite> returns JSON formatted data about the state of an individual suite. concurrent access to the database is locked using flock; running from frontend and shell at the same time shouldn't cause any issues with data integrity. Ideally, default format for returned data would be plain text; it may be possible (but messy) to implement this, and have a --format=json parameter. Maybe better served by adding suite state to info command? * Correct quotes in JSON data which broke it. * Fix true/false bug in verify-suite * Added non-installed scripts to "all" status display. * remove debugging variables from the script. * Added non-array JSON to hassbian-config status command at @Baloob's request to simplify parsing * Remove debugging variables. * Remove orphaned function. * Rework for packaging * Our first .deb package * fix broken link * Add that missing / * FIxed funtion call so that it will work. (#21) * Update install_hue.sh Rename functions. * Add tellstick installer * Update install_homeassistant.sh No longer removes the script. Only disables the script in question. * Update home-assistant@homeassistant.service Fix spelling and remove whitespace. * Tellstick install * Update install_libcec.sh (#26) Looks like CEC is installed in dist-packages now instead of site-packages. Updated documentation here -> https://home-assistant.io/components/hdmi_cec/ * OpenZwave config directory location (#30) * OpenZwave config directory location I'm not sure if I was having a moment or if OpenZWave 0.40 caused this, but after using `hassbian-config install openzwave` tonight, Zwave did not run with HA. After checking things out, it looks like the `/srv/homeassistant/lib/python3.*/site-packages/libopenzwave-0.*-linux*.egg/config` folder does not exist. I did find the openzwave config information in ` /srv/homeassistant/lib/python3.*/site-packages/python_openzwave/ozw_config`. When I changed the links to that folder and used the config path `/srv/homeassistant/src/python-openzwave/openzwave/config` in my HA configuration file everything is working great. Might be worth double checking before merging this, but just wanted to point it out. Cheers! * Update install_openzwave.sh * Add tradfri, openzwave-pip and minor fixes * Update version of package and add dependencies * Update README.md * Fix sorting of package files * Add gitignore for built packages * Update README.md * Update install_tradfri.sh Fix heritage from copied file * Fix OZWCP link * Add simple script to make builing easier * Correct creation of OZWCP link * Update README.md Fix spelling and clarify use of Open Z-Wave scripts. * Update README (#34) Fixes a few typos * Updates for Stretch * Adding support for Python 3.5 in install_hue.sh (#40) * Adding support for Python 3.5 Adding support for Python 3.5 and keeping 3.4 for compability. * Update install_hue.sh * Fixed error in getting IP-Address (#41) Not sure if this is related to strech or not, but the old one give me: "Configuration is now available as a Samba share at \\\homeassistant" This will correct that. * Added support for upgrade scripts (#42) * Added upgrade to MD * Initial upgrade script for homeassistant * Update and rename upgrade_homeassistant.sh to upgrade_home-assistant.sh * Update upgrade_home-assistant.sh * Initial support for upgrade * Update hassbian-config * Create upgrade_hassbian-script.sh * Fix minor spelling misstake * Spelling and cleanup of sentence * Check for permissions on where needed * Check for permissions on where needed (#43) * Update to use Discord and various updates * hassbian-config: new upgrade script hassbian (#44) * Add base OS upgrade script * Add base OS upgrade script * Added sorting in the show command (#45) * Remove extra ~~ * Update README.md Removed - OpenZwave - Tellstick Marked as not working - Mosquitto * Added installation script for an web terminal. (#46) * Added install script for an web terminal * Added instructions to webterminal script * Fixed problem when running on stretch (#47) * Fixed problem when running on stretch These addistions will do this: - Try running it normally (so if this is fixed upstream, we don't need the rest of the additions in the future) - If first tryf fails, missing dependencies are downloaded, and tre installer runs 1 more time. Testet with the current version on Hassbian 1.3 * Added mention that this is an workaround * Changed function of show commad (#49) This will use the short desctription, and will look better on a smaller terminal window * Update scripts from dev branch (#50) * Update scripts from dev branch For the users living on the "bleeding edge" * Update upgrade_hassbian-script-dev.sh * Support for duckdns (#48) * Initial creation of this script * Update install_duckdns.sh * Update install_duckdns.sh * Update version of packge to .6 * Preperation for 0.6 (#51) * Added new scripts, and uppdated mosquitto * Corrected typo * Corrected typo * Corrected typo in URL * Changed out gitter for github * Corrected typo in URL * Corrected typo in URL * [WIP]Appdeamon install script (#52) * Install script for Appdaemon * Install script for Appdaemon * Fixes for Appdaemon scripts * Fix start of appdaemon * Install script for MariaDB (#53) * Add install script for MariaDB * Add missing dependency for MariaDB * Add docs for MariaDB script + spell fixes * Rephrasing * Add example for creating DB * Add sudo where needed * Correct name to MariaDB * Additional database install scripts (#56) * Add additional db install scripts * Add documentation for db install scripts * Razberry install script. (#57) * Add additional db install scripts * Add documentation for db install scripts * Add install script for Razberry * Add docs for install script for Razberry * Update README.md * Add cython3 to fix tradfri * Attempt to fix Tradfri * Attempt to fix Tradfri (#58) * Attempt to fix Tradfri again * Fiexes Trådfri (#59) * Making sure wheel and setuptools are up to date (#62) * Remove cython from base package since it's installed as a pip package (#64) * Update upgrade_hassbian.sh (#67) As of now, sudo hassbian-config show gives same description for hassbian and home-assistant upgrade script. Perhaps this is confusing that the short description is the same for both scripts? * Simplify Tradfri install script Simplify script for 0.56 according to home-assistant/home-assistant.io#3672 * Add sudo exception for hassbian-config upgrade * Initial tab autocomplete (#60) * Fixes problem with deps during install (#61) * Fixes problem with deps during install * Changed instal methode
* Typo in HASSbian scripts documentation * Update master from dev (#65) * Implement unified interface to install scripts (#11) * Initial commit for hassbian-config script. The hassbian-config script is a framework for configuring the installed packages on the system. It utilises the install scripts with minor modifications for inclusion into the framework. hassbian-config defines three operations: install, show and info install will install the named software package (hassbian-config calls this a "suite") show will show all available installers. info will show information about the suite selected. As of this version, there is no kind of state kept by hassbian-config; this will likely need to be changed. * Add documentation for hassbian-config. * Added comment as to why the homeassistant suite is not in the list of available suites. * Attempt to commit all local changes (I'm not familiar with git, sorry). * Added stanzas to all suite installers; updated install_homeassistant.sh to be "just" another suite. * Untab file - somehow tabs had crept in, not spaces. * Fixup tabs Correct /bin/sh stanza which precludes the "function" keyword Restore old functionality if installer is run standalone. * Change package long info text to reflect reality. * Remove local testing variable. * Typo in HASSbian scripts documentation (#16) * Add status of installed suites, plus interrogation of state with JSON results. (#13) * Initial commit for hassbian-config script. The hassbian-config script is a framework for configuring the installed packages on the system. It utilises the install scripts with minor modifications for inclusion into the framework. hassbian-config defines three operations: install, show and info install will install the named software package (hassbian-config calls this a "suite") show will show all available installers. info will show information about the suite selected. As of this version, there is no kind of state kept by hassbian-config; this will likely need to be changed. * Add documentation for hassbian-config. * Added comment as to why the homeassistant suite is not in the list of available suites. * Attempt to commit all local changes (I'm not familiar with git, sorry). * Added stanzas to all suite installers; updated install_homeassistant.sh to be "just" another suite. * Untab file - somehow tabs had crept in, not spaces. * Fixup tabs Correct /bin/sh stanza which precludes the "function" keyword Restore old functionality if installer is run standalone. * Change package long info text to reflect reality. * Remove local testing variable. * FEATURE: Add a persistent database of suite states. IMPLEMENTATION DETAIL: Change individual installer scripts to return an error in the install functions rather than exit the script hassbian-config has new command "state" implemented. hassbian-config state returns JSON formatted data about the state of all suites for use by API clients. hassbian-config state <suite> returns JSON formatted data about the state of an individual suite. concurrent access to the database is locked using flock; running from frontend and shell at the same time shouldn't cause any issues with data integrity. Ideally, default format for returned data would be plain text; it may be possible (but messy) to implement this, and have a --format=json parameter. Maybe better served by adding suite state to info command? * Correct quotes in JSON data which broke it. * Fix true/false bug in verify-suite * Added non-installed scripts to "all" status display. * remove debugging variables from the script. * Added non-array JSON to hassbian-config status command at @Baloob's request to simplify parsing * Remove debugging variables. * Remove orphaned function. * Rework for packaging * Our first .deb package * fix broken link * Add that missing / * FIxed funtion call so that it will work. (#21) * Update install_hue.sh Rename functions. * Add tellstick installer * Update install_homeassistant.sh No longer removes the script. Only disables the script in question. * Update home-assistant@homeassistant.service Fix spelling and remove whitespace. * Tellstick install * Update install_libcec.sh (#26) Looks like CEC is installed in dist-packages now instead of site-packages. Updated documentation here -> https://home-assistant.io/components/hdmi_cec/ * OpenZwave config directory location (#30) * OpenZwave config directory location I'm not sure if I was having a moment or if OpenZWave 0.40 caused this, but after using `hassbian-config install openzwave` tonight, Zwave did not run with HA. After checking things out, it looks like the `/srv/homeassistant/lib/python3.*/site-packages/libopenzwave-0.*-linux*.egg/config` folder does not exist. I did find the openzwave config information in ` /srv/homeassistant/lib/python3.*/site-packages/python_openzwave/ozw_config`. When I changed the links to that folder and used the config path `/srv/homeassistant/src/python-openzwave/openzwave/config` in my HA configuration file everything is working great. Might be worth double checking before merging this, but just wanted to point it out. Cheers! * Update install_openzwave.sh * Add tradfri, openzwave-pip and minor fixes * Update version of package and add dependencies * Update README.md * Fix sorting of package files * Add gitignore for built packages * Update README.md * Update install_tradfri.sh Fix heritage from copied file * Fix OZWCP link * Add simple script to make builing easier * Correct creation of OZWCP link * Update README.md Fix spelling and clarify use of Open Z-Wave scripts. * Update README (#34) Fixes a few typos * Updates for Stretch * Adding support for Python 3.5 in install_hue.sh (#40) * Adding support for Python 3.5 Adding support for Python 3.5 and keeping 3.4 for compability. * Update install_hue.sh * Fixed error in getting IP-Address (#41) Not sure if this is related to strech or not, but the old one give me: "Configuration is now available as a Samba share at \\\homeassistant" This will correct that. * Added support for upgrade scripts (#42) * Added upgrade to MD * Initial upgrade script for homeassistant * Update and rename upgrade_homeassistant.sh to upgrade_home-assistant.sh * Update upgrade_home-assistant.sh * Initial support for upgrade * Update hassbian-config * Create upgrade_hassbian-script.sh * Fix minor spelling misstake * Spelling and cleanup of sentence * Check for permissions on where needed * Check for permissions on where needed (#43) * Update to use Discord and various updates * hassbian-config: new upgrade script hassbian (#44) * Add base OS upgrade script * Add base OS upgrade script * Added sorting in the show command (#45) * Remove extra ~~ * Update README.md Removed - OpenZwave - Tellstick Marked as not working - Mosquitto * Added installation script for an web terminal. (#46) * Added install script for an web terminal * Added instructions to webterminal script * Fixed problem when running on stretch (#47) * Fixed problem when running on stretch These addistions will do this: - Try running it normally (so if this is fixed upstream, we don't need the rest of the additions in the future) - If first tryf fails, missing dependencies are downloaded, and tre installer runs 1 more time. Testet with the current version on Hassbian 1.3 * Added mention that this is an workaround * Changed function of show commad (#49) This will use the short desctription, and will look better on a smaller terminal window * Update scripts from dev branch (#50) * Update scripts from dev branch For the users living on the "bleeding edge" * Update upgrade_hassbian-script-dev.sh * Support for duckdns (#48) * Initial creation of this script * Update install_duckdns.sh * Update install_duckdns.sh * Update version of packge to .6 * Preperation for 0.6 (#51) * Added new scripts, and uppdated mosquitto * Corrected typo * Corrected typo * Corrected typo in URL * Changed out gitter for github * Corrected typo in URL * Corrected typo in URL * [WIP]Appdeamon install script (#52) * Install script for Appdaemon * Install script for Appdaemon * Fixes for Appdaemon scripts * Fix start of appdaemon * Install script for MariaDB (#53) * Add install script for MariaDB * Add missing dependency for MariaDB * Add docs for MariaDB script + spell fixes * Rephrasing * Add example for creating DB * Add sudo where needed * Correct name to MariaDB * Additional database install scripts (#56) * Add additional db install scripts * Add documentation for db install scripts * Razberry install script. (#57) * Add additional db install scripts * Add documentation for db install scripts * Add install script for Razberry * Add docs for install script for Razberry * Update README.md * Add cython3 to fix tradfri * Attempt to fix Tradfri * Attempt to fix Tradfri (#58) * Attempt to fix Tradfri again * Fiexes Trådfri (#59) * Making sure wheel and setuptools are up to date (#62) * Remove cython from base package since it's installed as a pip package (#64) * Update upgrade_hassbian.sh (#67) As of now, sudo hassbian-config show gives same description for hassbian and home-assistant upgrade script. Perhaps this is confusing that the short description is the same for both scripts? * Simplify Tradfri install script Simplify script for 0.56 according to home-assistant/home-assistant.io#3672 * Add sudo exception for hassbian-config upgrade * Initial tab autocomplete (#60) * Fixes problem with deps during install (#61) * Fixes problem with deps during install * Changed instal methode
Partially complete code: I've tested most of the code, but would appreciate feedback and additional testing based on unexpected (to me) usage of the script. My apologies in advance if it's incomplete.
Adds a persistent state for each suite installed. This state can be fetched by using the new
hassbian-config
state
command. This new command will return the states of all installed and available suites in JSON format.The states of the suites are:
The JSON returned is built in parts through text concatenation (no native JSON libraries in bash scripting), all emitted JSON to date has passed the syntactic parsing done by http://json.parser.online.fr/ which I found using a google search. The JSON is therefore assumed to be correctly formed.
installer_*.sh scripts have changed so that instead of calling exit, the installer function returns error/success and hassbian-config checks that returned value and adjusts the packages state as appropriate.