mirror of
https://huihui.cat/mirrors/MikroTikPatch.git
synced 2025-12-10 03:24:37 +01:00
Update chr.sh
Signed-off-by: elseif <elseif@live.cn>
This commit is contained in:
parent
502136464a
commit
6e8d5cf26c
1 changed files with 47 additions and 22 deletions
69
chr.sh
69
chr.sh
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
set_language() {
|
set_language() {
|
||||||
local current_lang=${LANG:-C}
|
local current_lang=${LANG:-C}
|
||||||
current_lang=${current_lang%%.*}
|
current_lang=${current_lang%%.*}
|
||||||
|
|
@ -94,6 +93,41 @@ show_system_info() {
|
||||||
echo "$MSG_DNS $DNS"
|
echo "$MSG_DNS $DNS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
http_get() {
|
||||||
|
local url=$1
|
||||||
|
local dest_file=$2
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
if [ -z "$dest_file" ]; then
|
||||||
|
curl -Ls "$url"
|
||||||
|
else
|
||||||
|
curl -L -# -o "$dest_file" "$url" || { echo "$MSG_DOWNLOAD_FAILED"; exit 1; }
|
||||||
|
fi
|
||||||
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
|
if [ -z "$dest_file" ]; then
|
||||||
|
wget --no-check-certificate -qO- "$url"
|
||||||
|
else
|
||||||
|
wget --no-check-certificate -O "$dest_file" "$url" || { echo "$MSG_DOWNLOAD_FAILED"; exit 1; }
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$MSG_DOWNLOAD_ERROR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_zip() {
|
||||||
|
local zip_file=$1
|
||||||
|
local dest_file=$2
|
||||||
|
if command -v unzip >/dev/null 2>&1; then
|
||||||
|
unzip -p "$zip_file" > "$dest_file" || { echo "$MSG_EXTRACT_ERROR"; exit 1; }
|
||||||
|
elif command -v gunzip >/dev/null 2>&1; then
|
||||||
|
gunzip -c "$zip_file" > "$dest_file" || { echo "$MSG_EXTRACT_ERROR"; exit 1; }
|
||||||
|
else
|
||||||
|
echo "$MSG_EXTRACT_ERROR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
select_version() {
|
select_version() {
|
||||||
if [[ -n "$VERSION" ]]; then
|
if [[ -n "$VERSION" ]]; then
|
||||||
if [[ "$VERSION" == 7.* ]]; then
|
if [[ "$VERSION" == 7.* ]]; then
|
||||||
|
|
@ -129,14 +163,20 @@ select_version() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
case $version_choice in
|
case $version_choice in
|
||||||
1) VERSION=$(curl -s "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.stable" | cut -d' ' -f1); V7=1 ;;
|
1)
|
||||||
2) VERSION=$(curl -s "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.testing" | cut -d' ' -f1); V7=1 ;;
|
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.stable" | cut -d' ' -f1)
|
||||||
|
V7=1
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.testing" | cut -d' ' -f1)
|
||||||
|
V7=1
|
||||||
|
;;
|
||||||
3)
|
3)
|
||||||
if [[ "$ARCH" == "aarch64" ]]; then
|
if [[ "$ARCH" == "aarch64" ]]; then
|
||||||
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
VERSION=$(curl -s "https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term" | cut -d' ' -f1)
|
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term" | cut -d' ' -f1)
|
||||||
V7=0
|
V7=0
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
|
|
@ -144,7 +184,7 @@ select_version() {
|
||||||
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
VERSION=$(curl -s "https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable" | cut -d' ' -f1)
|
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable" | cut -d' ' -f1)
|
||||||
V7=0
|
V7=0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
@ -175,27 +215,12 @@ download_image(){
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "$MSG_FILE_DOWNLOAD $(basename "$IMG_URL")"
|
echo "$MSG_FILE_DOWNLOAD $(basename "$IMG_URL")"
|
||||||
if command -v curl >/dev/null 2>&1; then
|
http_get "$IMG_URL" "/tmp/chr.img.zip"
|
||||||
curl -L -# -o /tmp/chr.img.zip "$IMG_URL" || { echo "$MSG_DOWNLOAD_FAILED"; exit 1; }
|
|
||||||
elif command -v wget >/dev/null 2>&1; then
|
|
||||||
wget -nv -O /tmp/chr.img.zip "$IMG_URL" || { echo "$MSG_DOWNLOAD_FAILED"; exit 1; }
|
|
||||||
else
|
|
||||||
echo "$MSG_DOWNLOAD_ERROR $IMG_URL"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
if command -v unzip >/dev/null 2>&1; then
|
extract_zip "chr.img.zip" chr.img
|
||||||
unzip -p "chr.img.zip" > chr.img
|
|
||||||
elif command -v gunzip >/dev/null 2>&1; then
|
|
||||||
gunzip -c chr.img.zip > chr.img
|
|
||||||
else
|
|
||||||
echo "$MSG_EXTRACT_ERROR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create_autorun() {
|
create_autorun() {
|
||||||
|
|
||||||
if LOOP=$(losetup -Pf --show chr.img 2>/dev/null); then
|
if LOOP=$(losetup -Pf --show chr.img 2>/dev/null); then
|
||||||
sleep 1
|
sleep 1
|
||||||
MNT=/tmp/chr
|
MNT=/tmp/chr
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue