Here is the content of /etc/network/interfaces
:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
post-up /etc/network/if-up.d/sshstart
And sshstart
is a script with the following in it:
curl something something darkside send a file over ftps in the background &
/usr/bin/autossh -M 0 -f -N -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -R 127.0.0.1:2005:127.0.0.1:22 -R 192.168.1.10:2006:192.168.2.110:1912 -L 127.0.0.1:5249:192.168.1.212:5249 [email protected] -p 8080
When the machine reboots, the curl
command is executed multiple times, the file ends up 2 or 3 times on the ftp server and when I look at the processes it seems like there are multiple instances of autossh running... Not sure if this is how autossh does things or not, but for sure curl shouldn't upload the file multiple times.
My hunch is that the whole sshstart
script is ran multiple times but I don't understand why.
I tried searching for details on the network setup process at boot but all I could find was syntax information for the interfaces file.
Can someone help please?
Thank you.
---Edit---
As suggested bellow I have modified my interfaces file as follow (removed the empty lines above post-up):
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
post-up /etc/network/if-up.d/sshstart
And added the following line to sshstart:
echo $(date)>>/run/shm/sshstart.log
Here is the content of /run/shm/sshstart.log
after a reboot:
Wed Oct 29 08:07:00 EDT 2014
Wed Oct 29 08:07:07 EDT 2014
Wed Oct 29 08:07:07 EDT 2014
Wed Oct 29 08:07:07 EDT 2014
So its been ran 4 times :( what's going on?
echo $(date)
is kinda awkward and indirect. Might as well just spell that asdate
. Similar to Useless Use of Cat Award.