-
-
Save haipham/03912a6884176a413184 to your computer and use it in GitHub Desktop.
This file contains 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 | |
if [ ! $(whoami) = 'root' ]; then | |
echo "This script should be run as root." > /dev/stderr | |
exit 1 | |
fi | |
spinner() | |
{ | |
local pid=$! | |
local delay=0.75 | |
local spinstr='|/-\' | |
local text=$1 | |
local count=0 | |
echo -ne "$text " | |
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | |
local temp=${spinstr#?} | |
printf "[%c]" "$spinstr" | |
local spinstr=$temp${spinstr%"$temp"} | |
sleep $delay | |
printf "\b\b\b" | |
done | |
echo -ne "\b\b\b\n" | |
} | |
case "$1" in | |
install) | |
(cp ./mDNSResponder /usr/sbin/ && cp ./mDNSResponderHelper /usr/sbin/ && cp ./com.apple.mDNSResponder.plist /System/Library/LaunchDaemons/ && cp ./com.apple.mDNSResponderHelper.plist /System/Library/LaunchDaemons/) > /dev/null 2>&1 & spinner "copying required files" | |
(launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist && launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd_helper.plist) > /dev/null 2>&1 & spinner "deactivating discoveryd" | |
(launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist && launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponderHelper.plist) > /dev/null 2>&1 & spinner "activating mDNSResponder" | |
echo -e "Please reboot your machine" | |
;; | |
remove) | |
(launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist && launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponderHelper.plist) > /dev/null 2>&1 & spinner "deactivating mDNSResponder" | |
(launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist && launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd_helper.plist) > /dev/null 2>&1 & spinner "activating discoveryd" | |
(rm -rf /usr/sbin/mDNSResponder && rm -rf /usr/sbin/mDNSResponderHelper && rm -rf /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist && rm -rf /System/Library/LaunchDaemons/com.apple.mDNSResponderHelper.plist) > /dev/null 2>&1 & spinner "removing unnecessary files" | |
echo -e "Please reboot your machine" | |
;; | |
*) | |
echo -e "Usage: mdnsresponder.sh {install|remove}" | |
exit 1 | |
;; | |
esac |
This file contains 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
Usage: | |
1. Download and unzip the archive from https://copy.com/DKXr6KxqL1LrFkpA into the same directory as the attached shell script | |
2. chmod +x ./mdnsresponder.sh | |
3. sudo ./mdnsresponder.sh install | |
4. reboot your machine | |
To switch back to discoverd: | |
1. sudo ./mdnsresponder.sh remove | |
2. reboot your machine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment