Commit ec528c81 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Add Armbian mirror changing to menu

parent 0ced67ed
......@@ -803,6 +803,39 @@ function jobs ()
;;
# Change to other mirrors
#
"Mirror" )
IFS=$'\r\n'
GLOBIGNORE='*'
LIST_CONST=3
BEFORE="$(cat /etc/apt/sources.list.d/armbian.list | sed 's/http/\nhttp/g' | grep ^http | sed 's/\(^http[^ <]*\)\(.*\)/\1/g' | sed 's/https\?:\/\///')"
PREFIX="$(echo $BEFORE | cut -f1 -d".")"
AVAL_MIRROR=("${PREFIX}.armbian.com" "${PREFIX}.uk.armbian.com")
local LIST=()
for i in "${AVAL_MIRROR[@]}"
do
DESC=$(description "${i[0]}")
[[ "${i[0]}" != "$BEFORE" ]] && LIST+=( "${i[0]//[[:blank:]]/}" "$DESC" )
done
LIST_LENGHT=$(($LIST_CONST+${#LIST[@]}/2));
if [ "$LIST_LENGHT" -eq 1 ]; then
TARGET_MIRROR=${AVAL_MIRROR[0]}
dialog --backtitle "$BACKTITLE" --title "Please wait" --colors --msgbox "\nThere are no mirrors available!" 7 35
else
exec 3>&1
TARGET_MIRROR=$(dialog --cancel-label "Back" --backtitle "$BACKTITLE" --no-collapse \
--title "Change repository location" --colors --clear --menu "\nfrom \Z1$BEFORE\Z0 to:\n " $((6+${LIST_LENGHT})) 60 15 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?;
exec 3>&-
fi
if [[ $exitstatus == 0 ]]; then
sed -i "s/$BEFORE/$TARGET_MIRROR/" /etc/apt/sources.list.d/armbian.list
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nArmbian package repository was switched to:\n\n\Z1$TARGET_MIRROR\Z0" 9 47
fi
;;
# Toggle welcome screen items
#
......
......@@ -220,6 +220,12 @@ function description
*autoreboot-warn*)
echo "Show warning when reboot is needed"
;;
*uk.armbian.com*)
echo "United Kingdom"
;;
*.armbian.com*)
echo "Estonia"
;;
*)
echo ""
;;
......@@ -694,6 +700,7 @@ while true; do
[[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" )
[[ -f /boot/armbianEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" )
[[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" )
[[ -f /etc/apt/sources.list.d/armbian.list ]] && LIST+=( "Mirror" "Change repository server" )
LIST+=( "Welcome" "Toggle welcome screen items" )
if [[ -z $(apt-mark showhold | grep -w "$BOARD") ]]; then
[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment