2

I am connecting from my BeagleBone running Debian to a cellular modem.

In order to connect, I enter command pppd file /etc/ppp/peers/zdial &

Now, in order to execute this command on boot-up, I created a script start-ppp.sh which runs this command as below.

I then create and enable a service ppp-connect.service as below. sudo systemctl enable ppp-connect.

I would expect this service to run on boot-up and automatically connect to my modem but it doesn't work.

However, If I manually start the service with sudo systemctl start ppp-connect , then my service starts and I can connect to the modem.

Why is it that it does not connect on boot-up automatically? Can anyone see something obvious that I am doing wrong. Perhaps it's something to do with not entering the password for sudo during boot-up. I'm not sure.

start-ppp.sh

#!/bin/sh -e

sudo -H -u debian pppd file /etc/ppp/ppers/zdial &

ppp-connect.service

[Unit]
Description=ppp_service
ConditionPathExists=/dev/ttyACM0

[Service]
Type=forking
ExecStart=/bin/sh /home/debian/start-ppp.sh
Restart=always
RestartSec=60

[Install]
WantedBy=multi-user.target
Engineer999
  • 1,151
  • 1
    Certainly there's no need to background the call, and presumably systemd is starting the unit as root, so those are easy changes -- User=debian in the [Service] section. Presumably the script is executable by that user, so there's also no need to use /bin/sh to call it. Beyond that, all the script is doing is executing ppd, so why not just make that the ExecStart? – Jeff Schaller Jan 29 '19 at 19:35
  • 1
    The interesting part will be why systemd didn't or couldn't do what you wanted; is there anything in journalctl -u ppp_service? – Jeff Schaller Jan 29 '19 at 19:46
  • Please post the output of systemctl status ppp-connect.service after boot, that should help us diagnose the problem. And also, as @JeffSchaller pointed out, please look at journalctl -u ppp-connect.service (he used ppp_service which is incorrect, the argument should match the filename, not the Description=...) – filbranden Jan 30 '19 at 04:45
  • Try adding After=dev-ttyACM0.device to the [Unit] stanza, since it's possible your service is being run before that device is up and that's causing it to fail (due to the ConditionPathExists= constraint.) – filbranden Jan 30 '19 at 04:50
  • @filbranden Thanks for your suggestions. I will try this when I get back. Meanwhile, if I start my script from rc.local, it works ok. – Engineer999 Jan 30 '19 at 04:51
  • rc.local runs later in boot (through After=network.target), so it's possible /dev/ttyACM0 is already available at that point. I don't think it's a problem with sudo, otherwise the problem would exist when you launch it manually with systemctl as well. – filbranden Jan 30 '19 at 04:57
  • @filbranden The only way I got this working using rc.local was by putting command /bin/sh /home/debian/start-ppp.sh without sudo. What didn't work for me however, was If I put sudo before that command in rc.local . This part I can't understand. Any idea why that is, that it doesn't work with sudo? Sorry if it's diverging from the main topic of the first question – Engineer999 Jan 30 '19 at 05:09
  • @Engineer999 Typically sudo won't need a password when you run it as root (which is the case for a systemd service or rc.local) but it's possible it needs a tty to run (see https://unix.stackexchange.com/a/122624/281844 for more details.) But if systemctl start ppp-connect.service works after the system is up and when the service is using sudo, then it suggests sudo is working some of the time, which suggests "requiretty" is not really the problem... Please post systemctl status ppp-connect.service output, that should help most in troubleshooting this. – filbranden Jan 30 '19 at 05:45

0 Answers0