OS X tips: Restarting sendmail after changing network
Wednesday, July 23rd, 2003平常我都是用自己的 Laptop 上用 sendmail 做送 email 的工作。不過每次換了網路就得重新開始 sendmail,有點煩。找了一下,發現 OS X 中 configd 可以設定在某些系統事件發生後去執行一定的檔案。設定檔是在 /System/Library/SystemConfiguration/Kicker.bundle/Resources/中的Kicker.xml。如果在其中加入下面一段,
<dict>
<key>name</key>
<string>resendmail</string>
<key>keys</key>
<array>
<string>File:/var/run/nibindd.pid</string>
</array>
<key>execUID</key>
<integer>0</integer>
<key>execCommand</key>
<string>/usr/local/bin/resendmail.sh</string>
</dict>
就可在重設網路後,執行 resendmail.sh :
#!/bin/sh sleep 20 #avoid to start two sendmail at boot up /System/Library/StartupItems/Sendmail/Sendmail restart
如此一來就能在換網路得到新的 IP 後重設 sendmail,不需要等到信送不出去後在手動執行。 configd 的應用應該很廣,例如 重設 samba ,或是重設動態 DNS 等等。
備忘:configd 相關的設定可以用 scutil 來查詢 (scutil -> open -> list)。

