Last active
March 21, 2020 09:03
-
-
Save mplinuxgeek/25836c08d872359f1285e4045a374af1 to your computer and use it in GitHub Desktop.
Home Assistant Python Virtual environment on Fedora 31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dnf update | |
reboot | |
firewall-cmd --add-port=8123/tcp --permanent | |
firewall-cmd --reload | |
sudo useradd -rm homeassistant -G dialout | |
cd /srv | |
sudo mkdir homeassistant | |
sudo chown homeassistant:homeassistant homeassistant | |
sudo dnf groupinstall 'Development Tools' | |
sudo dnf install python3-devel autoconf | |
nano /etc/systemd/system/home-assistant.service | |
[Unit] | |
Description=Home Assistant | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=homeassistant | |
Environment=VIRTUAL_ENV="/srv/homeassistant/" | |
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant" | |
Restart=on-failure | |
RestartSec=5s | |
[Install] | |
WantedBy=multi-user.target | |
sudo systemctl daemon-reload | |
sudo systemctl status home-assistant | |
sudo systemctl start home-assistant | |
sudo systemctl status home-assistant | |
setenforce 0 | |
cd /etc/systemd/system/ | |
ls -Zal | |
sudo chcon system_u:object_r:systemd_unit_file_t:s0 home-assistant.service | |
sudo chcon system_u:object_r:systemd_unit_file_t:s0 dnf-automatic-install.service.d/ | |
ls -Zal | |
sudo nano /etc/selinux/config | |
#SELINUX=enforcing | |
SELINUX=permissive | |
# Clone zigbee2mqtt repository | |
sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt | |
sudo su - | |
useradd -rm zigbee2mqtt -G dialout | |
chown -R zigbee2mqtt:zigbee2mqtt /opt/zigbee2mqtt | |
su - zigbee2mqtt | |
# Enter folder | |
cd /opt/zigbee2mqtt | |
# Install python env | |
python3 -m venv . | |
# Activate environment | |
source /opt/zigbee2mqtt/bin/activate | |
# Upgrade pip, wheel and setuptools | |
pip install --upgrade pip wheel setuptools | |
# Install node environment | |
pip install nodeenv | |
# Init node environment | |
nodeenv -p -n 10.15.1 | |
# Deactivate and activate environment to be sure | |
deactivate | |
source /opt/zigbee2mqtt/bin/activate | |
# Install dependencies | |
cd /opt/zigbee2mqtt | |
npm ci | |
# Deactivate environment | |
deactivate | |
# Enter folder | |
cd /opt/zigbee2mqtt | |
# Activate environment | |
source /opt/zigbee2mqtt/bin/activate | |
# Start | |
npm start | |
# ctrl + c to quit | |
# Deactivate environment | |
deactivate | |
sudo nano /etc/systemd/system/zigbee2mqtt.service | |
Add the following to this file: | |
[Unit] | |
Description=zigbee2mqtt | |
After=network.target | |
[Service] | |
ExecStart=/bin/bash -c 'source /opt/zigbee2mqtt/bin/activate; /opt/zigbee2mqtt/bin/npm start' | |
WorkingDirectory=/opt/zigbee2mqtt | |
StandardOutput=inherit | |
StandardError=inherit | |
Restart=always | |
User=zigbee2mqtt | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment