Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
18.7 Legacy Series
»
[SOLVED] Autostart a script after WAN connection is up
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Autostart a script after WAN connection is up (Read 4631 times)
ktk
Newbie
Posts: 13
Karma: 3
[SOLVED] Autostart a script after WAN connection is up
«
on:
November 10, 2018, 09:34:11 am »
I have a machine in a mobile carrier network with a private IP as WAN address. To be able to remotely connect to the machine I use autossh, which seems to work fine. I've created the following
/usr/local/etc/rc.autossh
script:
#!/bin/sh
autossh -M 19984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /root/.ssh/id_rsa -R 24385:localhost:22 remote-ip.somewhere.org -l remoteuser &
For starting it I did:
cat /etc/rc.conf.d/autossh
autossh_enable="YES"
When I reboot the box, this script does not seem to be up. Did I miss something or might this be because there is no default gw yet at the stage where it gets triggered?
If so, is there any way I can let the script get executed once I have a WAN IP & GW?
«
Last Edit: November 10, 2018, 10:59:38 am by ktk
»
Logged
franco
Administrator
Hero Member
Posts: 17660
Karma: 1611
Re: Autostart a script after WAN connection is up
«
Reply #1 on:
November 10, 2018, 09:46:13 am »
autossh_enable="YES" should do the trick if it's the correct rc.conf variable.
Otherwise call you script via rc.syshook "start":
https://docs.opnsense.org/development/backend/autorun.html
I think there is an autossh plugin coming soon.
Cheers,
Franco
Logged
ktk
Newbie
Posts: 13
Karma: 3
Re: Autostart a script after WAN connection is up
«
Reply #2 on:
November 10, 2018, 10:41:59 am »
thanks, I just assumed it's the variable I would have to take, or are they "registered" somewhere? My guess was it has to be named like the rc-script I created.
"start" looks great, will check that out thanks
Logged
ktk
Newbie
Posts: 13
Karma: 3
Re: [SOLVED] Autostart a script after WAN connection is up
«
Reply #3 on:
November 10, 2018, 11:00:01 am »
The "start" script works great, thanks @franco!
Logged
franco
Administrator
Hero Member
Posts: 17660
Karma: 1611
Re: [SOLVED] Autostart a script after WAN connection is up
«
Reply #4 on:
November 10, 2018, 11:22:55 am »
Yay, cool. I double-checked the FreeBSD port:
It does not ship an rc.d script so autossh_enable="YES" is never read and acted upon.
Cheers,
Franco
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
18.7 Legacy Series
»
[SOLVED] Autostart a script after WAN connection is up