0

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.

5
  • 1
    what are you trying to accomplish?
    – Sgaduuw
    Aug 1, 2011 at 11:11
  • Can you try re-wording your question? I can't make out what you are asking.
    – Caleb
    Aug 1, 2011 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.
    – bagavadhar
    Aug 1, 2011 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, 2011 at 11:40
  • Im not sure what you want here, but cron @reboot feature may help you. Aug 1, 2011 at 19:18

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .