Jan 2, 2015

Running noipupdater.sh as service on MacOS

This entry is the corresponding one to the adaption of the noipupdate.sh Script, where the necessary changes for MacOS bash are filed. In order to regularly execute a shell script, Apple uses a launch daemon. All services have a corresponding plist file on the Mac, where the launch daemon gets to know what to do with the script and when to execute it. Most of this is nicely written down here (http://alvinalexander.com/mac-os-x/mac-osx-startup-crontab-launchd-jobs, so I will just paste the plist file I created for noipupdater.sh as an example. In my case I stored it in /Library/LaunchDaemons/ (you have to be root to do this) as org.yournamegoeshere.noipupdater.plist (so that it is run by root whether I'm logged in or not) and run it every 20 minutes, which for my purposes is by far often enough. Doesn't use ot of resources, is fast, and way better than most of the clients you can get. I've stored the noipupdater script in
/usr/local/scripts/noipupdate/noipupdater.sh
This is the plist file (stored in /Library/LaunchDaemons/)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.yournamegoeshere.noipupdater seconds</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/scripts/noipupdate/noipupdater.sh</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>1200</integer>
</dict>
</plist>

No comments: