2

I’m playing around with the hologram Nova cellular USB kit and I’m trying to create an automatic connection using the /etc/rc.local file. Hologram uses it's own way of connecting to a ppp0 network connection and the way to enable or start a connection is through:

sudo hologram network connect

This command runs on the command line without any problem. However it doesn’t seem to ever run on boot up.

For those of you who aren’t familiar with the Nova Hologram you can follow this link

In order to get a ppp0 connection.

So I have tried a rc.local edit just simply adding the command and it just doesn't seem to run... I have also tried running a crontab command (same command after reboot) in order to run. However it just doesn’t seem to run at all...

After running crontab under admin priviledges:

(sudo crontab e-)

I type at the end of the file:

@reboot sudo hologram network connect

Nothing seems to happen when I reboot or power on Raspberry pi.

Anyway, any help would be greatly appreciated!

Thank you kindly

Edit: After creating the unit service for systemd, as suggested by @Ingo Here is the following log result:

Ok Here's the output from the termination error:

pi@BerryPi2:~ $ sudo systemctl status holConn.service
● holConn.service - Hologram Service
   Loaded: loaded (/etc/systemd/system/holConn.service; enabled; vendor 
preset: enabled)
   Active: inactive (dead) since Fri 2019-07-05 00:41:26 EDT; 14s ago
  Process: 1249 ExecStart=/usr/local/bin/hologram network connect 
(code=exited, status=0/SUCCESS)
 Main PID: 1249 (code=exited, status=0/SUCCESS)

Jul 05 00:41:20 BerryPi2 pppd[1256]: Connect: ppp0 <--> /dev/ttyACM0
Jul 05 00:41:24 BerryPi2 pppd[1256]: local  IP address xx.xx.x.x        # -> note I masked the real IP and DNS addresses
Jul 05 00:41:24 BerryPi2 pppd[1256]: remote IP address xx.xx.x.x
Jul 05 00:41:24 BerryPi2 pppd[1256]: primary   DNS address xx.xx.xxx.xxx
Jul 05 00:41:24 BerryPi2 pppd[1256]: secondary DNS address xx.xx.xxx.xxx
Jul 05 00:41:26 BerryPi2 hologram[1249]: PPP session started
Jul 05 00:41:26 BerryPi2 pppd[1256]: Terminating on signal 15
Jul 05 00:41:26 BerryPi2 pppd[1256]: Connect time 0.1 minutes.
Jul 05 00:41:26 BerryPi2 pppd[1256]: Sent 0 bytes, received 0 bytes.
Jul 05 00:41:26 BerryPi2 pppd[1256]: Connection terminated.

2nd Edit:

After the updates to the unit file, including the oneshot and other options suggested by @Ingo, the service stays active but shows status as exited.

pi@BerryPi2:~ $ sudo systemctl status holConn.service
● holConn.service - Hologram Service
   Loaded: loaded (/etc/systemd/system/holConn.service; enabled; vendor 
preset: enabled)
   Active: active (exited) since Fri 2019-07-05 11:55:42 EDT; 2min 19s ago
  Process: 507 ExecStart=/usr/local/bin/hologram network connect 
(code=exited, status=0/SUCCESS)
 Main PID: 507 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/holConn.service

Jul 05 11:55:39 BerryPi2 systemd[1]: Starting Hologram Service...
Jul 05 11:55:42 BerryPi2 sudo[624]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/modprobe option
Jul 05 11:55:42 BerryPi2 sudo[624]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jul 05 11:55:42 BerryPi2 sudo[624]: pam_unix(sudo:session): session closed for user root
Jul 05 11:55:42 BerryPi2 hologram[507]: ERROR: Modem not detected
Jul 05 11:55:42 BerryPi2 systemd[1]: Started Hologram Service.

I'm guessing we have to modify the After option to wait for both network and usb modem to be recognized? is there such an option? I tried putting the idle.target because I read it was basically when the Pi is ready and everything has loaded... but I'm most likely wrong.

4
  • As far as I understand there is an external device called Nova. On the RasPi you use a program named hologram to connect to Nova by ppp. Can you confirm this?
    – Ingo
    Commented Jul 3, 2019 at 8:12
  • yeah, the external device is a 3G usb device and its managed by hologram.io more info can be found at that website (hologram.io)
    – Agustin
    Commented Jul 4, 2019 at 3:25
  • You can edit your question. Please add this information to it.
    – Ingo
    Commented Jul 4, 2019 at 8:27
  • @Ingo, I thought it was all in there, but I have reworded the question, hopefully this is a bit more clear? Thanks!
    – Agustin
    Commented Jul 5, 2019 at 4:27

1 Answer 1

3

Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it.

Instead you should use a systemd Unit file to start your service. With systemd you have many options to make your service run. Your command only runs one time and does not stay in the background as a service. So we have to use oneshot. We have to find the condition that is available on the command line but not early on boot up. First we can try to wait until network-online.target. If it doesn't help we can try to start the command again after a time until it is started. This provides that the command fails without connection but it seems it finishes with (code=exited, status=0/SUCCESS), why? The best is when we know what other service (condition available on command line) is needed so we can start our command After that without only fixing symptoms.

Try this unit file. The possible alternatives I have commented out. You can create the unit with:

rpi ~$ sudo systemctl --full --force edit holConn.service

In the empty editor insert these statements, save them and quit the editor:

[Unit]
Description=Connect Hologram service
After=network-online.target
# After=service needed to be available

[Service]
Type=oneshot
RemainAfterExit=yes
# Restart=on-failure
# RestartSec=5
# TimeoutStartSec=30
ExecStart=/usr/local/bin/hologram network connect

[Install]
WantedBy=multi-user.target

You can edit it again with:

rpi ~$ sudo systemctl --full edit holConn.service

Enable the new service:

rpi ~$ sudo systemctl enable holConn.service

and reboot. Check status with:

rpi ~$ systemctl status holConn.service

It is likely that it doesn't run on the first attempt due to missing conditions. We will look at it then.

Update:
Using the chat we have found that there is an additional condition. A ppp connection on interface ppp0 must be established before starting the service. That was the missing # After=service needed to be available. We can check with sys-subsystem-net-devices-ppp0.device if the interface is up. So the final Unit file looks like this:

[Unit]
Description=Connect Hologram Service
After=network-online.target
After=sys-subsystem-net-devices-ppp0.device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/hologram network connect

[Install]
WantedBy=multi-user.target
11
  • Thank you for your feedback, I’m not very well versed on systemd Unit files, but I can definitely elaborate on my question if you need any more information! Thank you again!
    – Agustin
    Commented Jul 3, 2019 at 0:35
  • @Agustin I have updated the answer.
    – Ingo
    Commented Jul 4, 2019 at 8:44
  • It seems we're in sync, because I found some documentation on doing this, however while the service ran on boot, the log shows it disconnects almost immediately... and if I run the same command on the terminal as myself it runs without a problem... :(
    – Agustin
    Commented Jul 5, 2019 at 4:08
  • Ok, I have updated the question with the log after running the service, thank you!
    – Agustin
    Commented Jul 5, 2019 at 4:45
  • @Agustin I have updated the answer. Please give me feedback.
    – Ingo
    Commented Jul 5, 2019 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.