forked from cmlsharp/bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ref
executable file
·34 lines (31 loc) · 1.35 KB
/
ref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
#
# Written by: crossroads1112
# Purpose: This is a bash wrapper to the reflector python script/library. It prompts the user for his/her country code and substitutes that into the reflector command.
# It also has the option to change the default country.
#
#
#########################################
country='US'
conffile=~/.config/refrc
[[ ! -f $conffile ]] && echo "country='${country}'" > $conffile
source $conffile
echo "Your usual country code is $(tput bold)'${country}'$(tput sgr0)"
echo -n "Would you like to use this country? [Y/n] "
read answer
case $answer in
""|[Yy]|[Yy][Ee][Ss]) sudo reflector --verbose --country=$country -l 20 -p http --sort rate --save /etc/pacman.d/mirrorlist ;;
[Nn]|[Nn][Oo]) reflector --list-countries | sed 's/[0-9]//g' #Leave only country code and country name
echo -e "\nWhat is the two digit country code of your current country?"
printf " Country code: "
read country
country="${country^^}" #Make all input upper case
sudo reflector --verbose --country=$country -l 20 -p http --sort rate --save /etc/pacman.d/mirrorlist
echo -n "Would you like to make this your default country? [y/N] "
read answer
case $answer in
[Yy]|[Yy][Ee][Ss]) echo "country='${country}'" > $conffile
;;
esac
;;
esac