aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--esphomeapi@.service17
-rwxr-xr-xrun.sh11
2 files changed, 24 insertions, 4 deletions
diff --git a/esphomeapi@.service b/esphomeapi@.service
new file mode 100644
index 0000000..d10f8b4
--- /dev/null
+++ b/esphomeapi@.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Simple service to start esphomeapi
+StartLimitIntervalSec=100
+StartLimitBurst=5
+
+[Service]
+Type=simple
+EnvironmentFile=%h/energyscripts/.env
+WorkingDirectory=%h/energyscripts
+ExecStart=%h/energyscripts/venv/bin/python3 -u scripts/esphomeapi.py -a %i
+Restart=on-failure
+TimeoutStopSec=70
+RestartSec=30
+SyslogIdentifier=%N
+
+[Install]
+WantedBy=default.target
diff --git a/run.sh b/run.sh
index 57d3128..a31acb6 100755
--- a/run.sh
+++ b/run.sh
@@ -8,10 +8,13 @@ setopt all_export
source .env
unsetopt all_export
-if [[ -f $1 ]]; then
- ./venv/bin/python3 $1
-elif [[ -f scripts/$1 ]]; then
- ./venv/bin/python3 scripts/$1
+script=$1
+shift
+
+if [[ -f $script ]]; then
+ ./venv/bin/python3 $script $@
+elif [[ -f scripts/$script ]]; then
+ ./venv/bin/python3 scripts/$script $@
else
print -u2 "Computer says no" && exit 1
fi