Last active
May 17, 2021 08:47
-
-
Save alexbonhomme/6923495 to your computer and use it in GitHub Desktop.
Ce script permet d'activer/désactiver le proxy de Lille 1 dans l'env (.bashrc) et sur les applications suivantes : Git, Maven, Network Manager, Eclipse. !! Attention !! Vous devez avoir configuré le proxy sur vos applications au préalable. Ce script n'est qu'un simple 'toggle'. Vous devez aussi éditer les variables de configurations si vous n'ut…
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/sh | |
USER=alex # <--- Put your username here | |
SSID=LILLE1 | |
INTERFACE=$1 | |
STATUS=$2 | |
case $INTERFACE in | |
wlan0) | |
case $STATUS in | |
up) | |
if [[ ! -z $(/bin/su $USER -c "iwlist wlan0 scanning | grep $SSID") ]] | |
then | |
echo "Proxy enable." | |
/bin/su $USER -c "/home/$USER/Scripts/proxy-lille1 on" | |
fi | |
;; | |
down) | |
if [[ "'none'" != $(/bin/su $USER -c "gsettings get org.gnome.system.proxy mode") ]] | |
then | |
/bin/su $USER -c "/home/$USER/Scripts/proxy-lille1 off" | |
echo "Proxy disabled." | |
fi | |
;; | |
esac | |
;; | |
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
#!/bin/sh | |
#---------------------------- | |
# | |
# Author : Alexandre Bonhomme | |
# Last update : 5/11/2013 | |
# | |
#---------------------------- | |
### Configuration ### | |
# Network Manager (by default in Gnome) | |
# | |
nm_active=true | |
# Env | |
# | |
env_config="$HOME/.bashrc" | |
# Git | |
# | |
git_config="$HOME/.gitconfig" | |
# SVN | |
# | |
svn_config="$HOME/.subversion/servers" | |
# Maven | |
# | |
mvn_config="$HOME/.m2/settings.xml" | |
# Eclipse | |
# Version number of your installation | |
# | |
eclipse_version="4.3.0" # /!\ <--- TO CONFIGURE /!\ | |
# Android SDK | |
# | |
android_config="$HOME/.android/androidtool.cfg" | |
###################### | |
# | |
eclipse_config="$HOME/.eclipse/org.eclipse.platform_$eclipse_version*/configuration/.settings/org.eclipse.core.net.prefs" | |
if [[ $1 = "on" ]]; then | |
# Network Manager | |
if $nm_active ; then | |
dbus-launch --exit-with-session gsettings set org.gnome.system.proxy mode auto | |
fi | |
# Env | |
sed -i -e 's/^#\(export\ .*_proxy\)/\1/' $env_config | |
# Git | |
sed -i -e 's/^#\(\[https*\]\)/\1/; s/^#\(\t*proxy\)/\1/' $git_config | |
# SVN | |
sed -i -e 's/^#\(http-proxy-host\)/\1/; s/^#\(http-proxy-port\)/\1/' $svn_config | |
# Maven | |
# Need this structure : | |
# <proxy> | |
# <active...</active> | |
# ... | |
# </proxy> | |
sed -i '/<proxy>/{n; s/false/true/}' $mvn_config | |
# Eclipse | |
sed -i '/proxiesEnabled/{s/false/true/}' $eclipse_config | |
# SDK Android | |
sed -i -e 's/^#\(http.proxy*\)/\1/' $android_config | |
elif [[ $1 = "off" ]]; then | |
# Network Manager | |
if $nm_active ; then | |
dbus-launch --exit-with-session gsettings set org.gnome.system.proxy mode none | |
fi | |
# Env | |
sed -i -e 's/\(^export\ .*_proxy\)/#\1/' $env_config | |
unset http_proxy | |
# Git | |
sed -i -e 's/\(^\[https*\]\)/#\1/; s/\(^\t*proxy\)/#\1/' $git_config | |
# SVN | |
sed -i -e 's/\(^http-proxy-host\)/#\1/; s/\(^http-proxy-port\)/#\1/' $svn_config | |
# Maven | |
sed -i '/<proxy>/{n; s/true/false/}' $mvn_config | |
# Eclipse | |
sed -i '/proxiesEnabled/{s/true/false/}' $eclipse_config | |
# SDK Android | |
sed -i -e 's/\(^http.proxy*\)/#\1/' $android_config | |
else | |
echo "Usage : $0 [on|off]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Done. Mais SVN non testé de mon coté.