Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.