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"
|
2022-04-02 23:42:12 +02:00
|
|
|
echo "https://github.com/termux/termux-packages/wiki/Mirrors"
|
2020-03-24 07:14:42 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
select_repository() {
|
2022-02-28 22:30:55 +01:00
|
|
|
if [ "$1" == "Default repositories (CF)" ]; then
|
2021-10-30 11:43:27 +02:00
|
|
|
echo "[*] Termux primary host (worldwide) selected"
|
|
|
|
MAIN="https://packages-cf.termux.org/apt/termux-main"
|
|
|
|
ROOT="https://packages-cf.termux.org/apt/termux-root"
|
|
|
|
X11="https://packages-cf.termux.org/apt/termux-x11"
|
2022-02-28 22:30:55 +01:00
|
|
|
|
|
|
|
elif [ "$1" == "Default repositories" ]; then
|
|
|
|
echo "[*] Termux primary host (EU) selected"
|
|
|
|
MAIN="https://packages.termux.org/apt/termux-main"
|
|
|
|
ROOT="https://packages.termux.org/apt/termux-root"
|
|
|
|
X11="https://packages.termux.org/apt/termux-x11"
|
2021-10-30 11:43:27 +02:00
|
|
|
|
2021-06-20 14:54:10 +02:00
|
|
|
elif [ "$1" == "GH Mirrors by Kcubeterm" ]; then
|
|
|
|
echo "[*] GH mirrors selected"
|
2022-02-18 14:50:37 +01:00
|
|
|
MAIN="https://dl.kcubeterm.com/termux-main"
|
|
|
|
ROOT="https://dl.kcubeterm.com/termux-root"
|
|
|
|
X11="https://dl.kcubeterm.com/termux-x11"
|
2021-06-20 14:54:10 +02:00
|
|
|
|
2020-04-19 22:04:55 +02:00
|
|
|
elif [ "$1" == "Mirrors by A1batross" ]; then
|
2021-10-27 12:10:23 +02:00
|
|
|
echo "[*] A1batross mirrors selected"
|
2021-06-04 16:58:54 +02:00
|
|
|
MAIN="https://termux.mentality.rip/termux-main"
|
|
|
|
ROOT="https://termux.mentality.rip/termux-root"
|
|
|
|
X11="https://termux.mentality.rip/termux-x11"
|
2020-03-24 07:14:42 +01:00
|
|
|
|
2021-09-20 21:35:27 +02:00
|
|
|
elif [ "$1" == "Mirrors by Astra ISP" ]; then
|
2021-10-27 12:10:23 +02:00
|
|
|
echo "[*] Astra ISP (UA) mirrors selected"
|
2021-09-20 21:35:27 +02:00
|
|
|
MAIN="https://termux.astra.in.ua/apt/termux-main"
|
|
|
|
ROOT="https://termux.astra.in.ua/apt/termux-root"
|
|
|
|
X11="https://termux.astra.in.ua/apt/termux-x11"
|
|
|
|
|
2021-10-27 12:10:23 +02:00
|
|
|
elif [ "$1" == "Mirrors by Bardia Moshiri" ]; then
|
|
|
|
echo "[*] Bardia Moshiri (Iran) mirrors selected"
|
|
|
|
MAIN="https://mirror.bardia.tech/termux/termux-packages-24/"
|
|
|
|
ROOT="https://mirror.bardia.tech/termux/termux-root-packages-24/"
|
|
|
|
X11="https://mirror.bardia.tech/termux/x11-packages/"
|
|
|
|
|
2020-03-24 07:14:42 +01:00
|
|
|
elif [ "$1" == "Mirrors by Grimler" ]; then
|
2022-01-19 16:54:18 +01:00
|
|
|
echo "[*] Grimler's (NL) mirrors selected"
|
2020-03-24 07:14:42 +01:00
|
|
|
MAIN="https://grimler.se/termux-packages-24"
|
|
|
|
ROOT="https://grimler.se/termux-root-packages-24"
|
|
|
|
X11="https://grimler.se/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"
|
|
|
|
ROOT="https://termux.librehat.com/apt/termux-root"
|
|
|
|
X11="https://termux.librehat.com/apt/termux-x11"
|
|
|
|
|
2022-01-19 16:52:43 +01:00
|
|
|
elif [ "$1" == "Mirrors by Mwt" ]; then
|
|
|
|
echo "[*] Mwt's (USA) mirrors selected"
|
|
|
|
MAIN="https://mirror.mwt.me/termux/main"
|
|
|
|
ROOT="https://mirror.mwt.me/termux/root"
|
|
|
|
X11="https://mirror.mwt.me/termux/x11"
|
|
|
|
|
2022-03-29 19:30:03 +02:00
|
|
|
elif [ "$1" == "Mirrors by Purdue Linux Users Group" ]; then
|
|
|
|
echo "[*] Purdue LUG's (USA) mirrors selected"
|
|
|
|
MAIN="https://plug-mirror.rcac.purdue.edu/termux/termux-main"
|
|
|
|
ROOT="https://plug-mirror.rcac.purdue.edu/termux/termux-root"
|
|
|
|
X11="https://plug-mirror.rcac.purdue.edu/termux/termux-x11"
|
|
|
|
|
2022-01-11 21:29:36 +01:00
|
|
|
elif [ "$1" == "Mirrors by Sahilister" ]; then
|
|
|
|
echo "[*] Sahilister's (DE) mirrors selected"
|
|
|
|
MAIN="https://termux.sahilister.in/apt/termux-main"
|
|
|
|
ROOT="https://termux.sahilister.in/apt/termux-root"
|
|
|
|
X11="https://termux.sahilister.in/apt/termux-x11"
|
|
|
|
|
2020-06-21 21:21:14 +02:00
|
|
|
elif [ "$1" == "Mirrors by BFSU" ]; then
|
2021-10-27 12:10:23 +02:00
|
|
|
echo "[*] BFSU (CN) mirrors selected"
|
2021-08-01 14:34:04 +02:00
|
|
|
MAIN="https://mirrors.bfsu.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.bfsu.edu.cn/termux/apt/termux-root"
|
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
|
|
|
|
2022-04-05 02:25:12 +02:00
|
|
|
elif [ "$1" == "Mirrors by CQUPT" ]; then
|
2022-04-03 21:09:17 +02:00
|
|
|
echo "[*] Chongqing University (CN) mirrors selected"
|
|
|
|
MAIN="https://mirrors.cqupt.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.cqupt.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirrors.cqupt.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2022-04-05 02:25:12 +02:00
|
|
|
elif [ "$1" == "Mirrors by DGUT" ]; then
|
2022-04-03 21:09:17 +02:00
|
|
|
echo "[*] Dongguan University of Technology (CN) mirrors selected"
|
|
|
|
MAIN="https://mirrors.dgut.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.dgut.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirrors.dgut.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
|
|
|
elif [ "$1" == "Mirrors by HIT" ]; then
|
|
|
|
echo "[*] HIT (CN) mirrors selected"
|
|
|
|
MAIN="https://mirrors.hit.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.hit.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirrors.hit.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2021-08-23 10:11:10 +02:00
|
|
|
elif [ "$1" == "Mirrors by NJU" ]; then
|
2021-10-27 12:10:23 +02:00
|
|
|
echo "[*] NJU (CN) mirrors selected"
|
2021-08-23 10:11:10 +02:00
|
|
|
MAIN="https://mirror.nju.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirror.nju.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirror.nju.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2022-04-03 21:09:17 +02:00
|
|
|
elif [ "$1" == "Mirrors by Tsinghua University" ]; then
|
|
|
|
echo "[*] Tsinghua's (CN) mirrors selected"
|
|
|
|
MAIN="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2021-06-14 21:25:24 +02:00
|
|
|
elif [ "$1" == "Mirrors by USTC" ]; then
|
2021-10-27 12:10:23 +02:00
|
|
|
echo "[*] USTC (CN) mirrors selected"
|
2021-06-14 21:25:24 +02:00
|
|
|
MAIN="https://mirrors.ustc.edu.cn/termux/apt/termux-main"
|
|
|
|
ROOT="https://mirrors.ustc.edu.cn/termux/apt/termux-root"
|
|
|
|
X11="https://mirrors.ustc.edu.cn/termux/apt/termux-x11"
|
|
|
|
|
2022-04-03 21:09:17 +02:00
|
|
|
elif [ "$1" == "Mirrors by Alibaba" ]; then
|
|
|
|
echo "[*] Alibaba (CN) mirrors selected"
|
|
|
|
MAIN="https://mirrors.aliyun.com/termux/termux-packages-24"
|
|
|
|
ROOT="https://mirrors.aliyun.com/termux/termux-root-packages-24"
|
|
|
|
X11="https://mirrors.aliyun.com/termux/x11-packages"
|
2022-03-06 03:59:12 +01:00
|
|
|
|
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/root.list $ROOT "root stable" "$2" "Root repository"
|
2020-03-29 20:29:21 +02:00
|
|
|
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
|
2021-10-13 12:45:50 +02:00
|
|
|
mv "$TMPFILE" "@TERMUX_PREFIX@/etc/apt/${SOURCE_FILE}"
|
2020-03-24 07:14:42 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-10-13 12:45:50 +02:00
|
|
|
TEMPFILE="$(mktemp @TERMUX_PREFIX@/tmp/mirror.XXXXXX)"
|
2020-03-24 07:14:42 +01:00
|
|
|
|
|
|
|
REPOSITORIES=()
|
|
|
|
REPOSITORIES+=("Main repository" "termux-packages" "on")
|
2021-10-13 12:45:50 +02:00
|
|
|
if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/root.list" ]; then
|
2020-03-24 07:14:42 +01:00
|
|
|
REPOSITORIES+=("Root repository" "termux-root-packages" "off")
|
|
|
|
fi
|
2021-10-13 12:45:50 +02:00
|
|
|
if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/x11.list" ]; then
|
2020-03-24 07:14:42 +01:00
|
|
|
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-10-30 11:43:27 +02:00
|
|
|
"Default repositories (CF)" "Default host with CloudFlare endpoint" on \
|
2022-03-01 09:50:55 +01:00
|
|
|
"Default repositories" "Default host" off \
|
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 \
|
2021-09-20 21:35:27 +02:00
|
|
|
"Mirrors by Astra ISP" "Hosted on termux.astra.in.ua" off \
|
2021-10-27 12:10:23 +02:00
|
|
|
"Mirrors by Bardia Moshiri" "Hosted on mirror.bardia.tech" off \
|
2020-03-24 07:14:42 +01:00
|
|
|
"Mirrors by Grimler" "Hosted on grimler.se" off \
|
2021-06-25 16:56:31 +02:00
|
|
|
"Mirrors by Librehat" "Hosted on termux.librehat.com" off \
|
2022-01-20 16:08:53 +01:00
|
|
|
"Mirrors by Mwt" "Hosted on mirror.mwt.me" off \
|
2022-03-29 19:30:03 +02:00
|
|
|
"Mirrors by Purdue Linux Users Group" "Hosted on plug-mirror.rcac.purdue.edu" off \
|
2022-01-11 21:29:36 +01:00
|
|
|
"Mirrors by Sahilister" "Hosted on termux.sahilister.in" 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 \
|
2022-04-04 19:06:01 +02:00
|
|
|
"Mirrors by CQUPT" "Hosted on mirrors.cqupt.edu.cn" off \
|
|
|
|
"Mirrors by DGUT" "Hosted on mirrors.dgut.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 \
|
2022-03-06 03:59:12 +01:00
|
|
|
"Mirrors by HIT" "Hosted on mirrors.hit.edu.cn" off \
|
2022-04-04 19:06:01 +02:00
|
|
|
"Mirrors by Alibaba" "Hosted on mirrors.aliyun.com" 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
|