LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2012, 02:01 PM   #1
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
How To Toggle Proxy


Under Firefox

Edit --> Preferences --> Network (tab) Connection Settings I find I have to toggle whether I use our proxy or not. One of the times I do is when using Leiningen to fetch a new version of itself. It won't work with the proxy off.

Rather than going into Firefox to do this, what network settings do I need to tweak using a shell script and in which files are these?

Thanks.
 
Old 04-04-2012, 02:43 PM   #2
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
Hi

look for the Firefox Add-on "FoxyProxy". This should allow you to handle your Proxy Setup depending with just a few clicks, I think even depending on IP addresses or networks.
 
Old 04-05-2012, 11:18 AM   #3
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Original Poster
Rep: Reputation: 35
Need Network Config Files

Quote:
Originally Posted by sys64738 View Post
Hi

look for the Firefox Add-on "FoxyProxy". This should allow you to handle your Proxy Setup depending with just a few clicks, I think even depending on IP addresses or networks.
Thank you for your reply, but I am looking to control this using a shell script.
 
Old 04-05-2012, 12:47 PM   #4
NyteOwl
Member
 
Registered: Aug 2008
Location: Nova Scotia, Canada
Distribution: Slackware, OpenBSD, others periodically
Posts: 512

Rep: Reputation: 139Reputation: 139
You can do it by maniputing the pref.js file where the settings are stored. Sample code:

Code:
#!/bin/bash
version="`firefox -v | awk '{print substr($3,1,3)}'`"
echo $version " is the version."
# Insert an ip into firefox for the proxy if there isn't one
if
! grep network.proxy.http /etc/firefox-$version/pref/firefox.js 
  then echo 'pref("network.proxy.http", "'"$1"'")";' >> /etc/firefox-$version/pref/firefox.js 
fi

# Even if there is change it to what we want
sed -i s/^.*network.proxy.http\".*$/'pref("network.proxy.http", "'"$1"')";'/  /etc/firefox-$version/pref/firefox.js 

# Set the port
if ! grep network.proxy.http_port /etc/firefox-$version/pref/firefox.js 
  then echo 'pref("network.proxy.http_port", 9980);' >> /etc/firefox-$version/pref/firefox.js 
  else sed -i s/^.*network.proxy.http_port.*$/'pref("network.proxy.http_port", 9980);'/ /etc/firefox-$version/pref/firefox.js 
fi

# Turn on the proxy
if ! grep network.proxy.type  /etc/firefox-$version/pref/firefox.js 
  then echo 'pref("network.proxy.type", 1);' >> /etc/firefox-$version/pref/firefox.js 
  else sed -i s/^.*network.proxy.type.*$/'pref("network.proxy.type", 1)";'/ /etc/firefox-$version/pref/firefox.js 
fi
Pehapss an easier, and safer way to do this is to configure your Firefox to use a PAC with a file URL, create fiels for your various settings, and then change the file URL from the line command when (re)starting Firefox.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accidental typeover toggle klarsin Linux - Desktop 2 02-18-2008 03:32 PM
Toggle between Linux & windows ppkamma Linux - Newbie 4 05-31-2006 02:23 PM
Toggle Post Totals On/Off trickykid LQ Suggestions & Feedback 8 03-15-2005 10:22 PM
Anyone toggle between 2.4 and 2.6 kernels much? Proud Mandriva 3 12-30-2004 01:50 PM
how can I toggle different keyboard layouts? kentri9 Linux - Newbie 14 10-09-2004 04:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration