mirror of
https://github.com/armbian/config.git
synced 2026-01-06 09:53:35 -08:00
Add submodule to select APT mirror from URL (#135)
* Add submodule to select APT mirror from URL * Add stock Armbian mirror, other minor edits * Allow direct call of personal submenu items from CLI * Allow selection of mirror region or individual mirrors
This commit is contained in:
@@ -1617,6 +1617,40 @@ function jobs ()
|
||||
echo "Device tree modifications finished!"
|
||||
;;
|
||||
|
||||
"Mirrors")
|
||||
|
||||
# Default automated mirror
|
||||
url="http://apt.armbian.com"
|
||||
LIST=( "0" "Automated" )
|
||||
mirrors=( "${url}" )
|
||||
|
||||
# Mirrors for each region
|
||||
for region in $(wget -qO- "${url}/regions" | jq -r '.[]' | sort | grep -v default); do
|
||||
LIST+=( "${#mirrors[@]}" "Region ${region}" )
|
||||
mirrors+=( "${url}/region/${region}/" )
|
||||
done
|
||||
|
||||
# Individual mirrors
|
||||
for mirror in $(wget -qO- "${url}/mirrors" | jq -r '.[] | .[]' | sort | uniq); do
|
||||
LIST+=( "${#mirrors[@]}" "${mirror}" )
|
||||
mirrors+=( "${mirror}" )
|
||||
done
|
||||
|
||||
exec 3>&1
|
||||
selection=$(dialog --colors --backtitle "${BACKTITLE}" --title " Select APT mirror " --clear --menu "Select mirror" 0 0 10 "${LIST[@]}" 2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
clear
|
||||
|
||||
if [ $exit_status -eq 0 ]; then
|
||||
# Reconfigure apt
|
||||
codename=$(lsb_release -sc)
|
||||
mirror=${mirrors[$selection]}
|
||||
echo "deb ${mirror} ${codename} main ${codename}-utils ${codename}-desktop" > /etc/apt/sources.list.d/armbian.list
|
||||
apt-get update
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
|
||||
@@ -319,18 +319,21 @@ while true; do
|
||||
LIST+=( "Keyboard" "Change console keyboard layout (\Z5$(cat /etc/default/keyboard | grep XKBLAYOUT | grep -o '".*"' | sed 's/"//g')\Z0)")
|
||||
LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" )
|
||||
LIST+=( "Welcome" "Toggle welcome screen items" )
|
||||
LIST+=( "Mirrors" "Reconfigure APT mirrors" )
|
||||
|
||||
# count number of menu items to adjust window sizee
|
||||
LISTLENGTH="$((6+${#LIST[@]}/2))"
|
||||
BOXLENGTH=${#LIST[@]}
|
||||
|
||||
exec 3>&1
|
||||
selection=$(dialog --colors --backtitle "$BACKTITLE" --title "Personal settings" --clear \
|
||||
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
|
||||
"${LIST[@]}" 2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
|
||||
if [[ -z $selection ]]; then
|
||||
exec 3>&1
|
||||
selection=$(dialog --colors --backtitle "$BACKTITLE" --title "Personal settings" --clear \
|
||||
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
|
||||
"${LIST[@]}" 2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
|
||||
fi
|
||||
|
||||
# run main function
|
||||
jobs "$selection"
|
||||
|
||||
Reference in New Issue
Block a user