Lines 29-36
Link Here
|
29 |
' |
29 |
' |
30 |
fi |
30 |
fi |
31 |
|
31 |
|
|
|
32 |
while getopts ":ahips:" opt |
33 |
do |
34 |
case $opt in |
35 |
a ) echo "Using automatic mode."; MODE=auto;; |
36 |
i ) echo "Using interactive mode."; MODE=user;; |
37 |
p ) echo "Not changing config files."; NOUPDATE=1;; |
38 |
s ) echo "Selecting $OPTARG servers."; SERVERS=$OPTARG;; |
39 |
h ) ;; |
40 |
* ) echo "Unimplemented option chosen.";; |
41 |
esac |
42 |
done |
43 |
|
32 |
# if auto mode is set run netselect |
44 |
# if auto mode is set run netselect |
33 |
if [ "${1}" = "-a" ] ; then |
45 |
if [ "${MODE}" = "auto" ] ; then |
34 |
echo "Fetching server list from web" |
46 |
echo "Fetching server list from web" |
35 |
# nastiness, but it should work for now |
47 |
# nastiness, but it should work for now |
36 |
MIRROR_LIST=$((echo -e "GET /main/en/mirrors.xml HTTP/0.9\r\n\r\n" 1>&3 & cat 0<&3) 3<> /dev/tcp/gentoo.org/80 | \ |
48 |
MIRROR_LIST=$((echo -e "GET /main/en/mirrors.xml HTTP/0.9\r\n\r\n" 1>&3 & cat 0<&3) 3<> /dev/tcp/gentoo.org/80 | \ |
Lines 42-56
Link Here
|
42 |
CHECKLIST="${CHECKLIST} `echo $i | grep -v "("`" |
54 |
CHECKLIST="${CHECKLIST} `echo $i | grep -v "("`" |
43 |
done |
55 |
done |
44 |
|
56 |
|
45 |
if [ "`echo ${2} | grep -e "^-s[01234567890]"`" ] ; then |
|
|
46 |
SERVERS="${2}" |
47 |
else |
48 |
if [ "${2}" ] ; then |
49 |
echo "${2} is an invalid option" |
50 |
exit |
51 |
fi |
52 |
fi |
53 |
|
54 |
#pick the mirror from list |
57 |
#pick the mirror from list |
55 |
echo "Running netselect on serverlist, this may take a moment" |
58 |
echo "Running netselect on serverlist, this may take a moment" |
56 |
CHOSEN=`netselect $SERVERS ${CHECKLIST} | awk -F" " '{ print $2 }'` |
59 |
CHOSEN=`netselect $SERVERS ${CHECKLIST} | awk -F" " '{ print $2 }'` |
Lines 59-65
Link Here
|
59 |
MIRRORS="${MIRRORS} $i" |
62 |
MIRRORS="${MIRRORS} $i" |
60 |
done |
63 |
done |
61 |
|
64 |
|
62 |
elif [ "${1}" = "-i" ] ; then |
65 |
elif [ "${MODE}" = "user" ] ; then |
63 |
# not auto mode, we'll run dialog based selection tool |
66 |
# not auto mode, we'll run dialog based selection tool |
64 |
# change "mirror (loc)" to "mirror(loc)" for bash loop below |
67 |
# change "mirror (loc)" to "mirror(loc)" for bash loop below |
65 |
MIRROR_LOCS=`echo $MIRROR_LIST | sed -e "s/ (/(/g"` |
68 |
MIRROR_LOCS=`echo $MIRROR_LIST | sed -e "s/ (/(/g"` |
Lines 94-99
Link Here
|
94 |
|
97 |
|
95 |
else |
98 |
else |
96 |
echo "mirrorselect usage (updated):" |
99 |
echo "mirrorselect usage (updated):" |
|
|
100 |
echo "-p : output the selected mirrors to stdout instead of making changes" |
97 |
echo "-i : interactive mode, dialog based and static mirrorlist" |
101 |
echo "-i : interactive mode, dialog based and static mirrorlist" |
98 |
echo "-a (-s<num>) : auto mode, will retrieve live mirror list from web," |
102 |
echo "-a (-s<num>) : auto mode, will retrieve live mirror list from web," |
99 |
echo " run netselect and choose the server(s) with best response times." |
103 |
echo " run netselect and choose the server(s) with best response times." |
Lines 121-126
Link Here
|
121 |
|
125 |
|
122 |
echo "Selected: $MIRRORS" |
126 |
echo "Selected: $MIRRORS" |
123 |
|
127 |
|
|
|
128 |
if [ -n "$NOUPDATE" ] ; then |
129 |
exit 0 |
130 |
fi |
131 |
|
124 |
# adjust settings in make.conf, all in one command to avoid complaints of make.conf being moved |
132 |
# adjust settings in make.conf, all in one command to avoid complaints of make.conf being moved |
125 |
mv /etc/make.conf /etc/make.conf.old && cat /etc/make.conf.old | egrep -e "^[^#]*GENTOO_MIRRORS=[^ \t\n]" -v > /etc/make.conf && \ |
133 |
mv /etc/make.conf /etc/make.conf.old && cat /etc/make.conf.old | egrep -e "^[^#]*GENTOO_MIRRORS=[^ \t\n]" -v > /etc/make.conf && \ |
126 |
echo "GENTOO_MIRRORS=\"$MIRRORS\"" >> /etc/make.conf |
134 |
echo "GENTOO_MIRRORS=\"$MIRRORS\"" >> /etc/make.conf |