mirror of
https://github.com/elseif/MikroTikPatch
synced 2026-07-17 10:39:40 +00:00
Update chr.sh
Signed-off-by: elseif <elseif@live.cn>
This commit is contained in:
parent
da3653fcb7
commit
3a17176568
44
chr.sh
44
chr.sh
@ -1,12 +1,28 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
echo "System boot mode: UEFI"
|
||||
wget --no-check-certificate -O /tmp/chr.img.zip https://github.com/elseif/MikroTikPatch/releases/download/7.19.4/chr-7.19.4.img.zip
|
||||
else
|
||||
echo "System boot mode: BIOS/MBR"
|
||||
wget --no-check-certificate -O /tmp/chr.img.zip https://github.com/elseif/MikroTikPatch/releases/download/7.19.4/chr-7.19.4-legacy-bios.img.zip
|
||||
fi
|
||||
LATEST_VERSION="7.19.4"
|
||||
ARCH=$(uname -m)
|
||||
case $ARCH in
|
||||
x86_64|i386|i486|i586|i686)
|
||||
echo "ARCH: $ARCH"
|
||||
if [ -d /sys/firmware/efi ]; then
|
||||
echo "BOOT MODE: UEFI"
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$LATEST_VERSION/chr-$LATEST_VERSION.img.zip"
|
||||
else
|
||||
echo "BOOT MOD: BIOS/MBR"
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$LATEST_VERSION/chr-$LATEST_VERSION-legacy-bios.img.zip"
|
||||
fi
|
||||
;;
|
||||
aarch64)
|
||||
echo "ARCH: $ARCH"
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$LATEST_VERSION-arm64/chr-$LATEST_VERSION-arm64.img.zip"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture: $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
wget --no-check-certificate -O /tmp/chr.img.zip "$IMG_URL"
|
||||
cd /tmp
|
||||
unzip -p chr.img.zip > chr.img
|
||||
|
||||
@ -16,19 +32,22 @@ STORAGE=$(for d in /sys/block/*; do
|
||||
*) echo $(basename $d); break ;;
|
||||
esac
|
||||
done)
|
||||
echo "STORAGE is $STORAGE"
|
||||
echo "STORAGE: $STORAGE"
|
||||
|
||||
ETH=$(ip route show default | grep '^default' | sed -n 's/.* dev \([^\ ]*\) .*/\1/p')
|
||||
echo "ETH is $ETH"
|
||||
echo "ETH: $ETH"
|
||||
|
||||
ADDRESS=$(ip addr show $ETH | grep global | cut -d' ' -f 6 | head -n 1)
|
||||
echo "ADDRESS is $ADDRESS"
|
||||
echo "ADDRESS: $ADDRESS"
|
||||
|
||||
GATEWAY=$(ip route list | grep default | cut -d' ' -f 3)
|
||||
echo "GATEWAY is $GATEWAY"
|
||||
echo "GATEWAY: $GATEWAY"
|
||||
|
||||
DNS=$(grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | head -n 1)
|
||||
[ -z "$DNS" ] && DNS="8.8.8.8"
|
||||
echo "DNS: $DNS"
|
||||
|
||||
if LOOP=$(losetup -Pf --show chr.img 2>/dev/null); then
|
||||
echo "LOOP device is $LOOP"
|
||||
sleep 3
|
||||
MNT=/tmp/chr
|
||||
mkdir -p $MNT
|
||||
@ -36,6 +55,7 @@ if LOOP=$(losetup -Pf --show chr.img 2>/dev/null); then
|
||||
cat <<EOF | tee $MNT/rw/autorun.scr
|
||||
/ip address add address=$ADDRESS interface=ether1
|
||||
/ip route add gateway=$GATEWAY
|
||||
/ip dns set servers=$DNS
|
||||
EOF
|
||||
echo "autorun.scr file created."
|
||||
umount $MNT
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user