Skip to content

Instantly share code, notes, and snippets.

@alvarow
Created September 28, 2016 00:01
Show Gist options
  • Save alvarow/26e5d85b7f3256daeb6c386b6dd6fc25 to your computer and use it in GitHub Desktop.
Save alvarow/26e5d85b7f3256daeb6c386b6dd6fc25 to your computer and use it in GitHub Desktop.
Launchd task to run a shell script on macOS boot up. It can be used to add things such as extra IP addresses, etc.
<?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>Label</key>
<string>regulya.local</string>
<key>Program</key>
<string>/Users/regulya/bin/boot-up-actions.sh</string>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>StandardOutPath</key>
<string>/dev/null</string>
</dict>
</plist>
@alvarow
Copy link
Author

alvarow commented Sep 28, 2016

Here's a sample shell script that adds 2 IP addresses to the loopback interface:

#!/bin/sh

# This script runs as root on boot - careful

if [ "$UID" != "0" ]; then
        echo "You need to be root to run the script"
        exit 1
fi

/sbin/ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.0
/sbin/ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment