Skip to content

Instantly share code, notes, and snippets.

@pestophagous
Created October 14, 2015 20:14
Show Gist options
  • Save pestophagous/58345ab1334c157a08bc to your computer and use it in GitHub Desktop.
Save pestophagous/58345ab1334c157a08bc to your computer and use it in GitHub Desktop.
runs on mac. (uses launchctl). hide something, but set a task to auto-restore in 15 minutes. (for atos. could be made more general.)
#!/bin/bash
echo "about to run 'sudo launchtl list', so you might be prompted for sudoer password!"
CHECK_ATRUN=`(sudo launchctl list | grep atrun | wc -l)`
if [ "$CHECK_ATRUN" -ne "1" ]; then
echo ""
echo "Refusing to run the script."
echo ""
echo "We require that the 'atrun' LaunchDaemon be in service."
echo ""
echo "Try to enable it like so:"
echo " sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist"
exit $1;
fi
# You could replace the three items with whatever you need.
# "/usr/bin/fake_atos" is the thing to enable for 15 minutes only.
# "/usr/bin/atos" is the location at which ANY of these items is invoked. (by your compiler, or other process)
# "/usr/bin/REAL_atos" is the ORIGINAL exe to restore after 15 min.
cp /usr/bin/fake_atos /usr/bin/atos
# some mac osx security update made it so you must 'sudo' to run `at`
echo "cp /usr/bin/REAL_atos /usr/bin/atos" | sudo at now + 15 minutes
echo "real exe should be restored in 15 minutes."
echo "to restore it sooner, you can run this:"
echo " cp /usr/bin/REAL_atos /usr/bin/atos"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment