2020-03-24 07:14:42 +01:00
|
|
|
#!@TERMUX_PREFIX@/bin/bash
|
|
|
|
|
|
|
|
if [ "$1" == "--help" ] || [ "$1" == "-help" ]; then
|
|
|
|
echo "Script for redirecting subscribed repositories to mirrors."
|
|
|
|
echo "You can choose between mirrors listed at"
|
|
|
|
echo "https://github.com/termux/termux-packages/wiki/Mirrors"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
select_repository() {
|
2021-04-14 16:51:30 +02:00
|
|
|
if [ "$1" == "Default repositories" ]; then
|
|
|
|
echo "[*] Default repositories selected"
|
2021-06-03 00:48:51 +02:00
|
|
|
MAIN="https://packages.termux.org/apt/termux-main"
|
|
|
|
GAME="https://packages.termux.org/apt/termux-games"
|
|
|
|
ROOT="https://packages.termux.org/apt/termux-root"
|
|
|
|
SCIENCE="https://packages.termux.org/apt/termux-science"
|
|
|
|
UNSTABLE="https://packages.termux.org/apt/termux-unstable"
|
|
|
|
X11="https://packages.termux.org/apt/termux-x11"
|
2020-03-24 07:14:42 +01:00
|
|
|
|
2021-06-20 14:54:10 +02:00
|
|
|
elif [ "$1" == "GH Mirrors by Kcubeterm" ]; then
|
|
|
|
echo "[*] GH mirrors selected"
|
|
|
|
MAIN="https://deb.kcubeterm.me/termux-main"
|
|
|
|
GAME="https://deb.kcubeterm.me/termux-games"
|
|
|
|
ROOT="https://deb.kcubeterm.me/termux-root"
|
|
|
|
SCIENCE="https://deb.kcubeterm.me/termux-science"
|
|
|
|
UNSTABLE="https://deb.kcubeterm.me/termux-unstable"
|
|
|
|
X11="https://deb.kcubeterm.me/termux-x11"
|
|
|
|
|
2020-04-19 22:04:55 +02:00
|
|
|
elif [ "$1" == "Mirrors by A1batross" ]; then
|
|
|
|
echo "[*] A1batross's mirrors selected"
|
2021-06-04 16:58:54 +02:00
|
|
|
MAIN="https://termux.mentality.rip/termux-main"
|
|
|
|
GAME="https://termux.mentality.rip/termux-games"
|
|
|
|
ROOT="https://termux.mentality.rip/termux-root"
|
|
|
|
SCIENCE="https://termux.mentality.rip/termux-science"
|
|
|
|
UNSTABLE="https://termux.mentality.rip/termux-unstable"
|
|
|
|
X11="https://termux.mentality.rip/termux-x11"
|
2020-03-24 07:14:42 +01:00
|
|
|
|
|
|
|
elif [ "$1" == "Mirrors by Grimler" ]; then
|
|
|
|
echo "[*] Grimler's mirrors selected"
|
|
|
|
MAIN="https://grimler.se/termux-packages-24"
|
|
|
|
GAME="https://grimler.se/game-packages-24"
|
|
|
|
ROOT="https://grimler.se/termux-root-packages-24"
|
|
|
|
SCIENCE="https://grimler.se/science-packages-24"
|
|
|
|
UNSTABLE="https://grimler.se/unstable-packages"
|
|
|
|
X11="https://grimler.se/x11-packages"
|
|
|
|
|
2021-05-18 14:48:47 +02:00
|
|
|
elif [ "$1" == "Mirrors by Kcubeterm" ]; then
|
|
|
|
echo "[*] Kcubeterm's mirrors selected"
|
|
|
|
MAIN="https://dl.kcubeterm.me/termux-packages-24"
|
|
|
|
GAME="https://dl.kcubeterm.me/game-packages-24"
|
|
|
|
ROOT="https://dl.kcubeterm.me/termux-root-packages-24"
|
|
|
|
SCIENCE="https://dl.kcubeterm.me/science-packages-24"
|
|
|
|
UNSTABLE="https://dl.kcubeterm.me/unstable-packages"
|
|
|
|
X11="https://dl.kcubeterm.me/x11-packages"
|
|
|
|
|
2021-06-25 16:56:31 +02:00
|
|
|
elif [ "$1" == "Mirrors by Librehat" ]; then
|
|
|
|
echo "[*] Librehat's mirrors selected"
|
|
|
|
MAIN="https://termux.librehat.com/apt/termux-main"
|
|
|
|
GAME="https://termux.librehat.com/apt/termux-games"
|
|
|
|
ROOT="https://termux.librehat.com/apt/termux-root"
|
|
|
|
SCIENCE="https://termux.librehat.com/apt/termux-science"
|
|
|
|
UNSTABLE="https://termux.librehat.com/apt/termux-unstable"
|
|
|
|
X11="https://termux.librehat.com/apt/termux-x11"
|
|
|
|
|
2020-03-24 07:14:42 +01:00
|
|
|
elif [ "$1" == "Mirrors by Tsinghua University" ]; then
|
|
|
|
echo "[*] Tsinghua's mirrors selected"
|
2021-08-01 14:34:04 +02:00
|
|
|
MAIN="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main"
|
|
|
|
GAME="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-games"
|
|
|
|
ROOT="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-root"
|
|
|
|
SCIENCE="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-science"
|
|
|
|
UNSTABLE="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-unstable"
|
|
|
|
X11="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-x11"
|
2020-03-24 07:14:42 +01:00
|
|
|
|
2020-06-21 21:21:14 +02:00
|
|
|
elif [ "$1" == "Mirrors by BFSU" ]; then
|
|
|
|
echo "[*] BFSU mirrors selected"
|
2021-08-01 14:34:04 +02:00
|
|
|
MAIN="https://mirrors.bfsu.edu.cn/termux/apt/termux-main"
|
|
|
|
GAME="https://mirrors.bfsu.edu.cn/termux/apt/termux-games"
|
|
|
|
ROOT="https://mirrors.bfsu.edu.cn/termux/apt/termux-root"
|
|
|
|
SCIENCE="https://mirrors.bfsu.edu.cn/termux/apt/termux-science"
|
|
|
|
UNSTABLE="https://mirrors.bfsu.edu.cn/termux/apt/termux-unstable"
|
2021-08-01 14:46:18 +02:00
|
|
|
X11="https://mirrors.bfsu.edu.cn/termux/apt/termux-x11"
|
2020-06-21 21:21:14 +02:00
|
|
|
|
2021-08-23 10:11:10 +02:00
|
|
|
elif [ "$1" == "Mirrors by NJU" ]; then
|
|
|
|
echo "[*] NJU mirrors selected"
|
|
|
|
MAIN="https://mirror.nju.edu.cn/termux/apt/termux-main"
|
|
|
|
GAME="https://mirror.nju.edu.cn/termux/apt/termux-games"
|
|
|
|
ROOT="https://mirror.nju.edu.cn/termux/apt/termux-root"
|
|
|
|
SCIENCE="https://mirror.nju.edu.cn/termux/apt/termux-science"
|
|
|
|
UNSTABLE="https://mirror.nju.edu.cn/termux/apt/termux-unstable"
|
|
|
|
X11="https://mirror.nju.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2021-06-14 21:25:24 +02:00
|
|
|
elif [ "$1" == "Mirrors by USTC" ]; then
|
|
|
|
echo "[*] USTC mirrors selected"
|
|
|
|
MAIN="https://mirrors.ustc.edu.cn/termux/apt/termux-main"
|
|
|
|
GAME="https://mirrors.ustc.edu.cn/termux/apt/termux-games"
|
|
|
|
ROOT="https://mirrors.ustc.edu.cn/termux/apt/termux-root"
|
|
|
|
SCIENCE="https://mirrors.ustc.edu.cn/termux/apt/termux-science"
|
|
|
|
UNSTABLE="https://mirrors.ustc.edu.cn/termux/apt/termux-unstable"
|
|
|
|
X11="https://mirrors.ustc.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2020-03-24 07:14:42 +01:00
|
|
|
else
|
|
|
|
echo "[!] Error: unknown repository: '$1'. Exiting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
replace_repository sources.list $MAIN "stable main" "$2" "Main repository"
|
|
|
|
replace_repository sources.list.d/game.list $GAME "games stable" "$2" "Game repository"
|
|
|
|
replace_repository sources.list.d/root.list $ROOT "root stable" "$2" "Root repository"
|
|
|
|
replace_repository sources.list.d/science.list $SCIENCE "science stable" "$2" "Science repository"
|
2020-03-29 20:29:21 +02:00
|
|
|
replace_repository sources.list.d/unstable.list $UNSTABLE "unstable main" "$2" "Unstable repository"
|
|
|
|
replace_repository sources.list.d/x11.list $X11 "x11 main" "$2" "X11 repository"
|
2020-03-24 07:14:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
replace_repository() {
|
|
|
|
if [[ "$4" == *"$5"* ]]; then
|
|
|
|
SOURCE_FILE="$1"
|
|
|
|
NEW_URL="$2"
|
|
|
|
COMPONENT_SUITE="$3"
|
|
|
|
|
|
|
|
TMPFILE="$(mktemp $TMPDIR/$(basename ${SOURCE_FILE}).XXXXXX)"
|
|
|
|
if [ "$1" == "sources.list" ]; then
|
|
|
|
echo "# The main termux repository:" >> "$TMPFILE"
|
|
|
|
fi
|
|
|
|
echo "deb ${NEW_URL} ${COMPONENT_SUITE}" >> "$TMPFILE"
|
|
|
|
echo " Changing ${5,,}" #${,,} converts to lower case
|
|
|
|
mv "$TMPFILE" "$PREFIX/etc/apt/${SOURCE_FILE}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
TEMPFILE="$(mktemp $PREFIX/tmp/mirror.XXXXXX)"
|
|
|
|
|
|
|
|
REPOSITORIES=()
|
|
|
|
REPOSITORIES+=("Main repository" "termux-packages" "on")
|
|
|
|
if [ -f "$PREFIX/etc/apt/sources.list.d/game.list" ]; then
|
|
|
|
REPOSITORIES+=("Game repository" "game-packages" "off")
|
|
|
|
fi
|
|
|
|
if [ -f "$PREFIX/etc/apt/sources.list.d/root.list" ]; then
|
|
|
|
REPOSITORIES+=("Root repository" "termux-root-packages" "off")
|
|
|
|
fi
|
|
|
|
if [ -f "$PREFIX/etc/apt/sources.list.d/science.list" ]; then
|
|
|
|
REPOSITORIES+=("Science repository" "science-packages" "off")
|
|
|
|
fi
|
|
|
|
if [ -f "$PREFIX/etc/apt/sources.list.d/unstable.list" ]; then
|
|
|
|
REPOSITORIES+=("Unstable repository" "unstable-packages" "off")
|
|
|
|
fi
|
|
|
|
if [ -f "$PREFIX/etc/apt/sources.list.d/x11.list" ]; then
|
|
|
|
REPOSITORIES+=("X11 repository" "x11-packages" "off")
|
|
|
|
fi
|
|
|
|
|
|
|
|
dialog \
|
|
|
|
--title "termux-change-repo" --clear \
|
|
|
|
--checklist "Which repositories do you want to edit? Select with space." 0 0 0 \
|
|
|
|
"${REPOSITORIES[@]}" --and-widget \
|
|
|
|
--title "termux-change-repo" --clear \
|
|
|
|
--radiolist "Which mirror do you want to use?" 0 0 0 \
|
2021-04-14 16:51:30 +02:00
|
|
|
"Default repositories" "The default package hosting" on \
|
2021-06-20 14:54:10 +02:00
|
|
|
"GH Mirrors by Kcubeterm" "Hosted on Github Release" off \
|
2020-04-19 22:04:55 +02:00
|
|
|
"Mirrors by A1batross" "Hosted on termux.mentality.rip" off \
|
2020-03-24 07:14:42 +01:00
|
|
|
"Mirrors by Grimler" "Hosted on grimler.se" off \
|
2021-05-18 14:48:47 +02:00
|
|
|
"Mirrors by Kcubeterm" "Hosted on dl.kcubeterm.me" off \
|
2021-06-25 16:56:31 +02:00
|
|
|
"Mirrors by Librehat" "Hosted on termux.librehat.com" off \
|
2020-03-24 07:14:42 +01:00
|
|
|
"Mirrors by Tsinghua University" "Hosted on mirrors.tuna.tsinghua.edu.cn" off \
|
2020-06-21 21:21:14 +02:00
|
|
|
"Mirrors by BFSU" "Hosted on mirrors.bfsu.edu.cn" off \
|
2021-08-23 10:11:10 +02:00
|
|
|
"Mirrors by NJU" "Hosted on mirror.nju.edu.cn" off \
|
2021-06-14 21:25:24 +02:00
|
|
|
"Mirrors by USTC" "Hosted on mirrors.ustc.edu.cn" off \
|
2020-03-24 07:14:42 +01:00
|
|
|
2> "$TEMPFILE"
|
2020-03-29 20:26:30 +02:00
|
|
|
|
2020-03-24 07:14:42 +01:00
|
|
|
retval=$?
|
|
|
|
clear
|
|
|
|
|
|
|
|
case $retval in
|
|
|
|
0)
|
|
|
|
IFS=$'\t' read REPOSITORIES MIRROR <<< "$(more $TEMPFILE)"
|
|
|
|
select_repository "$MIRROR" "$REPOSITORIES"
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
# Cancel pressed
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
255)
|
|
|
|
# Esc pressed
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
rm "$TEMPFILE"
|
2020-03-29 20:26:30 +02:00
|
|
|
|
2020-03-29 20:30:10 +02:00
|
|
|
echo "[*] Running apt update"
|
2020-03-29 20:26:30 +02:00
|
|
|
apt update
|