(→Autostart Devices) |
m (Added owner and group) |
||
Line 8: | Line 8: | ||
As root, copy your custom file to /opt/agocontrol/bin . Change the file permissions so that the file has read and execute permissions : | As root, copy your custom file to /opt/agocontrol/bin . Change the file permissions so that the file has read and execute permissions : | ||
chmod a+rx /opt/agocontrol/bin/agohumidity.py | chmod a+rx /opt/agocontrol/bin/agohumidity.py | ||
+ | |||
+ | Make sure root owns the file: | ||
+ | chown root /opt/agocontrol/bin/agohumidity.py | ||
+ | chgrp root /opt/agocontrol/bin/agohumidity.py | ||
Create a new file in /lib/systemd/system/ called agohumidity.service : | Create a new file in /lib/systemd/system/ called agohumidity.service : |
Here is an example on creating a service to automatically start your custom device driver:
IMPORTANT Your custom file's first line MUST be:
#!/usr/bin/python
As root, copy your custom file to /opt/agocontrol/bin . Change the file permissions so that the file has read and execute permissions :
chmod a+rx /opt/agocontrol/bin/agohumidity.py
Make sure root owns the file:
chown root /opt/agocontrol/bin/agohumidity.py chgrp root /opt/agocontrol/bin/agohumidity.py
Create a new file in /lib/systemd/system/ called agohumidity.service :
[Unit] Description=ago control Weather Device [Service] ExecStart=/opt/agocontrol/bin/agohumidity.py WorkingDirectory=/opt/agocontrol/bin StandardOutput=syslog StandardError=syslog Restart=always RestartSec=2 User=agocontrol [Install] WantedBy=multi-user.target
Change the filename, description and ExecStart to match the needs of your device driver.
Next, enable the service:
systemctl enable agohumidity.service
Then, start the service:
systemctl start agohumidity.service
Finally, ensure that the service is running:
root@debian# systemctl status agohumidity.service agohumidity.service - ago control Weather Device Loaded: loaded (/lib/systemd/system/agohumidity.service; enabled) Active: active (running) since Wed, 31 Dec 1969 18:00:26 -0600; 43 years and 9 months ago Main PID: 361 (python) CGroup: name=systemd:/system/agohumidity.service â 361 python /opt/agocontrol/bin/agohumidity.py
You can temporarily stop the service by using:
systemctl stop agohumidity.service
To permanently disable the service use:
systemctl disable agohumidity.service