Copy and paste the above code into a new Script Editor file, and click the run button. And this should create a new plist file on your Desktop with the example items in it. You can change the example code to set the kind of data type you want to store, and change the name of the keys to whatever label you want to use like this. A shell script and launchd plist for running commands whenever a Mac's network location information is updated. What is included? This is a very basic script for you to start with to create your own actions 'on network change'.
Plist File Mac
Script to generate the plist for Mac OS X 10.7 and higher to maintain a freedns dynamic dns record updated. Once installed, it will ping the freedns service daily as long as the computer can reach the net, whether or not you are logged in as a user on your mac.
freedns_plist_creator
Script To Generate The Plist For Mac Windows 10
#!/usr/bin/env bash |
# Script to generate the plist for Mac OS X 10.7 and higher to maintain a |
# freedns dynamic dns record updated. Once installed, it will ping the |
# freedns service daily as long as the computer can reach the net, |
# whether or not you are logged in as a user on your mac. |
# |
# You need to edit the variables MY_DOMAIN_NAME and MY_TOKEN with the correct |
# values you get from the freedns site |
# |
# Since the plist is stored under /System on your Mac, you must use sudo to |
# run this script |
# |
# It uses reverse domain name notation [2] to store a plist on your mac |
# [2] http://en.wikipedia.org/wiki/Reverse_domain_name_notation |
MY_DOMAIN_NAME=my.test.com |
MY_TOKEN='hthnhn=ddihdt+ddh*idhih' |
#------------------------------------------------------------------------------ |
# The MIT License (MIT) |
# |
# Copyright (c) 2013 Juan C. Mendez (jcmendez@alum.mit.edu) |
# |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
# of this software and associated documentation files (the 'Software'), to deal |
# in the Software without restriction, including without limitation the rights |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
# copies of the Software, and to permit persons to whom the Software is |
# furnished to do so, subject to the following conditions: |
# |
# The above copyright notice and this permission notice shall be included in |
# all copies or substantial portions of the Software. |
# |
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
# THE SOFTWARE. |
#------------------------------------------------------------------------------ |
PLIST_NAME=`echo '$MY_DOMAIN_NAME'| awk 'BEGIN{FS='.';ORS='.'} {for (i = NF; i > 0; i--){print $i}}'` |
cat >'/System/Library/LaunchDaemons/${PLIST_NAME}updater.freedns.plist'<<DOC |
<?xml version='1.0' encoding='UTF-8'?> |
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'> |
<plist version='1.0'> |
<dict> |
<key>KeepAlive</key> |
<false/> |
<key>Label</key> |
<string>${PLIST_NAME}updater</string> |
<key>ProgramArguments</key> |
<array> |
<string>/usr/bin/curl</string> |
<string>http://freedns.afraid.org/dynamic/update.php?$MY_TOKEN</string> |
<string>>/dev/null</string> |
<string>2>&1</string> |
</array> |
<key>StartCalendarInterval</key> |
<dict> |
<key>Hour</key> |
<integer>3</integer> |
<key>Minute</key> |
<integer>0</integer> |
</dict> |
</dict> |
</plist> |
DOC |
Script To Generate The Plist For Mac Os
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment