Last active
August 29, 2015 14:04
-
-
Save wangjiezhe/c0541622f3da63534d00 to your computer and use it in GitHub Desktop.
a simple script to change proxy used in yum repo
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
#!/usr/bin/env bash | |
GOAGENT="proxy=http://127.0.0.1:8087" | |
SSLCACERT="sslcacert=/home/wangjiezhe/Downloads/googleappengine/goagent/local/CA.crt" | |
IPV6="proxy=http://pkuproxy.acg.gd:1898" | |
YUM_PATH="/etc/yum.repos.d" | |
error() { | |
echo "Usage: $(basename "$0") goagent|ipv6|none" | |
exit 1 | |
} | |
if [ $# -ne 1 ] | |
then | |
error | |
fi | |
case $1 in | |
goagent) | |
for file in $YUM_PATH/* | |
do | |
sed -i -e "/proxy/s@\(.*\)\($GOAGENT\)\(.*\)@\2@" "$file" | |
sed -i -e "s@\(.*\)\($SSLCACERT\)\(.*\)@\2@" "$file" | |
sed -i -e "/proxy/s@\(.*\)\($IPV6\)\(.*\)@# \2@" "$file" | |
done | |
;; | |
ipv6) | |
for file in $YUM_PATH/* | |
do | |
sed -i -e "/proxy/s@\(.*\)\($GOAGENT\)\(.*\)@# \2@" "$file" | |
sed -i -e "s@\(.*\)\($SSLCACERT\)\(.*\)@# \2@" "$file" | |
sed -i -e "/proxy/s@\(.*\)\($IPV6\)\(.*\)@\2@" "$file" | |
done | |
;; | |
none) | |
for file in $YUM_PATH/* | |
do | |
sed -i -e "/proxy/s@\(.*\)\($GOAGENT\)\(.*\)@# \2@" "$file" | |
sed -i -e "s@\(.*\)\($SSLCACERT\)\(.*\)@# \2@" "$file" | |
sed -i -e "/proxy/s@\(.*\)\($IPV6\)\(.*\)@# \2@" "$file" | |
done | |
;; | |
dev) | |
for file in $YUM_PATH/russianfedora* | |
do | |
sed -i -e "/proxy/s@\(.*\)\($GOAGENT\)\(.*\)@# \2@" "$file" | |
sed -i -e "s@\(.*\)\($SSLCACERT\)\(.*\)@# \2@" "$file" | |
sed -i -e "s@^mirrorlist.*@#&@" "$file" | |
sed -i -e "s@\(.*\)\(baseurl=.*\)\(/releases\)\(.*\)\(/Everything\)\(.*\)@\2/development\4\6@" "$file" | |
done | |
;; | |
*) | |
error | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment