Last active
September 2, 2021 01:52
-
-
Save empireshades/6fc526c5c4e75eaad39599468d9f2ea6 to your computer and use it in GitHub Desktop.
Block access to google for younger kid when logged in on mac but make sure it works for everyone else. Run on root's crontab every minute and make sure common_hosts contains what you want as baseline hosts file.
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
cd "${0%/*}" | |
# Check which user is logged in | |
user=$(stat -f '%Su' /dev/console) | |
# Check if hosts file contains 'google' | |
if $(grep -q google /etc/hosts);then | |
GOOGLE=true | |
else | |
GOOGLE=false | |
fi | |
# Add google if it doesn't exist and user is Kylie | |
if [ $user == "bobby" ] && ! $GOOGLE; then | |
cat common_hosts > /etc/hosts | |
cat >> /etc/hosts << EOF | |
127.0.0.1 google.com www.google.com | |
EOF | |
# Else, clear it out | |
elif [ $user != "bobby" ] && $GOOGLE; then | |
cat common_hosts > /etc/hosts | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment