Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to detect the first time networking is run?

I am referring to the very first time after the computer is started up, rather than when it is installed, ie networking has already been configured, but I need a post-up routine to determine that it is the first time of bringing up the network interfaces at boot time, rather than subsequent restarts by an administrator via /etc/init.d/networking or other means.

I am on Ubuntu Hardy.

share|improve this question
1  
what are you trying to accomplish? –  Sgaduuw Aug 1 '11 at 11:11
    
Can you try re-wording your question? I can't make out what you are asking. –  Caleb Aug 1 '11 at 11:15
    
Your question is not clear. What are you trying to find out from first run. i don't see any special significance of first run, that can't undone or redone. –  Naai Sekar Aug 1 '11 at 11:16
    
For the first time it was run on startup. Use "uptime". But if you need to know when the "exactly this" configuration applied, I can't help you... –  HUB Aug 1 '11 at 11:40
    
Im not sure what you want here, but cron @reboot feature may help you. –  Pablo Castellazzi Aug 1 '11 at 19:18
add comment

1 Answer

up vote 1 down vote accepted

I'm not sure what you try to accomplish and it is possible that your goal can be achieved in a simpler way than what you've envisioned.

Anyhow, the simplest idea that I can think of is to add to your shutdown scripts one that does rm /var/lock/net.first. Then add touch /var/lock/net.first to your rc.local.

Then modify your network startup scripts to check for presence of this lock file. If it does not exists, it means, that the network is being brought up between a shutdown and execution of rc.local, which is the last of rc scripts being run at system boot.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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