This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
7 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
|
||
SUITE_INSTALL_DIR=/home/pi/hassbian-scripts | ||
|
||
function usage { | ||
echo $0: usage: | ||
echo | ||
echo $0 \<command\> \<suite\> | ||
echo where \<command\> is one of: | ||
echo install - installs a software suite | ||
echo show - shows software suites available | ||
echo and \<suite\> is the name of a software component to operate on. | ||
echo | ||
} | ||
|
||
function show-suite-info { | ||
source $SUITE_INSTALL_DIR/install_$1.sh | ||
$1-show-long-info | ||
} | ||
|
||
function show-suites { | ||
echo List of suites available for installation: | ||
# inhibit the homeassistant suite from being displayed, to discourage its (re-)installation. | ||
suites=$(ls $SUITE_INSTALL_DIR/install_*.sh | grep -Po "install_\K(.*)\.sh$" | awk -F. '!/homeassistant/ {print $1}') | ||
|
||
for i in $suites | ||
do | ||
echo $i: $(show-suite-info $i) | ||
done | ||
} | ||
|
||
function show-suite-long-info { | ||
# Shows long info for the suite. | ||
source $SUITE_INSTALL_DIR/install_$1.sh | ||
$1-show-short-info | ||
$1-show-long-info | ||
$1-show-copyright-info | ||
} | ||
|
||
function install-suite { | ||
# Having got here, the installer script exists; source it, then run the installer function. | ||
source $SUITE_INSTALL_DIR/install_$1.sh | ||
$1-install-package | ||
} | ||
|
||
function verify-suite { | ||
# Check that the suite specified actually exists | ||
if [ ! -f "$SUITE_INSTALL_DIR/install_$1.sh" ] | ||
then | ||
echo "Cannot find suite $1." | ||
echo "Try running the show command to see all available suites" | ||
exit | ||
fi | ||
} | ||
|
||
if [ $# -lt 1 ] | ||
then | ||
usage | ||
exit | ||
fi | ||
COMMAND=$1 | ||
SUITE=$2 | ||
|
||
|
||
case $COMMAND in | ||
"show") | ||
if [ "$SUITE" != "" ] | ||
then | ||
verify-suite $SUITE | ||
show-suite-long-info $SUITE | ||
else | ||
show-suites | ||
fi | ||
;; | ||
"install") | ||
verify-suite $SUITE | ||
install-suite $SUITE | ||
exit | ||
;; | ||
"info") | ||
verify-suite $SUITE | ||
info-suite $SUITE | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters