Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'AutoMount shares based on wireless network' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
AutoMount shares based on wireless network
Authored by: foilpan on Mar 29, '06 09:36:00AM

shouldn't you use launchd for this under 10.4.x?



[ Reply to This | # ]
AutoMount shares based on wireless network
Authored by: TheCrunge on Mar 29, '06 09:51:42AM
You can actually get a script to run when certain elements of the network stack change. For example, if the IPv4 changes, the default interface, the location, and so on. For this purpose, I'll show the location change:

Add dict entry to /System -> Library -> SystemConfiguration -> Kicker.bundle -> Contents -> Resources -> Kicker.xml:
<dict> 
      <key>execCommand</key> 
      <string>/path/to/script.sh</string> 
      <key>execUID</key> 
      <integer>0</integer> 
      <key>keys</key> 
      <array> 
         <string>Setup:/</string>  
      </array> 
      <key>name</key> 
      <string>Label_Here</string> 
   </dict>
The specific item is in the array (Setup:/ is for the network location). For example you can add any or all of these items to get the script to run based on the item that changes:
<dict> 
      <key>execCommand</key> 
      <string>/path/to/script.sh</string> 
      <key>execUID</key> 
      <integer>0</integer> 
      <key>keys</key> 
      <array> 
         <string>Setup:/</string> 
         <string>State:/Network/Interface/en0/Link</string> 
         <string>State:/Network/Interface/en1/Link</string> 
         <string>State:/Network/Global/DNS</string> 
         <string>State:/Network/Global/IPv4</string> 
         <string>State:/Network/Global/IPv6</string> 
         <string>State:/Network/Global/NetInfo</string> 
      </array> 
      <key>name</key> 
      <string>Test</string> 
   </dict>
Just remember that if any part of the script fails, kicker will disable it. You'll need to restart (or HUP configd).

[ Reply to This | # ]