#!/usr/bin/perl ################################################################################# ## Used by Dee Newcum to quickly setup some minimum preferences just after doing ## a fresh install of Linux. (I end up doing this a lot, somehow) ################################################################################# use strict; use warnings; $> == 0 or die "This script requires you to be root.\n"; ## setup the web proxy, if needed my $proxy = detect_desired_proxy(); setup_proxy($proxy) if ($proxy); # returns a hash-ref with the environment variables needed sub detect_desired_proxy { my %env; if (gethostbyname("wwwgate0.mot.com")) { $env{http_proxy} = "http://wwwgate0.mot.com:1080/"; $env{https_proxy} = "http://wwwgate0.mot.com:1080/"; $env{no_proxy} = "mot.com, mot-solutions.com"; } return \%env if %env; } sub setup_proxy { my %env = %{$_[0]}; return if (($ENV{http_proxy} || '') eq $env{http_proxy}); warn "Adding proxy settings to /etc/profile...\n"; open FOUT, ">>/etc/profile" or die $!; print FOUT "\n"; while (my ($var, $val) = each %env) { print FOUT "export $var='$val'\n"; } close FOUT; }