diff --git a/README.md b/README.md index a211ca13..71546b34 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ below for usage and instructions. - [hassbian-config](/docs/hassbian_config.md) - [AppDaemon](/docs/appdaemon.md) - [Cloud9](/docs/cloud9.md) + - [custom-component-store](/docs/custom-component-store.md) - [Duck DNS](/docs/duckdns.md) - [Fail2ban](/docs/fail2ban.md) - [Hassbian](/docs/hassbian.md) @@ -21,6 +22,7 @@ below for usage and instructions. - [Homebridge](/docs/homebridge.md) - [HUE](/docs/hue.md) - [LibCEC](/docs/libcec.md) + - [Manager](/docs/manager.md) - [MariaDB](/docs/mariadb.md) - [Monitor](/docs/monitor.md) - [Mosquitto](/docs/mosquitto.md) diff --git a/docs/custom-component-store.md b/docs/custom-component-store.md new file mode 100644 index 00000000..e4502488 --- /dev/null +++ b/docs/custom-component-store.md @@ -0,0 +1,45 @@ +# Custom component store + +Custom component store is a web UI tool that can help you manage your custom components. + +![overview](https://camo.githubusercontent.com/b01a7e30e5c8d5938eed8091ec23ad9b4dc84cfe/68747470733a2f2f692e6962622e636f2f42737a714c58722f64656d6f2e676966) + +When installed the WEB UI are running on port `8120` + +## Installation + +```bash +sudo hassbian-config install custom-component-store +``` + +## Upgrade + +```bash +sudo hassbian-config upgrade custom-component-store +``` + +## Remove to beta channel + +```bash +sudo hassbian-config remoev custom-component-store +``` + +## Additional info + +Description | Command/value +:--- | :--- +Running as: | homeassistant +Default user: | `pi` +Default password: | `raspberry` +Port: | `8120` +Start service: | `sudo systemctl start custom-component-store@homeassistant.service` +Stop service: | `sudo systemctl stop custom-component-store@homeassistant.service` +Restart service: | `sudo systemctl restart custom-component-store@homeassistant.service` +Service status: | `sudo systemctl status custom-component-store@homeassistant.service` + +*** + +The script was originally contributed by [@Ludeeus][ludeeus]. + + +[ludeeus]: https://github.com/ludeeus \ No newline at end of file diff --git a/docs/manager.md b/docs/manager.md new file mode 100644 index 00000000..288a19b8 --- /dev/null +++ b/docs/manager.md @@ -0,0 +1,43 @@ +# Hassbian manager + +Hassbian manager is a web UI tool that can help you manage your suites. + +When installed the WEB UI are running on port `9999` + +## Installation + +```bash +sudo hassbian-config install manager +``` + +## Upgrade + +```bash +sudo hassbian-config upgrade manager +``` + +## Remove to beta channel + +```bash +sudo hassbian-config remoev manager +``` + +## Additional info + +Description | Command/value +:--- | :--- +Running as: | homeassistant +Default user: | `pi` +Default password: | `raspberry` +Port: | `9999` +Start service: | `sudo systemctl start hassbian-manager@homeassistant.service` +Stop service: | `sudo systemctl stop hassbian-manager@homeassistant.service` +Restart service: | `sudo systemctl restart hassbian-manager@homeassistant.service` +Service status: | `sudo systemctl status hassbian-manager@homeassistant.service` + +*** + +The script was originally contributed by [@Ludeeus][ludeeus]. + + +[ludeeus]: https://github.com/ludeeus diff --git a/docs/postgresql.md b/docs/postgresql.md index 505a1780..315125ba 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -20,13 +20,16 @@ If so, add a PR here when you are done: Example of how to create the database: -```sql -sudo mysql -u root -p -CREATE DATABASE homeassistant; -CREATE USER 'homeassistantuser' IDENTIFIED BY 'password'; -GRANT ALL PRIVILEGES ON homeassistant.* TO 'homeassistantuser'; -FLUSH PRIVILEGES; -exit +```bash +sudo -s -u postgres +createuser homeassistant +createdb -O homeassistant homeassistant +``` + +Example configuration +```yaml +recorder: + db_url: postgresql://@/homeassistant #Connects to Postgresql via Unix socket, allowed by default ``` *** diff --git a/package/DEBIAN/control b/package/DEBIAN/control index 5d75ed11..efcfc116 100644 --- a/package/DEBIAN/control +++ b/package/DEBIAN/control @@ -1,8 +1,8 @@ Package: hassbian-scripts -Version: 0.11.1 +Version: 0.12.0 Priority: optional Architecture: all -Depends: bash, wget, git, python3, python3-venv, python3-pip, python3-dev, bluetooth, libbluetooth-dev, avahi-daemon, build-essential, libssl-dev, libffi-dev, python-dev,libudev-dev, zip, nodejs, apt-transport-https, bluez-hcidump, bc, figlet +Depends: bash, wget, git, python3, python3-venv, python3-pip, python3-dev, bluetooth, libbluetooth-dev, avahi-daemon, build-essential, libssl-dev, libffi-dev, python-dev,libudev-dev, zip, apt-transport-https, bluez-hcidump, bc, figlet Maintainer: Fredrik Lindqvist Homepage: www.home-assistant.io Description: Hassbian scripts diff --git a/package/etc/bash_completion.d/hassbian-config b/package/etc/bash_completion.d/hassbian-config index 3c7dcbcd..656cf324 100644 --- a/package/etc/bash_completion.d/hassbian-config +++ b/package/etc/bash_completion.d/hassbian-config @@ -14,7 +14,7 @@ _hassbian-config() fi case "${prev}" in - install|upgrade|show) + install|upgrade|show|remove) COMPREPLY=( $(compgen -W "${inst}" -- ${cur}) ) return 0 ;; diff --git a/package/etc/sudoers.d/020_homeassistant_hassbian-scripts b/package/etc/sudoers.d/020_homeassistant_hassbian-scripts index 17e64244..0bfba8fd 100644 --- a/package/etc/sudoers.d/020_homeassistant_hassbian-scripts +++ b/package/etc/sudoers.d/020_homeassistant_hassbian-scripts @@ -1,4 +1,4 @@ %homeassistant ALL= NOPASSWD: /usr/local/bin/hassbian-config show * %homeassistant ALL= NOPASSWD: /usr/local/bin/hassbian-config install * %homeassistant ALL= NOPASSWD: /usr/local/bin/hassbian-config upgrade * - +%homeassistant ALL= NOPASSWD: /usr/local/bin/hassbian-config remove * diff --git a/package/etc/systemd/system/install_homeassistant.service b/package/etc/systemd/system/install_homeassistant.service index e722e8df..88d635fd 100644 --- a/package/etc/systemd/system/install_homeassistant.service +++ b/package/etc/systemd/system/install_homeassistant.service @@ -9,6 +9,7 @@ After=network.target [Service] ExecStartPre=/usr/local/bin/hassbian-config upgrade hassbian-script ExecStart=/usr/local/bin/hassbian-config install homeassistant --force +TimeOutSec=1800 [Install] WantedBy=multi-user.target diff --git a/package/opt/hassbian/suites/cloud9.sh b/package/opt/hassbian/suites/cloud9.sh index 8724d509..439cd7b0 100644 --- a/package/opt/hassbian/suites/cloud9.sh +++ b/package/opt/hassbian/suites/cloud9.sh @@ -16,7 +16,7 @@ function cloud9-install-package { node=$(which node) if [ -z "${node}" ]; then #Installing NodeJS if not already installed. printf "Downloading and installing NodeJS...\\n" - curl -sL https://deb.nodesource.com/setup_9.x | bash - + curl -sL https://deb.nodesource.com/setup_10.x | bash - apt install -y nodejs fi @@ -48,9 +48,23 @@ echo "Starting Cloud9 service..." systemctl start cloud9@homeassistant.service echo "Checking the installation..." -ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') +sleep 15 validation=$(pgrep -f cloud9) if [ ! -z "${validation}" ]; then + echo "Using fallback installation." + echo "Installing npm" + apt install -y npm + + cd /opt/c9sdk || exit 1 + npm install + + echo "Checking the installation..." + sleep 15 +fi + +validation=$(pgrep -f cloud9) +if [ -z "${validation}" ]; then + ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') echo echo -e "\\e[32mInstallation done.\\e[0m" echo "Your Cloud9 IDE is now avaiable at http://$ip_address:8181" @@ -77,6 +91,7 @@ printf "Starting Cloud9 service...\\n" systemctl start cloud9@homeassistant.service echo "Checking the installation..." +sleep 15 validation=$(pgrep -f cloud9) if [ ! -z "${validation}" ]; then echo diff --git a/package/opt/hassbian/suites/custom-component-store.sh b/package/opt/hassbian/suites/custom-component-store.sh new file mode 100644 index 00000000..f64b94d7 --- /dev/null +++ b/package/opt/hassbian/suites/custom-component-store.sh @@ -0,0 +1,112 @@ +#!/bin/bash +function custom-component-store-show-short-info { + echo "Custom component store script." +} + +function custom-component-store-show-long-info { + echo "Custom component store is a web UI tool that can help you manage your custom components." +} + +function custom-component-store-show-copyright-info { + echo "Original concept by Ludeeus ." +} + +function custom-component-store-install-package { + +if [ "$ACCEPT" == "true" ]; then + username=pi + password=raspberry +else + echo + echo "Please take a moment to setup your the user account" + echo + + echo -n "Username: " + read -r username + if [ ! "$username" ]; then + username=pi + fi + + echo -n "Password: " + read -s -r password + echo + if [ ! "$password" ]; then + password=raspberry + fi +fi + +echo "Installing latest version of Custom component store" +python3 -m pip install componentstore + +echo "Enabling Custom component store service" +cp /opt/hassbian/suites/files/custom-component-store@homeassistant.service /etc/systemd/system/custom-component-store@homeassistant.service + +sed -i "s,%%USERNAME%%,${username},g" /etc/systemd/system/custom-component-store@homeassistant.service +sed -i "s,%%PASSWORD%%,${password},g" /etc/systemd/system/custom-component-store@homeassistant.service + +systemctl enable custom-component-store@homeassistant.service +sync + +echo "Starting Custom component storer" +systemctl start custom-component-store@homeassistant.service + +echo "Starting cleanup" +cd || exit 1 +rm -R /tmp/custom-component-store + +ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') + +echo "Checking the installation..." +validation=$(pgrep -x componentstore) +if [ ! -z "${validation}" ]; then + echo + echo -e "\\e[32mInstallation done..\\e[0m" + echo "Custom component store installation is running at $ip_address:8120 or if preferred http://hassbian.local:8120" + echo + echo +else + echo + echo -e "\\e[31mInstallation failed..." + echo + return 1 +fi +return 0 +} + +function custom-component-store-upgrade-package { +echo "Upgrading Custom component store" +python3 -m pip install --upgrade componentstore + +echo "Restarting Custom component store" +systemctl start custom-component-store@homeassistant.service + +echo "Checking the installation..." +validation=$(pgrep -x componentstore) +if [ ! -z "${validation}" ]; then + echo + echo -e "\\e[32mUpgrade script completed..\\e[0m" + echo +else + echo + echo -e "\\e[31mUpgrade failed..." + echo + return 1 +fi +return 0 +} + +function custom-component-store-remove-package { +printf "Removing Custom component store...\\n" +systemctl stop custom-component-store@homeassistant.service +systemctl disable custom-component-store@homeassistant.service +rm /etc/systemd/system/custom-component-store@homeassistant.service +sync + + +python3 -m pip uninstall --yes componentstore + + +printf "\\e[32mRemoval done..\\e[0m\\n" +} + +[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead" \ No newline at end of file diff --git a/package/opt/hassbian/suites/files/custom-component-store@homeassistant.service b/package/opt/hassbian/suites/files/custom-component-store@homeassistant.service new file mode 100644 index 00000000..373e1e3a --- /dev/null +++ b/package/opt/hassbian/suites/files/custom-component-store@homeassistant.service @@ -0,0 +1,16 @@ +# +# Service file for systems with systemd to run custom-component-store as the homeassistant user. +# + +[Unit] +Description=custom-component-store for %i +After=network.target + +[Service] +Type=simple +User=%i +ExecStart=/usr/local/bin/componentstore --port 8120 --nocache --username %%USERNAME%% --password %%PASSWORD%% --ha_path /home/homeassistant/.homeassistant +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/package/opt/hassbian/suites/files/hassbian-manager@homeassistant.service b/package/opt/hassbian/suites/files/hassbian-manager@homeassistant.service new file mode 100644 index 00000000..7a8c1a35 --- /dev/null +++ b/package/opt/hassbian/suites/files/hassbian-manager@homeassistant.service @@ -0,0 +1,16 @@ +# +# Service file for systems with systemd to run Hassbian manager as the homeassistant user. +# + +[Unit] +Description=Hassbian manager for %i +After=network.target + +[Service] +Type=simple +User=%i +ExecStart=/usr/local/bin/pyhassbian --username %%USERNAME%% --password %%PASSWORD%% +SendSIGKILL=no + +[Install] +WantedBy=multi-user.target diff --git a/package/opt/hassbian/suites/homeassistant.sh b/package/opt/hassbian/suites/homeassistant.sh index 955376e0..6bd4dd06 100644 --- a/package/opt/hassbian/suites/homeassistant.sh +++ b/package/opt/hassbian/suites/homeassistant.sh @@ -136,6 +136,7 @@ EOF config_check_lines=$(echo "$config_check" | wc -l) if (( config_check_lines > 2 ));then if [ "$ACCEPT" != "true" ]; then + echo "$config_check" echo -n "Config check failed for new version, do you want to revert? [Y/n] : " read -r RESPONSE if [ ! "$RESPONSE" ]; then diff --git a/package/opt/hassbian/suites/manager.sh b/package/opt/hassbian/suites/manager.sh new file mode 100644 index 00000000..b3912d59 --- /dev/null +++ b/package/opt/hassbian/suites/manager.sh @@ -0,0 +1,109 @@ +#!/bin/bash +function manager-show-short-info { + echo "Hassbian manager script." +} + +function manager-show-long-info { + echo "Hassbian manager is a web UI tool that can help you manage your suites." +} + +function manager-show-copyright-info { + echo "Original concept by Ludeeus ." +} + +function manager-install-package { + +if [ "$ACCEPT" == "true" ]; then + username=pi + password=raspberry +else + echo + echo "Please take a moment to setup your the user account" + echo + + echo -n "Username: " + read -r username + if [ ! "$username" ]; then + username=pi + fi + + echo -n "Password: " + read -s -r password + echo + if [ ! "$password" ]; then + password=raspberry + fi +fi + +echo "Installing latest version of Hassbian manager" +python3 -m pip install setuptools wheel +python3 -m pip install pyhassbian + + +echo "Enabling Hassbian manager service" +cp /opt/hassbian/suites/files/hassbian-manager@homeassistant.service /etc/systemd/system/hassbian-manager@homeassistant.service + +sed -i "s,%%USERNAME%%,${username},g" /etc/systemd/system/hassbian-manager@homeassistant.service +sed -i "s,%%PASSWORD%%,${password},g" /etc/systemd/system/hassbian-manager@homeassistant.service + +systemctl enable hassbian-manager@homeassistant.service +sync + +echo "Starting Hassbian manager" +systemctl start hassbian-manager@homeassistant.service + +ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') + +echo "Checking the installation..." +validation=$(pgrep -x pyhassbian) +if [ ! -z "${validation}" ]; then + echo + echo -e "\\e[32mInstallation done..\\e[0m" + echo "Hassbian manager installation is running at $ip_address:9999 or if preferred http://hassbian.local:9999" + echo + echo +else + echo + echo -e "\\e[31mInstallation failed..." + echo + return 1 +fi +return 0 +} + +function manager-upgrade-package { +echo "Upgrading Hassbian manager" +python3 -m pip install --upgrade pyhassbian + +echo "Restarting Hassbian manager" +systemctl start hassbian-manager@homeassistant.service + +echo "Checking the installation..." +validation=$(pgrep -x pyhassbian) +if [ ! -z "${validation}" ]; then + echo + echo -e "\\e[32mUpgrade script completed..\\e[0m" + echo +else + echo + echo -e "\\e[31mUpgrade failed..." + echo + return 1 +fi +return 0 +} + +function manager-remove-package { +printf "Removing Hassbian manager...\\n" +systemctl stop hassbian-manager@homeassistant.service +systemctl disable hassbian-manager@homeassistant.service +rm /etc/systemd/system/hassbian-manager@homeassistant.service +sync + +echo "Removing Hassbian manager" +python3 -m pip uninstall --yes pyhassbian + +printf "\\e[32mRemoval done..\\e[0m\\n" +} + +[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead" diff --git a/package/opt/hassbian/suites/zigbee2mqtt.sh b/package/opt/hassbian/suites/zigbee2mqtt.sh index 7945d148..0638ffa6 100644 --- a/package/opt/hassbian/suites/zigbee2mqtt.sh +++ b/package/opt/hassbian/suites/zigbee2mqtt.sh @@ -16,7 +16,7 @@ echo -n "Installing dependencies : " node=$(which npm) if [ -z "${node}" ]; then #Installing NodeJS if not already installed. printf "Downloading and installing NodeJS...\\n" - curl -sL https://deb.nodesource.com/setup_8.x | bash - + curl -sL https://deb.nodesource.com/setup_10.x | bash - apt install -y nodejs fi diff --git a/package/usr/local/bin/hassbian-config b/package/usr/local/bin/hassbian-config index 4817874e..8083f2d3 100755 --- a/package/usr/local/bin/hassbian-config +++ b/package/usr/local/bin/hassbian-config @@ -183,7 +183,11 @@ function run-suite { #This is the function the actually run install/upgrade. RETURN=("$?") # Return value after script execution. if [ "$DEBUG" == "true" ]; then set +x; fi #Deactivating debug if --debug is used. if [ "$RETURN" == "0" ]; then STATE="installed"; else printf "\\e[0mIf you have issues with this script, please say something in the #devs_hassbian channel on Discord.\\n" && STATE="failed"; fi #Set suite state to installed if 0 is returned, failed otherwise. - echo "SCRIPTSTATE=$STATE" > "$SUITE_CONTROL_DIR/$2" #Setting status in control file. + if [ "$1" == "remove" ]; then + rm "$SUITE_CONTROL_DIR/$2" + else + echo "SCRIPTSTATE=$STATE" > "$SUITE_CONTROL_DIR/$2" #Setting status in control file. + fi return 0 }