Skip to content

Commit

Permalink
No dollar signs in shell code (home-assistant#10477)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Sep 29, 2019
1 parent 448fc17 commit 79206dd
Show file tree
Hide file tree
Showing 43 changed files with 316 additions and 306 deletions.
3 changes: 2 additions & 1 deletion .remarkrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ var remarkrc = {
},
plugins: [
["frontmatter"],
["lint-fenced-code-flag"]
["lint-fenced-code-flag"],
["lint-no-shell-dollars"]
]
};

Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"remark-frontmatter": "^1.3.2",
"remark-lint": "^6.0.5",
"remark-lint-fenced-code-flag": "^1.0.3",
"remark-lint-no-shell-dollars": "^1.0.3",
"remark-stringify": "^7.0.3"
},
"scripts": {
"markdown:lint": "remark --quiet --frail ."
}
}
}
8 changes: 4 additions & 4 deletions source/_components/bluetooth_le_tracker.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Devices discovered are stored with 'BLE_' as the prefix for device mac addresses
This platform requires pybluez to be installed. On Debian based installs, run

```bash
$ sudo apt install bluetooth
sudo apt install bluetooth
```

Before you get started with this platform, please note that:
Expand Down Expand Up @@ -52,9 +52,9 @@ Some BTLE devices (e.g., fitness trackers) are only visible to the devices that
Normally accessing the Bluetooth stack is reserved for root, but running programs that are networked as root is a bad security wise. To allow non-root access to the Bluetooth stack we can give Python 3 and hcitool the missing capabilities to access the Bluetooth stack. Quite like setting the setuid bit (see [Stack Exchange](http://unix.stackexchange.com/questions/96106/bluetooth-le-scan-as-non-root) for more information).
```bash
$ sudo apt-get install libcap2-bin
$ sudo setcap 'cap_net_raw,cap_net_admin+eip' `readlink -f \`which python3\``
$ sudo setcap 'cap_net_raw+ep' `readlink -f \`which hcitool\``
sudo apt-get install libcap2-bin
sudo setcap 'cap_net_raw,cap_net_admin+eip' `readlink -f \`which python3\``
sudo setcap 'cap_net_raw+ep' `readlink -f \`which hcitool\``
```

A restart of Home Assistant is required.
Expand Down
6 changes: 3 additions & 3 deletions source/_components/eddystone_temperature.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ All beacons that support the Eddystone protocol, have a temperature sensor and c
As this platform uses `bluez` to scan for Bluetooth LE devices **a Linux OS with bluez installed** is required. In addition to that, the `libbluetooth` headers need to be installed:

```bash
$ sudo apt-get install libbluetooth-dev
sudo apt-get install libbluetooth-dev
```

Scanning for Bluetooth LE devices also requires special permissions. To grant these to the python executable execute the following:

```bash
$ sudo apt-get install libcap2-bin
$ sudo setcap 'cap_net_raw,cap_net_admin+eip' $(readlink -f $(which python3))
sudo apt-get install libcap2-bin
sudo setcap 'cap_net_raw,cap_net_admin+eip' $(readlink -f $(which python3))
```

To use your Eddystone beacon in your installation, add the following to your `configuration.yaml` file:
Expand Down
8 changes: 4 additions & 4 deletions source/_components/ffmpeg.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ ffmpeg_bin:
To get the binary on Raspbian Debian Jessie Lite on a RPi you need to perform the following:

```bash
$ sudo echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get -t jessie-backports install ffmpeg
sudo echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get -t jessie-backports install ffmpeg
```

We can use now following in the configuration:
Expand All @@ -60,7 +60,7 @@ In most cases, `ffmpeg` automatically detects all needed options to read a video
First, check that your stream is playable by `ffmpeg` outside of Home Assistant with (use option `-an` or `-vn` to disable video or audio stream):

```bash
$ ffmpeg -i INPUT -an -f null -
ffmpeg -i INPUT -an -f null -
```

Now you should be able to see what is going wrong. The following list contains some common problems and solutions:
Expand Down
9 changes: 4 additions & 5 deletions source/_components/hdmi_cec.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ If you are using [Hass.io](/hassio/) then just move forward to the configuration
Create a symlink to the `cec` installation including the _cec.so file. Keep in mind different installation methods will result in different locations of cec.

```bash
$ ln -s /path/to/your/installation/of/cec.py /path/to/your/venv/lib/python*/site-packages
$ ln -s /path/to/your/installation/of/_cec.so /path/to/your/venv/lib/python*/site-packages
ln -s /path/to/your/installation/of/cec.py /path/to/your/venv/lib/python*/site-packages
ln -s /path/to/your/installation/of/_cec.so /path/to/your/venv/lib/python*/site-packages

```

Expand All @@ -41,9 +41,8 @@ $ ln -s /path/to/your/installation/of/_cec.so /path/to/your/venv/lib/python*/sit
For the default virtual environment of a [HASSbian Image for Raspberry Pi](/docs/installation/raspberry-pi/) the command would be as follows.

```bash
$ ln -s /usr/local/lib/python*/dist-packages/cec.py /srv/homeassistant/lib/python*/site-packages
$ ln -s /usr/local/lib/python*/dist-packages/_cec.so /srv/homeassistant/lib/python*/site-packages

ln -s /usr/local/lib/python*/dist-packages/cec.py /srv/homeassistant/lib/python*/site-packages
ln -s /usr/local/lib/python*/dist-packages/_cec.so /srv/homeassistant/lib/python*/site-packages
```

<div class='note'>
Expand Down
12 changes: 6 additions & 6 deletions source/_components/pandora.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ This media player uses the [Pianobar command-line Pandora client](https://github
The version of pianobar that comes with Jessie has a bug, so you have to build a more recent version. The latest version depends on a recent version of libraries associated with ffmpeg, so you should make sure you go through the backport process documented in [The FFmpeg component](/components/ffmpeg/) before doing this. Install the following basic dependencies:

```bash
$ sudo apt-get install git libao-dev libgcrypt11-dev libfaad-dev libmad0-dev libjson-c-dev make pkg-config libcurl4-openssl-dev
sudo apt-get install git libao-dev libgcrypt11-dev libfaad-dev libmad0-dev libjson-c-dev make pkg-config libcurl4-openssl-dev
```

And now install the backported ffmpeg-related libraries (note that if you're using an older version of ffmpeg for other things on this machine, you may encounter issues after doings this):

```bash
$ sudo apt-get -t jessie-backports install libav-tools libavcodec-extra libavcodec-dev libavfilter-dev libavformat-dev
sudo apt-get -t jessie-backports install libav-tools libavcodec-extra libavcodec-dev libavfilter-dev libavformat-dev
```

Now clone the Pianobar repo and build pianobar:

```bash
$ git clone https://github.com/PromyLOPh/pianobar.git
$ cd pianobar
$ make clean && make
$ sudo make install
git clone https://github.com/PromyLOPh/pianobar.git
cd pianobar
make clean && make
sudo make install
```

Configure Pianobar to auto-login and start playing a station (optional, see `man pianobar`) by creating and editing the `~/.config/pianobar/config` file:
Expand Down
26 changes: 13 additions & 13 deletions source/_components/recorder.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ If you are using the default `FULL` recovery model for MS SQL Server you will ne
If you are running a database server instance on the same server as Home Assistant then you must ensure that this service starts before Home Assistant. For a Linux instance running Systemd (Raspberry Pi, Debian, Ubuntu and others) then you should edit the service file.

```bash
$ sudo nano /etc/systemd/system/[email protected]
sudo nano /etc/systemd/system/[email protected]
```

and add the service for the database, for example, PostgreSQL:
Expand All @@ -183,7 +183,7 @@ After=network.target postgresql.service
Save the file then reload `systemctl`:

```bash
$ sudo systemctl daemon-reload
sudo systemctl daemon-reload
```

## Installation notes
Expand All @@ -205,15 +205,15 @@ For MariaDB you may have to install a few dependencies. If you're using MariaDB
On the Python side we use the `mysqlclient`:

```bash
$ sudo apt-get install libmariadbclient-dev libssl-dev
$ pip3 install mysqlclient
sudo apt-get install libmariadbclient-dev libssl-dev
pip3 install mysqlclient
```

For MySQL you may have to install a few dependencies. You can choose between `pymysql` and `mysqlclient`:

```bash
$ sudo apt-get install default-libmysqlclient-dev libssl-dev
$ pip3 install mysqlclient
sudo apt-get install default-libmysqlclient-dev libssl-dev
pip3 install mysqlclient
```

After installing the dependencies, it is required to create the database manually. During the startup, Home Assistant will look for the database specified in the `db_url`. If the database doesn't exist, it will not automatically create it for you.
Expand All @@ -225,8 +225,8 @@ Once Home Assistant finds the database, with the right level of permissions, all
For PostgreSQL you may have to install a few dependencies:

```bash
$ sudo apt-get install postgresql-server-dev-X.Y
$ pip3 install psycopg2
sudo apt-get install postgresql-server-dev-X.Y
pip3 install psycopg2
```

For using Unix Sockets, add the following line to your [`pg_hba.conf`](https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html):
Expand All @@ -250,14 +250,14 @@ A service restart will work as well.
For MS SQL Server you may have to install a few dependencies:

```bash
$ sudo apt-get install freetds-dev
$ pip3 install pymssql
sudo apt-get install freetds-dev
pip3 install pymssql
```

If you are in a virtual environment, don't forget to activate it before installing the pymssql package.

```bash
$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install pymssql
sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
pip3 install pymssql
```
8 changes: 4 additions & 4 deletions source/_components/samsungtv.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ No additional actions are required
You will need to activate the venv and install the websocket library:

```bash
$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install websocket-client
sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
pip3 install websocket-client
```
### Other install methods

You will need to install the `websocket-client` Python package in your Home Assistant install. This will probably be done with:

```bash
$ pip3 install websocket-client
pip3 install websocket-client
```

Remembering to activate your venv if you're using a venv install.
16 changes: 8 additions & 8 deletions source/_components/seven_segments.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ If you are using [Hass.io](/hassio/) then just move forward to the configuration
`ssocr` needs to be available on your system. Check the installation instruction below:

```bash
$ sudo dnf -y install imlib2-devel # Fedora
$ sudo apt install libimlib2-dev # Ubuntu
$ brew install imlib2 # macOS
$ git clone https://github.com/auerswal/ssocr.git
$ cd ssocr
$ make
$ sudo make PREFIX=/usr install # On most systems
$ make deb # (Optional) This allows you to make a deb so that you apt is aware of ssocr
sudo dnf -y install imlib2-devel # Fedora
sudo apt install libimlib2-dev # Ubuntu
brew install imlib2 # macOS
git clone https://github.com/auerswal/ssocr.git
cd ssocr
make
sudo make PREFIX=/usr install # On most systems
make deb # (Optional) This allows you to make a deb so that you apt is aware of ssocr
```

To enable the OCR of a seven segment display in your installation, add the following to your `configuration.yaml` file:
Expand Down
20 changes: 10 additions & 10 deletions source/_components/snips.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ Snips takes voice or text as input and produces *intents* as output, which are e
The Snips platform can be installed via the Snips APT/Debian repository.

```bash
$ sudo apt-get update
$ sudo apt-get install -y dirmngr
$ sudo bash -c 'echo "deb https://raspbian.snips.ai/$(lsb_release -cs) stable main" > /etc/apt/sources.list.d/snips.list'
$ sudo apt-key adv --keyserver pgp.mit.edu --recv-keys D4F50CDCA10A2849
$ sudo apt-get update
$ sudo apt-get install -y snips-platform-voice
sudo apt-get update
sudo apt-get install -y dirmngr
sudo bash -c 'echo "deb https://raspbian.snips.ai/$(lsb_release -cs) stable main" > /etc/apt/sources.list.d/snips.list'
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys D4F50CDCA10A2849
sudo apt-get update
sudo apt-get install -y snips-platform-voice
```

Note that if the keyserver pgp.mit.edu is down then try to use another one in the 4th line, like pgp.surfnet.nl:

```bash
$ sudo apt-key adv --keyserver pgp.surfnet.nl --recv-keys D4F50CDCA10A2849
sudo apt-key adv --keyserver pgp.surfnet.nl --recv-keys D4F50CDCA10A2849
```

### Creating an assistant
Expand All @@ -45,13 +45,13 @@ Head over to the [Snips Console](https://console.snips.ai) to create your assist
The next step is to get the assistant to work on your device. Unzip and copy the `assistant` folder that you downloaded from the web console to the path. Assuming your downloaded `assistant` folder is on your desktop, just run:

```bash
$ scp -r ~/Desktop/assistant pi@<raspi_hostname.local_or_IP>:/home/pi/.
scp -r ~/Desktop/assistant pi@<raspi_hostname.local_or_IP>:/home/pi/.
```

Now ssh into your Raspberry Pi:

```bash
$ ssh pi@<raspi_hostname.local_or_IP>
ssh pi@<raspi_hostname.local_or_IP>
```

By default, this command is `ssh [email protected]`, if you are using the default Raspberry Pi hostname.
Expand All @@ -76,7 +76,7 @@ Make sure that a microphone is plugged to the Raspberry Pi. If you are having tr
Start the Snips Voice Platform by starting the `snips-*` services:

```bash
$ sudo systemctl start "snips-*"
sudo systemctl start "snips-*"
```

Snips is now ready to take voice commands from the microphone. To trigger the listening, simply say
Expand Down
20 changes: 10 additions & 10 deletions source/_cookbook/fail2ban.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ This is a quick guide on how to set up `fail2ban` for Home Assistant. Contains e
Debian/Ubuntu:

```bash
$ sudo apt-get install fail2ban
sudo apt-get install fail2ban
```

CentOS/RHEL:

```bash
$ sudo yum install epel-release
$ sudo yum install -y fail2ban
sudo yum install epel-release
sudo yum install -y fail2ban
```
Fedora:

```bash
$ sudo dnf install -y fail2ban
sudo dnf install -y fail2ban
```

For other package managers use the appropriate commands.
Expand All @@ -42,7 +42,7 @@ logger:
Restart Home Assistant to activate the changes:
```bash
$ sudo systemctl restart home-assistant
sudo systemctl restart home-assistant
```

Tail the Home Assistant log then log out of the Home Assistant web interface and attempt logging in with an incorrect password, look for a line like `Login attempt or request with invalid authentication from xxx.xxx.xxx.xxx`:
Expand Down Expand Up @@ -141,20 +141,20 @@ sudo tail -f -n 20 /var/log/fail2ban.log
Now that fail2ban is working it can be enabled for startup at boot time, also raise the bantime from 30 seconds to what ever you would like. 8 hours is 28800 seconds.

```bash
$ sudo sed -i 's/bantime = 30/bantime = 28800/g' /etc/fail2ban/jail.d/ha.conf
$ sudo systemctl enable fail2ban
$ sudo systemctl restart fail2ban
sudo sed -i 's/bantime = 30/bantime = 28800/g' /etc/fail2ban/jail.d/ha.conf
sudo systemctl enable fail2ban
sudo systemctl restart fail2ban
```

A final note, if you need to unban an IP it can be done with `fail2ban-client`:

```bash
$ sudo fail2ban-client set JAILNAME unbanip IPADDRESS
sudo fail2ban-client set JAILNAME unbanip IPADDRESS
```
eg:

```bash
$ sudo fail2ban-client set ha unbanip xxx.xxx.xxx.xxx
sudo fail2ban-client set ha unbanip xxx.xxx.xxx.xxx
```

Fail2ban should now be configured and running, if an IP address is banned you will receive an email with WHOIS details about the IP address that attempted to connect, if not you will need configure Postfix or another MTA (Mail Transport Agent).
Expand Down
6 changes: 3 additions & 3 deletions source/_cookbook/owntracks_two_mqtt_broker.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ password_file /etc/mosquitto/pwfile
Create a password for `mosquitto-ext`

```bash
$ docker exec -it mosquitto-ext /bin/bash
$ cd /etc/mosquitto/
$ mosquitto_passwd -c /etc/mosquitto/pwfile <userID>
docker exec -it mosquitto-ext /bin/bash
cd /etc/mosquitto/
mosquitto_passwd -c /etc/mosquitto/pwfile <userID>
```

### OwnTracks settings for Android
Expand Down
Loading

0 comments on commit 79206dd

Please sign in to comment.