Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Implement unified interface to install scripts #11

Merged
merged 9 commits into from
Feb 8, 2017

Conversation

kxtcd950
Copy link
Contributor

@kxtcd950 kxtcd950 commented Feb 6, 2017

I've implemented a unified interface to the install scripts for the components - "hassbian-config"
This takes the form of a single script which uses the (slightly modified) install scripts previously used to be able to install and show information about the packages (suites, in new "hassbian-config" terms).
The script itself is nothing terribly special, it just uses the installers to be able to show which suites are available, information about those suites, and to install them (dynamically retrieved so that this script can remain unchanged despite packages being added).
Note that no attempt at an uninstall command for hassbian-config has been attempted due to there being no uninstallers present for the installers as historically presented.

It's very simplistic, and if accepted, will require a change in the install systemd unit file to reference the hassbian-config script rather than calling install_homeassistant.sh as the unit file does now.

The changes to the install_.sh files have been kept to a minimum, and no changes have been made in the code which actually performs the installs - only to wrap it with a bash function declaration which the hassbian-config script itself calls after sourcing the install_.sh file as required.

The requirements for install_*.sh scripts are that:

  • the filename is of a normalised pattern - install_*.sh - for discovery purposes.
  • four functions exist, named after what would be captured with the regexp install_(.*).sh when presented with the filename. This would yield a captured text of "homeassistant" for an suite file named install_homeassistant.sh.

The four functions are ($1 means the text as captured from the regexp against the filename):

$1-show-short-info (shown in the list of suites available with the "show" command)
$1-show-long-info (shown in the information about a single suite from the "info" command)
$1-show-copyright-info (shown in the info when a single suite is listed with the "show" command; also shown in the installation process)
$1-install-package (the function which installs the package, as the script used to when run standalone in response to the "install" command)

These are called as required by the "hassbian-config" script as indicated above.

Sorry also about the messed up commit history; I'm not really that familiar with git (but I'm learning fast!)

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.
@mention-bot
Copy link

@kxtcd950, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Landrash to be a potential reviewer.

@homeassistant
Copy link

Hi @kxtcd950,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@Landrash
Copy link
Collaborator

Landrash commented Feb 6, 2017

This is awesome! Going to do some testing and hopefully merge this is as soon as possible

@Landrash
Copy link
Collaborator

Landrash commented Feb 7, 2017

@kxtcd950 I love this and I'll merge it in this weekend. I'm going to make a dev branch and and try to follow the same plan as we do with the HA release. Every other week for larger changes such as this and patches in between.

Copy link
Collaborator

@Landrash Landrash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment.
More might come after I've tested it properly.

@@ -1,8 +1,19 @@
#!/bin/sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't need to be any change to this script since it's the one ran when we create the image. It's not run after the image is created so the tool shouldn't need to care about this script. Might move this script into the files folder but no change you need to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this too - it's a breaking change for first installation, which I'm not happy with. I'm sorta thinking that having it available isn't a bad idea, as it allows for reinstalls of homeassistant to happen from the hassbian-config script; otherwise users have to find out how to perform this one install themselves. I did inhibit it from being viewed as a "suite" though, because it shouldn't ordinarily be run...
With a little more effort, it may be possible to detect that install_homeassistant.sh is being run at first-run time, and make it work as it has previously. It's a case of changing the very last line of the script.
If you're interested, I could look into making this change; but I'm at work and so it won't be a speedily forthcoming one :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it's not as difficult as I first thought. I've just pushed a new change in so that the install_homeassistant.sh script when run standalone acts as if it were the old installer. Bonus: it still fits in the hassbian-config mechanism so it can be used from there too.
This also fixes the install_homeassistant.sh script's hashbang which somehow hadn't been edited to use bash, but /bin/sh - which precluded the whole lot working.

Correct /bin/sh stanza which precludes the "function" keyword
Restore old functionality if installer is run standalone.
Copy link
Collaborator

@Landrash Landrash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes are awesome!
Love this and hope to have the time to give it a proper run down as soon as possible. (This weekend)

}

function homeassistant-show-long-info {
echo "Installs the libcec package for controlling CEC devices from this Pi"
echo "Installs the libcec package for controlling CEC devices from this Pi"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the libcec package.

@Landrash Landrash self-assigned this Feb 7, 2017
@balloob
Copy link
Member

balloob commented Feb 7, 2017

W00t 🍻 love it

@balloob balloob mentioned this pull request Feb 8, 2017
@balloob
Copy link
Member

balloob commented Feb 8, 2017

This is some advanced shell scripting 👍 This PR fixes #9

I also created a follow up feature request from me: #12 . Would love some input to see if shell scripts will be flexible enough to implement such features in the future.

Radiodan's config tool has a folder per task, which is nice because that way if we depend on files, we can have it all nicely organized together.

@balloob
Copy link
Member

balloob commented Feb 8, 2017

@Landrash does the current hassbian image pull this repo? If so, would merging this to master break all new image installs ?

@Landrash
Copy link
Collaborator

Landrash commented Feb 8, 2017 via email

@Landrash Landrash changed the base branch from master to dev February 8, 2017 20:26
@Landrash Landrash merged commit 92ccdd0 into home-assistant:dev Feb 8, 2017
Landrash added a commit that referenced this pull request Oct 29, 2017
* 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
Landrash added a commit that referenced this pull request Feb 11, 2018
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants