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

Commit

Permalink
Merge pull request #215 from home-assistant/dev
Browse files Browse the repository at this point in the history
Release v0.11.0
  • Loading branch information
Landrash authored Nov 6, 2018
2 parents 61f1bb9 + 1ee0572 commit c99814c
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ below for usage and instructions.
- [AppDaemon](/docs/appdaemon.md)
- [Cloud9](/docs/cloud9.md)
- [Duck DNS](/docs/duckdns.md)
- [Fail2ban](/docs/fail2ban.md)
- [Hassbian](/docs/hassbian.md)
- [Home Assistant](/docs/homeassistant.md)
- [Homebridge](/docs/homebridge.md)
Expand All @@ -30,6 +31,7 @@ below for usage and instructions.
- [Samba](/docs/samba.md)
- [Trådfri](/docs/tradfri.md)
- [Webterminal](/docs/webterminal.md)
- [Zigbee2mqtt](/docs/zigbee2mqtt.md)
- [Changelog][changelog]

***
Expand Down
34 changes: 34 additions & 0 deletions docs/fail2ban.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Fail2Ban

This script installs the fail2ban service.
Some further configuration is required after installation. More information [here](https://www.home-assistant.io/cookbook/fail2ban/).

## Installation

```bash
sudo hassbian-config install fail2ban
```

## Upgrade

There's nothing to upgrade.

## Additional info

Description | Command/value
:--- | :---
Running as: | root
Configuration file: | /etc/fail2ban/filter.d/ha.conf
Configuration file: | /etc/fail2ban/jail.d/ha.conf
Start service: | `sudo systemctl start fail2ban.service`
Stop service: | `sudo systemctl stop fail2ban.service`
Restart service: | `sudo systemctl restart fail2ban.service`
Service status: | `sudo systemctl status fail2ban.service`

***

This install script was originally contributed by [@Landrash][landrash]

<!--- Links --->
[landrash]: https://github.com/landrash
[repo]: https://github.com/home-assistant/hassbian-scripts/pulls
2 changes: 1 addition & 1 deletion docs/pihole.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Monitor
# Pi-hole

This script downloads and runs the [Pi-Hole][pihole] install script from https://pi-hole.net/ .
## Installation
Expand Down
37 changes: 37 additions & 0 deletions docs/zigbee2mqtt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Zigbee2mqtt

This script installs the [Zigbee2mqtt bridge][zigbee2mqtt].
After installation some further configuration is required. Instructions can be found [here][zigbee2mqttdocs].

## Installation

```bash
sudo hassbian-config install zigbee2mqtt
```

## Upgrade

No script available, maybe you could write one?
If so, add an PR here when you are done:
[homeassistant/hassbian-scripts][repo]

## Additional info

Description | Command/value
:--- | :---
Running as: | pi
Configuration file: | /opt/zigbee2mqtt/data/configuration.yaml
Start service: | `sudo systemctl start zigbee2mqtt.service`
Stop service: | `sudo systemctl stop zigbee2mqtt.service`
Restart service: | `sudo systemctl restart zigbee2mqtt.service`
Service status: | `sudo systemctl status zigbee2mqtt.service`

***

This install script was originally contributed by [@Landrash][landrash]

<!--- Links --->
[zigbee2mqtt]: https://github.com/Koenkk/zigbee2mqtt/
[zigbee2mqttdocs]: https://github.com/Koenkk/zigbee2mqtt/wiki/Running-the-bridge#3-configuring
[landrash]: https://github.com/landrash
[repo]: https://github.com/home-assistant/hassbian-scripts/pulls
2 changes: 1 addition & 1 deletion package/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: hassbian-scripts
Version: 0.10.0
Version: 0.11.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
Expand Down
81 changes: 81 additions & 0 deletions package/opt/hassbian/suites/fail2ban.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
function fail2ban-show-short-info {
echo "Setup for fail2ban service."
}

function fail2ban-show-long-info {
echo "This script installs the fail2ban service."
echo "Some further configuration is required after installation."
}

function fail2ban-show-copyright-info {
echo "Original concept by Landrash <https://github.com/landrash>."
}

function fail2ban-install-package {
echo "Installing fail2ban package"
apt install -y fail2ban

FAIL2BANFILTER="/etc/fail2ban/filter.d/ha.conf"
FAIL2BANJAIL="/etc/fail2ban/jail.d/ha.conf"

echo "Creating configuration files"
if [ -f $FAIL2BANFILTER ] ; then
echo "Configuration file exists. Skipping.."
else

echo "[INCLUDES]
before = common.conf
[Definition]
failregex = ^%(__prefix_line)s.*Login attempt or request with invalid authentication from <HOST>.*$
ignoreregex =" > "$FAIL2BANFILTER"

fi

if [ -f $FAIL2BANJAIL ] ; then
echo "Configuration file exists. Skipping.."
else

echo "[DEFAULT]
# Email config
sender = email@address.com
destemail = email@address.com
# Action %(action_mwl)s will ban the IP and send an email notification including whois data and log entries.
action = %(action_mwl)s
[ha]
enabled = true
filter = ha
logpath = /home/homeassistant/.homeassistant/home-assistant.log
# 3600 seconds = 1 hour
bantime = 3600
#bantime = 30 # during testing it is useful to have a short ban interval, comment out this line later
# Maximum amount of login attempts before IP is blocked
maxretry = 3" > "$FAIL2BANJAIL"
fi

echo "Restarting fail2ban service"
systemctl restart fail2ban

echo "Checking the installation..."
validation=$(which fail2ban-client)
if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done.\\e[0m"
echo
echo "To continue have a look at https://www.home-assistant.io/cookbook/fail2ban/"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
}

[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead"
73 changes: 73 additions & 0 deletions package/opt/hassbian/suites/zigbee2mqtt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
function zigbee2mqtt-show-short-info {
echo "Setup for Zigbee2mqtt bridge."
}

function zigbee2mqtt-show-long-info {
echo "This script installs the Zigbee2mqtt bridge"
}

function zigbee2mqtt-show-copyright-info {
echo "Original concept by Landrash <https://github.com/landrash>."
}

function zigbee2mqtt-install-package {
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 -
apt install -y nodejs
fi

echo "Cloning Zigbee2mqtt git repository"
git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
chown -R pi:pi /opt/zigbee2mqtt

echo "Running install. This might take a while and can produce som expected errors"
cd /opt/zigbee2mqtt || exit
su pi -c "npm install"

echo "Creating service file zigbee2mqtt.service"
service_path="/etc/systemd/system/zigbee2mqtt.service"

echo "[Unit]
Description=zigbee2mqtt
After=network.target
[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target" > $service_path

echo "Checking the installation..."
if [ ! -f /opt/zigbee2mqtt/data/configuration.yaml ]; then
validation=""
else
validation="ok"
fi

if [ ! -z "${validation}" ]; then
echo
echo -e "\\e[32mInstallation done..\\e[0m"
echo -e "Update of configuration.yaml is required found at /opt/zigbee2mqtt/data/"
echo -e "Some further configuration is required and details can be found here https://github.com/Koenkk/zigbee2mqtt/wiki/Running-the-bridge "
echo
echo -e "Service can be started after configuration but running sudo systemctl start zigbee2mqtt"
echo
else
echo
echo -e "\\e[31mInstallation failed..."
echo
return 1
fi
return 0
}

[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead"
2 changes: 1 addition & 1 deletion package/usr/local/bin/hassbian-config
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function raspberry_pi_zero_check {
if [ "$FORCE" != "true" ]; then
REVCODE=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^ *//g' | sed 's/ *$//g')
if [ "$REVCODE" = "90092" ] || [ "$REVCODE" = "90093" ] || [ "$REVCODE" = "0x9000C1" ] || [ "$REVCODE" = "9000c1" ]; then
if [[ "$1" =~ ^(mosquitto|cloud9)$ ]]; then
if [[ "$1" =~ ^(mosquitto|cloud9|zigbee2mqtt)$ ]]; then
echo "This suite can't be installed on Raspberry Pi Zero..."
exit 0
fi
Expand Down

0 comments on commit c99814c

Please sign in to comment.