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

Hassbian-config: Added debug option. #132

Merged
merged 2 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/hassbian_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ where command is one of:
Optional flags:
- `-y | --accept` This will accept defaults on scripts that allow this.
- `-f | --force` This will force run an script. This is useful if you need to reinstall a package.
- `-D | --debug` This will output every comand to the console.

Other available comands:
- `-V | --version` This will show you the installed version of `hassbian-config`.
Expand Down
19 changes: 18 additions & 1 deletion package/usr/local/bin/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function help {
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 "%-10s\\t%s\\n" " -D | --debug" "This will output every comand to the console."
printf "\\n"
printf "other [command] available:\\n"
printf "%-10s\\t%s\\n" " -V | --version" "Prints the version of hassbian-config"
Expand Down Expand Up @@ -101,6 +102,9 @@ function install-suite {
echo "This script must be run with sudo. Use 'sudo hassbian-config install $1'" 1>&2
return 1
fi
if [ "$DEBUG" == "true" ]; then
set -x
fi
if [ ! -f $SUITE_CONTROL_DIR/"$1" ]; then
touch $SUITE_CONTROL_DIR/"$1"
echo "SCRIPTSTATE=uninstalled" > $SUITE_CONTROL_DIR/"$1"
Expand All @@ -117,7 +121,7 @@ function install-suite {
echo "Upgrade script is not available..."
echo "You can force run the install script like this:"
echo "sudo hassbian-config -f install $1"
exit
return 0
fi
"$1"-upgrade-package | tee $LOGFILE
sed -i -- 's/SCRIPTSTATE='"$SUITESTATE"'/SCRIPTSTATE=installed/g' $SUITE_CONTROL_DIR/"$1"
Expand All @@ -126,6 +130,9 @@ function install-suite {
"$1"-install-package | tee $LOGFILE
sed -i -- 's/SCRIPTSTATE='"$SUITESTATE"'/SCRIPTSTATE=installed/g' $SUITE_CONTROL_DIR/"$1"
fi
if [ "$DEBUG" == "true" ]; then
set +x
fi
return 0
}

Expand All @@ -134,6 +141,9 @@ function upgrade-suite {
echo "This script must be run with sudo. Use 'sudo hassbian-config upgrade $1'" 1>&2
return 1
fi
if [ "$DEBUG" == "true" ]; then
set -x
fi
UPGRADE=$(grep "$1"-upgrade-package $SUITE_INSTALL_DIR/"$1".sh)
if [ "$UPGRADE" == "" ]; then
echo "Upgrade script is not available..."
Expand All @@ -143,6 +153,9 @@ function upgrade-suite {
check-permission
source $SUITE_INSTALL_DIR/"$1".sh
"$1"-upgrade-package | tee $LOGFILE
if [ "$DEBUG" == "true" ]; then
set +x
fi
return 0
}

Expand Down Expand Up @@ -189,6 +202,10 @@ case $COMMAND in
ACCEPT="true"
shift # past argument
;;
"-D"|"--debug")
DEBUG="true"
shift # past argument
;;
"show")
if [ "$SUITE" != "" ]; then
if verify-suite "$SUITE"; then
Expand Down