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 97
hassbian-config: Usage cleanup, added new help and command options. #125
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fafb47f
rewrite usage function
ludeeus 06c3386
Stickler fix
ludeeus 6b66f11
added stuff
ludeeus af1e7b6
added --help to usage
ludeeus 730f1a7
added documentation
ludeeus c65e443
Stickler fix, and removed sudo check in scripts
ludeeus fdab307
stickler fix
ludeeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -4,17 +4,31 @@ SUITE_INSTALL_DIR=/opt/hassbian/suites | |
SUITE_CONTROL_DIR=/srv/homeassistant/hassbian/control | ||
|
||
function usage { | ||
echo hassbian-config usage: | ||
echo | ||
echo hassbian-config \<command\> \<suite\> | ||
echo where \<command\> is one of: | ||
echo install - installs a software suite | ||
echo upgrade - upgrades a software suite | ||
echo show - shows software suites available | ||
echo log - displays an log of the last operation | ||
echo share-log - generates an hastebin link of the last operation | ||
echo and \<suite\> is the name of a software component to operate on. | ||
echo | ||
printf "usage: hassbian-config [command] [suite] [options]\\n" | ||
printf "run 'hassbian-config --help' to see all options\\n" | ||
return 0 | ||
} | ||
|
||
function help { | ||
printf "hassbian-config\\n" | ||
printf "%s\\n" "version: $(hassbian-config -V)" | ||
printf "\\n" | ||
printf "usage: hassbian-config [command] [suite] [options]\\n" | ||
printf "where [command] is one of:\\n" | ||
printf "%-8s\\t%s\\n" " install" "Installs a software [suite]" | ||
printf "%-8s\\t%s\\n" " upgrade" "Upgrades a software [suite]" | ||
printf "%-8s\\t%s\\n" " show" "To see available [suite] for install/upgrade" | ||
printf "%-8s\\t%s\\n" " log" "Displays an log of the last operation" | ||
printf "%-8s\\t%s\\n" " share-log" "Generates an hastebin link of the last operation" | ||
printf "\\n" | ||
printf "available optional [options]:\\n" | ||
printf "%-10s\\t%s\\n" " -y | --accept" "Accept defaults on scripts that allow this" | ||
printf "%-10s\\t%s\\n" " -f | --force" "Force run an script, this is useful if you need to reinstall a package" | ||
printf "\\n" | ||
printf "other [command] available:\\n" | ||
printf "%-10s\\t%s\\n" " -V | --version" "Prints the version of hassbian-config" | ||
printf "%-10s\\t%s\\n" " -H | --help" "Shows this help" | ||
printf "\\n" | ||
return 0 | ||
} | ||
|
||
|
@@ -83,6 +97,10 @@ function share-log { | |
} | ||
|
||
function install-suite { | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script must be run with sudo. Use \"sudo hassbian-config install "$1"\"" 1>&2 | ||
return 1 | ||
fi | ||
if [ ! -f $SUITE_CONTROL_DIR/"$1" ]; then | ||
touch $SUITE_CONTROL_DIR/"$1" | ||
echo "SCRIPTSTATE=uninstalled" > $SUITE_CONTROL_DIR/"$1" | ||
|
@@ -112,6 +130,10 @@ function install-suite { | |
} | ||
|
||
function upgrade-suite { | ||
if [ "$(id -u)" != "0" ]; then | ||
echo "This script must be run with sudo. Use \"sudo hassbian-config upgrade "$1"\"" 1>&2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The surrounding quotes actually unquote this. Remove or escape them. |
||
return 1 | ||
fi | ||
UPGRADE=$(grep "$1"-upgrade-package $SUITE_INSTALL_DIR/"$1".sh) | ||
if [ "$UPGRADE" == "" ]; then | ||
echo "Upgrade script is not available..." | ||
|
@@ -159,11 +181,11 @@ SUITE=$2 | |
|
||
|
||
case $COMMAND in | ||
"-f") | ||
"-f"|"--force") | ||
FORCE="true" | ||
shift # past argument | ||
;; | ||
"-y") | ||
"-y"|"--accept") | ||
ACCEPT="true" | ||
shift # past argument | ||
;; | ||
|
@@ -206,7 +228,7 @@ case $COMMAND in | |
RUN="share-log" | ||
shift # past argument | ||
;; | ||
"-V") | ||
"-V"|"--version") | ||
VERSION=$(dpkg -s hassbian-scripts | grep 'Version:' | awk '{print $2}') | ||
RUN="echo $VERSION" | ||
shift # past argument | ||
|
@@ -215,6 +237,10 @@ case $COMMAND in | |
RUN="show-installed-suites" | ||
shift # past argument | ||
;; | ||
"-H"|"--help") | ||
RUN="help" | ||
shift # past argument | ||
;; | ||
*) | ||
RUN="usage" | ||
shift # past argument | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The surrounding quotes actually unquote this. Remove or escape them.
Double quote to prevent globbing and word splitting.