NickWaterton / Roomba980-Python

Python program and library to control iRobot Roomba 980 Vacuum Cleaner
MIT License
367 stars 103 forks source link

Systemd service script? #79

Closed wojewsky closed 4 years ago

wojewsky commented 4 years ago

First of all: Thank you a lot for your great work! Everything works great.

I've tried to write a systemd script but i've got: Process: 19320 ExecStart=/opt/Roomba980-Python/roomba/start_openhab_roomba.sh (code=exited, status=1/FAILURE) Main PID: 19320 (code=exited, status=1/FAILURE)

This is my script:

[Unit]
Description=Roomba
Documentation=https://github.com/NickWaterton/Roomba980-Python
After=network.target

[Service]
ExecStart=/opt/Roomba980-Python/roomba/start_openhab_roomba.sh
WorkingDirectory=/opt/Roomba980-Python/roomba
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=Roomba
User=username
Group=usergroup

[Install]
WantedBy=multi-user.target

and start_openhab_roomba.sh looks like this: #! /bin/bash ./roomba_direct.py -b localhost -U openhabian -P 9qa1pgou+wif -l ./Roomba.log -M /etc/openhab2/html -s '(1500,1500,0,-600,0,0)' -e 1>/dev/null 2>/dev/null

NickWaterton commented 4 years ago

These things are quite often a permissions problem. Are you sure the user that starts the process has permission to write to /etc/openhab2/html and ./Roomba.log ? because /etc is a protected directory, and ./Roomba.log does not look like a good place to write a log file (it's a relative address).

wojewsky commented 4 years ago

logged in as the defined user i can call start_openhab_roomba.sh without any problems. but i can test to change the map path...

NickWaterton commented 4 years ago

What is the 'defined user'? because 'openhab' does not have a login, so you can't log in as openhab, and that means you can't write to /etc/openhab2/html unless you change the permissions for /etc/openhab2/html or run start_openhab_roomba.sh as root (which is what I do). Same goes for ./Roomba.log - where exactly is that supposed to be logging to? - /var/log/openhab2 would be a good place, but that is also a protected directory...

wojewsky commented 4 years ago

you are absolutly right. it was my mistake. After changing the ./Romba.log to openhabian:openhabian everything works. Thank you a lot.