Last active
September 19, 2019 08:55
-
-
Save IanSavchenko/6734cb4ac8422399e60f34d7a68ccd44 to your computer and use it in GitHub Desktop.
Add an alias for loopback interface on startup of MacOS for https://github.com/otm/limes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script adds an alias for loopback interface on start of MacOS X. | |
# This is needed in order for https://github.com/otm/limes to work properly. | |
# | |
# Inspired by | |
# https://apple.stackexchange.com/questions/311188/running-a-sudo-command-on-startup | |
# | |
# USAGE (with local cloned version): | |
# sudo bash add_lo0_alias.sh | |
# | |
# USAGE (without cloning - ALWAYS VERIFY WHAT YOU RUN BEFORE YOU RUN IT): | |
# sudo bash -c "$(curl -fsSL https://gist.githubusercontent.com/IanSavchenko/6734cb4ac8422399e60f34d7a68ccd44/raw/add_lo0_alias.sh)" | |
# | |
# Written by Ian Savchenko in 2019 (iansavchenko.com) | |
set -euo pipefail | |
DAEMON_NAME=org.limes.ifconfig | |
DAEMON_FILE_NAME=${DAEMON_NAME}.plist | |
DAEMON_FILE_PATH=/Library/LaunchDaemons/${DAEMON_FILE_NAME} | |
touch ${DAEMON_FILE_PATH} | |
chown root:wheel ${DAEMON_FILE_PATH} | |
cat > ${DAEMON_FILE_PATH} <<- EOM | |
<?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>${DAEMON_NAME}</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>StandardErrorPath</key> | |
<string>/tmp/${DAEMON_NAME}.err</string> | |
<key>StandardOutPath</key> | |
<string>/tmp/${DAEMON_NAME}.out</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/sbin/ifconfig</string> | |
<string>lo0</string> | |
<string>alias</string> | |
<string>169.254.169.254</string> | |
</array> | |
</dict> | |
</plist> | |
EOM | |
echo Created ${DAEMON_FILE_PATH}! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment