0

I need to create a systemd service to start some owfs-daemon automatically.

I can manually start the daemon with sudo /opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/. Then there are folders and files with the different temperatures created in /mnt/1wire. It is not possible to start the owfs-daemon as a normal user.

Now I tried to create some systemd service to start it automatically (see following code).

[Unit]
Description=1-wire service
After=syslog.target
After=network.target

[Service]
Type=simple
ExecStart=/opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

I installed the service and I can also start it by with sudo systemctl start owfs.service. But there are no files created in /mnt/1wire. sudo systemctl status owfs.service shows following output.

● owfs.service - 1-wire service
   Loaded: loaded (/lib/systemd/system/owfs.service; enabled)
   Active: inactive (dead) since Sat 2016-02-27 13:11:13 UTC; 20s ago
  Process: 1025 ExecStart=/usr/local/bin/temperature/owfs.sh (code=exited, status=0/SUCCESS)
 Main PID: 1025 (code=exited, status=0/SUCCESS)

Feb 27 13:11:13 raspberrypi systemd[1]: Started 1-wire service.

I think the service is not started as root user. Wich modifications do need to make in my service file to correctly start the owfs-daemon?

EDIT: Here is the service file which is working with owfs.

[Unit]
Description=1-wire service

[Service]
Type=forking
ExecStart=/opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

1 Answer 1

2

I use the following:

[Unit]
Description=1-wire filesystem FUSE mount
Documentation=man:owfs(1)

[Service]
Type=forking
ExecStart=/usr/bin/owfs -uall --allow_other /run/owfs
ExecStop=/usr/bin/umount /run/owfs
RuntimeDirectory=owfs

The real difference in the Service type: from the Manual:

If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main daemon process. This is the behavior of traditional UNIX daemons. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon. systemd will proceed with starting follow-up units as soon as the parent process exits.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .