浏览代码

Update pyenv2.sh

tteckster 2 年之前
父节点
当前提交
124e0e191b
共有 1 个文件被更改,包括 24 次插入7 次删除
  1. 24 7
      misc/pyenv2.sh

+ 24 - 7
misc/pyenv2.sh

@@ -27,6 +27,7 @@ cd /srv/homeassistant
 python3 -m venv .
 source bin/activate
 python3 -m pip install wheel &>/dev/null
+pip3 install --upgrade pip &>/dev/null
 pip3 install psycopg2-binary &>/dev/null
 pip3 install --pre homeassistant &>/dev/null
 systemctl enable homeassistant &>/dev/null
@@ -40,19 +41,35 @@ if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]
   ESP="Y"
 fi
 if [[ $ESP == "Y" ]]; then
-echo "Installing ESPHome"
+echo "Installing ESPHome Beta"
+mkdir /srv/esphome
+cd /srv/esphome
+python3 -m venv .
+source bin/activate
+python3 -m pip install wheel &>/dev/null
+pip3 install --upgrade pip &>/dev/null
 pip3 install --pre esphome &>/dev/null
-cat <<EOF >/etc/systemd/system/esphomeDashboard.service
+cat <<EOF >/srv/esphome/start.sh
+#!/bin/bash
+source /srv/esphome/bin/activate
+esphome dashboard /srv/esphome/
+EOF
+chmod +x start.sh
+cat <<EOF >/etc/systemd/system/esphomedashboard.service
 [Unit]
-Description=ESPHome Dashboard
+Description=ESPHome Dashboard Service
 After=network.target
 [Service]
-ExecStart=/root/.pyenv/versions/3.10.8/bin/esphome /root/.pyenv/versions/3.10.8/lib/python3.10/site-packages/esphome_dashboard dashboard
-Restart=always
+Type=simple
 User=root
+WorkingDirectory=/srv/esphome
+ExecStart=/srv/esphome/start.sh
+RestartSec=30
+Restart=on-failure
 [Install]
 WantedBy=multi-user.target
 EOF
-systemctl enable --now esphomeDashboard &>/dev/null
-echo "Installed ESPHome"
+systemctl enable --now esphomedashboard &>/dev/null
+echo "Installed ESPHome Beta"
+echo -e " Go to $(hostname -I | awk '{print $1}'):6052"
 fi