Просмотр исходного кода

Update alpine-esphome-install.sh

tteckster 2 лет назад
Родитель
Сommit
d345712e7b
1 измененных файлов с 19 добавлено и 18 удалено
  1. 19 18
      install/alpine-esphome-install.sh

+ 19 - 18
install/alpine-esphome-install.sh

@@ -26,38 +26,39 @@ msg_info "Installing Alpine-ESPHome"
 $STD apk add py3-pip
 $STD apk add py3-pip
 $STD pip3 install esphome
 $STD pip3 install esphome
 $STD pip3 install tornado esptool
 $STD pip3 install tornado esptool
-cat <<EOF >/etc/init.d/esphome
-#!/sbin/openrc-run
 
 
-name="esphome"
-description="ESPHome Service"
-command="/usr/bin/esphome /root/config/ dashboard"
-pidfile="/run/esphome/pid"
+service_path="/etc/init.d/esphome"
+echo "#!/sbin/openrc-run
+name=\"esphome\"
+description=\"ESPHome Dashboard\"
+command=\"/usr/bin/esphome /root/config/ dashboard\"
+command_user=\"root\"
+command_background=true
+pidfile=\"/run/\$name.pid\"
 
 
 depend() {
 depend() {
     need net
     need net
 }
 }
 
 
 start_pre() {
 start_pre() {
-    checkpath --directory --mode 0755 /run/esphome
+    checkpath --directory --mode 0755 /run/\$name
 }
 }
 
 
 start() {
 start() {
-    ebegin "Starting $description"
-    start-stop-daemon --start --quiet --exec $command
-    eend $?
+    ebegin \"Starting \$description\"
+    start-stop-daemon --start --quiet --background --exec /usr/bin/esphome -- /root/config/ dashboard
+    eend \$?
 }
 }
 
 
 stop() {
 stop() {
-    ebegin "Stopping $description"
-    start-stop-daemon --stop --quiet --exec $command
-    eend $?
-}
-EOF
+    ebegin \"Stopping \$description\"
+    pkill esphome
+    eend \$?
+}" > $service_path
 
 
-chmod 755 /etc/init.d/esphome
-/etc/init.d/esphome start
-rc-update add esphome default
+chmod 755 $service_path
+$STD rc-update add esphome default
+$STD /etc/init.d/esphome start
 msg_ok "Installed Alpine-ESPHome"
 msg_ok "Installed Alpine-ESPHome"
 
 
 motd_ssh
 motd_ssh