In linux (ubuntu), is it possible to execute a script on any incoming network connection?
For a long period of inactivity on my home server, I plan to stop the software raid, park data disks, and restart the RAID array when it encounters an incoming network connection.
I am studying this problem and have not yet found a suitable solution, any help is appreciated.
Neil
Note. I know that it is imperceptible to stop / start the array, and there are drawbacks (disk wear, etc.). However, I am configured on my own paths, please do not send messages so that I do not stop / start disks.
Edit (1):
I thought I would share my opinion and, I hope, would get some feedback from him.
I think I will need to use the xinetd binding of the script catcher, which catches incoming connection data on all ports, starts my script launch and passes the incoming connection data to the appropriate service for this port. The only problem is I don’t know what data I will need to catch or like in python.
Edit (2):
I hacked the solution using the python pypcap library http://code.google.com/p/pypcap/ . For future reference, here is the code.
import pcap
...
pc = pcap.pcap(name)
pc.setfilter(' '.join(args))
pc.setnonblock()
try:
for ts, pkt in pc:
print 'readying disks...'
break
except OSError, ValueError:
print 'Error: invalid arguements passed to subprocess'
except KeyboardInterrupt:
print 'Error: keyboard interupt'
anon.
source
share