Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Systemd Scripts Not working at boot time
New on LowEndTalk? Please Register and read our Community Rules.

Systemd Scripts Not working at boot time

noamannoaman Member
edited June 2017 in Help

Hello

I have two scripts that I want to run on my orangepi

SSH Tunnel

https://paste2.org/91V3tnON

OPENVPN

https://paste2.org/wIOy9JV3

I want to start these at the boot time...

Now after reboot to test

systemctl status sshtunnel.service

gives me failure

and

netstat -tulnp | grep ssh

shows the tunnel is not up

Now without changing anything

systemctl start sshtunnel.service

netstat -tulnp | grep ssh

shows the tunnel is up

which is weird IMO

The problem is same with the openvpn

It simply doesnt work at boot time

systemctl status openvpn-germany.service DEAD

systemctl start openvpn-germany.service

systemctl status openvpn-germany.service ACTIVE

Thanx in advance

Comments

  • MasonRMasonR Member

    Under [Unit], instead of "network.target" try "network-online.target"

    HTTP/1.1 301 Moved Permanently

  • bsdguybsdguy Member

    Isn't not-working and generally creating a clusterfuck the very raison d'etre and normal state of systemd infected systems?

    My favourite prime number is 42. - \forall cpu in {intel, amd, arm}: cpu->speed -= cpu->speed/100 x irandom(15, 30) | state := hacked

  • noamannoaman Member

    @MasonR said:
    Under [Unit], instead of "network.target" try "network-online.target"

    Worked like a charm

    Still There is one issue left

    if modem and orangepi are rebooted

    The orangepi tries to setup an ssh tunnel even if the ISP modem is not up....

    no internet so it fails...

  • MasonRMasonR Member

    @noaman said:

    @MasonR said:
    Under [Unit], instead of "network.target" try "network-online.target"

    Worked like a charm

    Still There is one issue left

    if modem and orangepi are rebooted

    The orangepi tries to setup an ssh tunnel even if the ISP modem is not up....

    no internet so it fails...

    Cool beans

    In that case I'd probably suggest to move your ssh tunnel setup to a script and at the beginning of the script write a loop that pings your modem IP and only run the tunnel setup command after a successful reply. Or similarly grep the output of ifconfig for an IP in a loop, sleeping every x seconds, until the IP is given. Then just call this script in your ExecStart in your service config instead of running the ssh tunnel command directly.

    HTTP/1.1 301 Moved Permanently

  • @noaman said:

    @MasonR said:
    Under [Unit], instead of "network.target" try "network-online.target"

    Worked like a charm

    Still There is one issue left

    if modem and orangepi are rebooted

    The orangepi tries to setup an ssh tunnel even if the ISP modem is not up....

    no internet so it fails...

    not answering your question directly, if you had openvpn why you need to setup SSH tunnel? Why don't connect to your openvpn server and connect to your orange pi from there?

    I use same setup with you, but without ssh tunnel.

    We only support unsupported OS!

  • noamannoaman Member

    @sibaper said:

    @noaman said:

    @MasonR said:
    Under [Unit], instead of "network.target" try "network-online.target"

    Worked like a charm

    Still There is one issue left

    if modem and orangepi are rebooted

    The orangepi tries to setup an ssh tunnel even if the ISP modem is not up....

    no internet so it fails...

    not answering your question directly, if you had openvpn why you need to setup SSH tunnel? Why don't connect to your openvpn server and connect to your orange pi from there?

    I use same setup with you, but without ssh tunnel.

    BOTH were not working at startup .....:-)

    Now the ssh tunnel systemd is up and running ....

  • noamannoaman Member

    @MasonR said:

    @noaman said:

    @MasonR said:
    Under [Unit], instead of "network.target" try "network-online.target"

    Worked like a charm

    Still There is one issue left

    if modem and orangepi are rebooted

    The orangepi tries to setup an ssh tunnel even if the ISP modem is not up....

    no internet so it fails...

    Cool beans

    In that case I'd probably suggest to move your ssh tunnel setup to a script and at the beginning of the script write a loop that pings your modem IP and only run the tunnel setup command after a successful reply. Or similarly grep the output of ifconfig for an IP in a loop, sleeping every x seconds, until the IP is given. Then just call this script in your ExecStart in your service config instead of running the ssh tunnel command directly.

    well i could directly do curl google.com or host google.com a much better way to determine internet connectivity

    and make that systemd script and add in each Requires/Wants section of the systemd scripts

    They wont fire until the internet is up :-)

Sign In or Register to comment.