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

Hassbian-config: Added remove function. #184

Merged
merged 1 commit into from
Sep 30, 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
5 changes: 5 additions & 0 deletions docs/cloud9.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ $ sudo hassbian-config install cloud9
$ sudo hassbian-config upgrade cloud9
```

## Remove
```bash
$ sudo hassbian-config remove cloud9
```

## Additional info
Description | Command/value
:--- | :---
Expand Down
2 changes: 1 addition & 1 deletion package/etc/bash_completion.d/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _hassbian-config()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="install upgrade show log share-log --version --help"
opts="install upgrade remove show log share-log --version --help"
altopts="--accept --force --debug --version --help --dev --beta"
inst=$(find /opt/hassbian/suites/ -maxdepth 1 -type f | awk -F'/|_' ' {print $NF}' | awk -F. '{print $1}')

Expand Down
4 changes: 2 additions & 2 deletions package/opt/hassbian/suites/cloud9.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
function cloud9-show-short-info {
printf "Cloud9 install script for Hassbian.\\n"
printf "Cloud9 script for Hassbian.\\n"
}

function cloud9-show-long-info {
printf "Installs Cloud9 SDK onto this system.\\n"
printf "Cloud9 script for Hassbian.\\n"
printf "Cloud9 SDK is an webservice IDE that makes it easy to manage your configuration files.\\n"
}

Expand Down
25 changes: 23 additions & 2 deletions package/usr/local/bin/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function help {
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" " upgrade" "Upgrades software [suite]."
printf "%-8s\\t%s\\n" " remove" "Remove 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."
Expand Down Expand Up @@ -184,7 +185,7 @@ function install-suite { #This function do checks if we can/want to install.
return 0
}

function upgrade-suite { #This function do checks if we can to upgrade.
function upgrade-suite { #This function do checks if we can upgrade.
check-permission
UPGRADE=$(grep "$1"-upgrade-package "$SUITE_INSTALL_DIR/$1".sh) #Checking if suite has upgrade function.
if [ "$UPGRADE" == "" ]; then
Expand All @@ -195,6 +196,17 @@ function upgrade-suite { #This function do checks if we can to upgrade.
return 0
}

function remove-suite { #This function do checks if we can remove.
check-permission
REMOVABLE=$(grep "$1"-remove-package "$SUITE_INSTALL_DIR/$1".sh) #Checking if suite has remove function.
if [ "$REMOVABLE" == "" ]; then
printf "Remove function not avaialable for this suite.\\n"
return 0
fi
run-suite remove "$1" | tee "$LOGFILE" #This is the default run.
return 0
}

function verify-suite {
if [ -f "$SUITE_INSTALL_DIR/$1.sh" ]; then
retval=0 # beware - 0 is true in bash.
Expand Down Expand Up @@ -287,6 +299,15 @@ case $COMMAND in
shift # past argument
shift # past value
;;
"remove")
if verify-suite "$SUITE"; then
RUN="remove-suite $SUITE"
else
RUN="echo suite $SUITE doesn't exist."
fi
shift # past argument
shift # past value
;;
"log")
RUN="more $LOGFILE"
shift # past argument
Expand Down