Last active
December 1, 2015 05:09
-
-
Save chew-z/ae8f17ead0211b032f69 to your computer and use it in GitHub Desktop.
connected.sh
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 | |
# It is complicated - not my fault. It's Apple implementing changes in launchctl on 10.10, 10.11 | |
# This script restarts Polipo service (as user not root) after connectiong to VPN via Tunnelblick | |
# The reason for this restart is that when on Public WiFi connections are blocked by LittleSnitch (firewall) | |
# Polipo goes crazy waiting for all these connections that disappeared in a black hole | |
# 'Couldn't establish listening socket: Too many open files' | |
# So it is better to start clean after getting VPN connection and I am too lazy to do that from commandline. | |
# Some explanations of why all this is necessary | |
# http://apple.stackexchange.com/questions/195445/ | |
# http://apple.stackexchange.com/questions/159532/ | |
# experimenting and Google did the rest. | |
id=$(ps aux | grep -v grep | grep polipo | awk {'print $2'}) | |
pid_uid=$(ps -axo pid,uid,args | grep -i "[l]oginwindow.app" | awk '{print $1 "," $2}') | |
uid=$(echo $pid_uid | cut -d, -f2) | |
sudo launchctl bsexec $id launchctl unload /Users/rrj/Library/LaunchAgents/homebrew.mxcl.polipo.plist | |
launchctl bootstrap gui/$uid /Users/rrj/Library/LaunchAgents/homebrew.mxcl.polipo.plist | |
# exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment