Skip to content

Commit 7de7d3e

Browse files
brahmafearLandrash
authored andcommitted
Updated docs based on user suggestions (home-assistant#2196)
* Updated docs based on user suggestions Thanks to @NeLLyMerC for the suggestions. Removed the EOF syntax for creating a file. Cleaned up the description of the systemctl commands. Added 'sudo' to the journalctl commands as it will not show the logs if running as an unprived user. * Update systemd.markdown
1 parent 8d14537 commit 7de7d3e

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

source/_docs/autostart/systemd.markdown

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,28 @@ $ ps -p 1 -o comm=
1818

1919
If the preceding command returns the string `systemd`, you are likely using `systemd`.
2020

21-
If you want Home Assistant to be launched automatically, an extra step is needed to setup `systemd`. You need a service file to control Home Assistant with `systemd`. If you are using a Raspberry Pi with Raspbian then replace the `[your user]` with `pi` otherwise use your user you want to run Home Assistant. `ExecStart` contains the path to `hass` and this may vary. Check with `whereis hass` for the location.
21+
If you want Home Assistant to be launched automatically, an extra step is needed to setup `systemd`. A service file is needed to control Home Assistant with `systemd`. The template below should be created using a text editor. Note, root permissions via 'sudo' will likely be needed. The following should be noted to modify the template:
2222

23-
```bash
24-
$ su -c 'cat <<EOF >> /etc/systemd/system/home-assistant@.service
25-
[Unit]
26-
Description=Home Assistant
27-
After=network.target
28-
29-
[Service]
30-
Type=simple
31-
User=%i
32-
ExecStart=/usr/bin/hass
23+
+ `ExecStart` contains the path to `hass` and this may vary. Check with `whereis hass` for the location.
24+
+ If running Home Assistant in a python virtual environment or a docker, please skip to section below.
25+
+ For most systems, the file is `/etc/systemd/system/home-assistant@[your user].service` with [your user] replaced by the user account that Home Assistant will run as - normally `homeassistant`. For Ubuntu 16.04, the file is `/lib/systemd/system/home-assistant.service` and requires running this command `sudo ln -s /lib/systemd/system/home-assistant.service /etc/systemd/system/home-assistant.service` after file is created.
26+
+ If unfamiliar with command line text editors, `sudo nano -w [filename]` can be used with `[filename]` replaced with the full path to the file. Ex. `sudo nano -w /etc/systemd/system/home-assistant@homeassistant.service`. After text entered, press CTRL-X then press Y to save and exit.
3327

34-
[Install]
35-
WantedBy=multi-user.target
36-
EOF'
3728
```
38-
39-
For Ubunt 16.04 use this commands. Notice that files are saved in a slightly diffrent path
40-
41-
```bash
42-
$ su -c 'cat <<EOF >> /lib/systemd/system/home-assistant.service
4329
[Unit]
4430
Description=Home Assistant
4531
After=network.target
4632
4733
[Service]
4834
Type=simple
4935
User=%i
50-
ExecStart=/usr/local/bin/hass
36+
ExecStart=/usr/bin/hass
5137
5238
[Install]
5339
WantedBy=multi-user.target
54-
EOF'
5540
```
5641

57-
``` sudo ln -s /lib/systemd/system/home-assistant.service /etc/systemd/system/home-assistant.service```
58-
59-
If you've setup Home Assistant in `virtualenv` following our [python installation guide](https://home-assistant.io/getting-started/installation-virtualenv/) or [manual installation guide for raspberry pi](https://home-assistant.io/getting-started/installation-raspberry-pi/), the following template should work for you.
42+
If you've setup Home Assistant in `virtualenv` following our [python installation guide](https://home-assistant.io/getting-started/installation-virtualenv/) or [manual installation guide for raspberry pi](https://home-assistant.io/getting-started/installation-raspberry-pi/), the following template should work for you. If Home Assistant install is not located at `/srv/homeassistant`, please modify the `Enviroment=` and `ExecStart=` lines appropriately.
6043

6144
```
6245
[Unit]
@@ -94,18 +77,33 @@ ExecStopPost=/usr/bin/docker rm -f home-assistant-%i
9477
WantedBy=multi-user.target
9578
```
9679

97-
You need to reload `systemd` to make the daemon aware of the new configuration. Enable and launch Home Assistant after that.
80+
You need to reload `systemd` to make the daemon aware of the new configuration.
9881

9982
```bash
10083
$ sudo systemctl --system daemon-reload
84+
```
85+
86+
To have Home Assistant start automatically at boot, enable the service.
87+
88+
```bash
10189
$ sudo systemctl enable home-assistant@[your user]
90+
```
91+
92+
To disable the automatic start, use this command.
93+
94+
```bash
95+
$ sudo systemctl disable home-assistant@[your user]
96+
```
97+
98+
To start Home Assistant now, use this command.
99+
```bash
102100
$ sudo systemctl start home-assistant@[your user]
103101
```
104102

105-
If everything went well, `sudo systemctl start home-assistant@[your user]` should give you a positive feedback.
103+
You can also substitute the `start` above with `stop` to stop Home Assistant, `restart` to restart Home Assistant, and 'status' to see a brief status report as seen below.
106104

107105
```bash
108-
$ sudo systemctl status home-assistant@[your user] -l
106+
$ sudo systemctl status home-assistant@[your user]
109107
● home-assistant@fab.service - Home Assistant for [your user]
110108
Loaded: loaded (/etc/systemd/system/home-assistant@[your user].service; enabled; vendor preset: disabled)
111109
Active: active (running) since Sat 2016-03-26 12:26:06 CET; 13min ago
@@ -119,10 +117,10 @@ $ sudo systemctl status home-assistant@[your user] -l
119117
To get Home Assistant's logging output, simple use `journalctl`.
120118

121119
```bash
122-
$ journalctl -f -u home-assistant@[your user]
120+
$ sudo journalctl -f -u home-assistant@[your user]
123121
```
124122

125-
Because the log can scroll quite quickly, you might want to open a second terminal to view only the errors:
123+
Because the log can scroll quite quickly, you can select to view only the error lines:
126124
```bash
127-
$ journalctl -f -u home-assistant@[your user] | grep -i 'error'
125+
$ sudo journalctl -f -u home-assistant@[your user] | grep -i 'error'
128126
```

0 commit comments

Comments
 (0)