Last active
April 20, 2016 08:06
-
-
Save ioggstream/ab1c71f7ec358bbf9c66 to your computer and use it in GitHub Desktop.
Switch git url between https and ssh via networkmanager
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 | |
export LANG=C | |
progname=$0 | |
interface=$1 | |
status=$2 | |
case "$status" in | |
up|down|vpn-up|vpn-down) | |
# You may need to wait a bit before the interface is up before | |
# all the proper checks returns true, eg routes, ... | |
sleep 10 | |
# Replace the following check with whatever you need. | |
/bin/nmcli device show wlan0 | grep -q 'GENERAL.CONNECTION:\s+CorporateLan' | |
is_corporate=$? | |
logger -t NetworkManager "Using $progname dispatcher to set git config while running $interface $status. is_corporate: $is_corporate " | |
if [ $is_corporate != 0 ]; then | |
git config --global url."https://example.com/".insteadOf git@example.com: | |
else | |
git config --global --unset url.https://example.com/.insteadof | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment