mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-08-26 10:05:50 +00:00
Compare commits
174 Commits
7.20beta8-
...
7.21beta4-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86e11b647d | ||
|
|
07c6617805 | ||
|
|
bf2865921a | ||
|
|
604631539c | ||
|
|
fc7bb4f206 | ||
|
|
410c19d2ce | ||
|
|
d5eea3df4b | ||
|
|
73559ce979 | ||
|
|
c54b46c760 | ||
|
|
8603498d39 | ||
|
|
d3fa483c4b | ||
|
|
e338ddb7b2 | ||
|
|
826072d302 | ||
|
|
5eee7b4dbb | ||
|
|
1691d01550 | ||
|
|
4543b7b3b2 | ||
|
|
3cddd9e6fb | ||
|
|
3fb99a94ac | ||
|
|
356575af79 | ||
|
|
58970bd829 | ||
|
|
6e8d5cf26c | ||
|
|
502136464a | ||
|
|
6b7d1a849f | ||
|
|
77f07bbf27 | ||
|
|
06a9d80798 | ||
|
|
3c2e1197ce | ||
|
|
befaa60509 | ||
|
|
1a2f73d363 | ||
|
|
e7063fdcbd | ||
|
|
b26437cb47 | ||
|
|
b6c24eb657 | ||
|
|
f1d3c640f8 | ||
|
|
2f627420a2 | ||
|
|
482041cac3 | ||
|
|
c139e9012a | ||
|
|
89e9e0a92e | ||
|
|
9ad1b924a1 | ||
|
|
68c53e4a19 | ||
|
|
e70a8aff16 | ||
|
|
1b857342ba | ||
|
|
4b4b257b4a | ||
|
|
597cbf30d8 | ||
|
|
6d7f3c0fd7 | ||
|
|
fc6fc897e1 | ||
|
|
0f45d580ba | ||
|
|
930a496ce4 | ||
|
|
b7f321f748 | ||
|
|
f9662f6d23 | ||
|
|
db5c0c3c8f | ||
|
|
93455ac7e7 | ||
|
|
29e25d9e8a | ||
|
|
30a45fc829 | ||
|
|
9d91a8348d | ||
|
|
66877c2071 | ||
|
|
671ad79933 | ||
|
|
61ba016da0 | ||
|
|
96d23defd3 | ||
|
|
5e80b52278 | ||
|
|
54252e8645 | ||
|
|
f03d0300d2 | ||
|
|
8281f0193f | ||
|
|
500c7b5748 | ||
|
|
e5b8288b35 | ||
|
|
fe493a8f0f | ||
|
|
e8bd998953 | ||
|
|
9ad4028007 | ||
|
|
f55fba6699 | ||
|
|
e2debac366 | ||
|
|
7fe82f7498 | ||
|
|
e7a08895f5 | ||
|
|
b436141665 | ||
|
|
86e2727c56 | ||
|
|
96670cbe60 | ||
|
|
f91f8e15d0 | ||
|
|
c4dd46205b | ||
|
|
4f9d2133fd | ||
|
|
b6721ffd7d | ||
|
|
6cbdbffbcb | ||
|
|
6d27075389 | ||
|
|
9b92fc3fa6 | ||
|
|
0c92a04b58 | ||
|
|
296db5b558 | ||
|
|
49bbcb1983 | ||
|
|
f750442687 | ||
|
|
06bd69f331 | ||
|
|
e35cf5f74e | ||
|
|
e12e1aa67b | ||
|
|
6a8aaa89d8 | ||
|
|
495927d0de | ||
|
|
c73c6bacc8 | ||
|
|
8e7134e0a6 | ||
|
|
f4cc728789 | ||
|
|
8c3278f477 | ||
|
|
04a831b463 | ||
|
|
c75dd48261 | ||
|
|
6519ab2e12 | ||
|
|
ec1c0f1719 | ||
|
|
3de34ef556 | ||
|
|
8499e4591a | ||
|
|
f520ff799c | ||
|
|
ccb4220a61 | ||
|
|
8159018e3c | ||
|
|
dc30d89afb | ||
|
|
4472649719 | ||
|
|
fc469087be | ||
|
|
477fd66fe0 | ||
|
|
cd32348c52 | ||
|
|
37f92c3def | ||
|
|
2bb452b300 | ||
|
|
710921ef23 | ||
|
|
8bfcdfe5a8 | ||
|
|
2baf264aec | ||
|
|
fd6f36d484 | ||
|
|
2ab01e5328 | ||
|
|
16854dadf9 | ||
|
|
d981a4b137 | ||
|
|
378c9009b8 | ||
|
|
73f9ba0506 | ||
|
|
646f479290 | ||
|
|
e3b46ed7c3 | ||
|
|
1a66685cc4 | ||
|
|
cbd6ffa50c | ||
|
|
73d90b27e0 | ||
|
|
60728d6fe2 | ||
|
|
556cc81474 | ||
|
|
2286063b65 | ||
|
|
907b335d3a | ||
|
|
567819bec4 | ||
|
|
bbc6b854cd | ||
|
|
6f4c9b43fc | ||
|
|
659de9d659 | ||
|
|
78707050a0 | ||
|
|
cdb378b45d | ||
|
|
9b40d04e38 | ||
|
|
110cda779c | ||
|
|
36be15859e | ||
|
|
c40954115b | ||
|
|
2babd89f27 | ||
|
|
7a6e538834 | ||
|
|
a2f9af37ad | ||
|
|
6e630b852a | ||
|
|
4987501168 | ||
|
|
c2ec6d439c | ||
|
|
c5712825ba | ||
|
|
072417bf1b | ||
|
|
f2d18e32f6 | ||
|
|
7758330905 | ||
|
|
0ff47ed53e | ||
|
|
90dfb10d32 | ||
|
|
a217ae8df0 | ||
|
|
fa9c53bef1 | ||
|
|
18b6449701 | ||
|
|
d7517cb9f4 | ||
|
|
3a17176568 | ||
|
|
da3653fcb7 | ||
|
|
48bd5e9601 | ||
|
|
c0f53a242a | ||
|
|
8d18551f5b | ||
|
|
f29d91d1a4 | ||
|
|
89c13ae6fa | ||
|
|
e028fdd880 | ||
|
|
88ff1f7130 | ||
|
|
92f26c270e | ||
|
|
c1163894f3 | ||
|
|
5196f20043 | ||
|
|
bba676a2d6 | ||
|
|
259051906c | ||
|
|
2162e76e64 | ||
|
|
7c22877423 | ||
|
|
6a486adfc6 | ||
|
|
49608606f2 | ||
|
|
85a2526bcd | ||
|
|
b5049c0ebb | ||
|
|
15273578e8 |
49
.github/workflows/mikrotik_patch_6.yml
vendored
49
.github/workflows/mikrotik_patch_6.yml
vendored
@@ -143,18 +143,9 @@ jobs:
|
||||
7z x -p"${{ secrets.LOADER_7Z_PASSWORD }}" loader.7z >> /dev/null
|
||||
rm loader.7z
|
||||
|
||||
- name: Cache Squashfs
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
id: cache-squashfs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
python3.sfs
|
||||
option.sfs
|
||||
key: busybox-python3-squashfs-${{ matrix.arch }}
|
||||
|
||||
- name: Create Squashfs for option and python3
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-squashfs.outputs.cache-hit != 'true'
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
run: |
|
||||
sudo mkdir -p ./option-root/bin/
|
||||
sudo cp busybox/busybox_x86 ./option-root/bin/busybox
|
||||
@@ -221,8 +212,8 @@ jobs:
|
||||
fi
|
||||
sudo cp -f system-$LATEST_VERSION.npk ./new_iso/
|
||||
sudo -E python3 patch.py kernel ./new_iso/isolinux/initrd.rgz
|
||||
#sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION.npk ./option-$LATEST_VERSION.npk option ./option.sfs -desc="busybox"
|
||||
#sudo cp option-$LATEST_VERSION.npk ./new_iso/
|
||||
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION.npk ./option-$LATEST_VERSION.npk option ./option.sfs -desc="busybox"
|
||||
sudo cp option-$LATEST_VERSION.npk ./new_iso/
|
||||
sudo mkisofs -o mikrotik-$LATEST_VERSION.iso \
|
||||
-V "MikroTik $LATEST_VERSION" \
|
||||
-sysid "" -preparer "MiKroTiK" \
|
||||
@@ -300,8 +291,10 @@ jobs:
|
||||
sudo cp ./all_packages/dude-$LATEST_VERSION.npk ./chr/var/pdb/dude/image
|
||||
sudo -E python3 patch.py npk ./chr/var/pdb/routeros-x86/image
|
||||
sudo cp ./chr/var/pdb/routeros-x86/image ./all_packages/routeros-x86-$LATEST_VERSION.npk
|
||||
#sudo mkdir -p ./chr/var/pdb/option
|
||||
#sudo cp ./all_packages/option-$LATEST_VERSION.npk ./chr/var/pdb/option/image
|
||||
sudo mkdir -p ./chr/var/pdb/option
|
||||
sudo cp ./all_packages/option-$LATEST_VERSION.npk ./chr/var/pdb/option/image
|
||||
sudo mkdir -p ./chr/rw/disk
|
||||
echo -e '#!/bin/sh\n# This script will be executed *before* RouterOS *loader* start.\n# You can put your own initialization stuff in here\n' | sudo tee ./chr/rw/disk/rc.local
|
||||
sudo umount ./chr
|
||||
sudo qemu-nbd -d /dev/nbd0
|
||||
sudo rm -rf ./chr
|
||||
@@ -328,13 +321,22 @@ jobs:
|
||||
cd ./all_packages
|
||||
sudo zip ../all_packages-x86-$LATEST_VERSION.zip *.npk
|
||||
cd ..
|
||||
|
||||
- name: Upload Files
|
||||
|
||||
- name: Prepare for Upload
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sudo mkdir -p ./publish/$LATEST_VERSION
|
||||
sudo cp CHANGELOG ./publish/$LATEST_VERSION/
|
||||
sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
||||
# sudo cp mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp chr-${{ env.LATEST_VERSION }}*.zip ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp netinstall-${{ env.LATEST_VERSION }}.* ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp install-image-${{ env.LATEST_VERSION }}.zip ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
echo $LATEST_VERSION $BUILD_TIME | sudo tee ./publish/NEWEST6.${{ matrix.channel }}
|
||||
|
||||
- name: Upload Files
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sudo chown -R root:root ./publish/
|
||||
|
||||
LOCAL_PATH=./publish/$LATEST_VERSION
|
||||
@@ -355,6 +357,20 @@ jobs:
|
||||
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no -p $PORT $USER@$SERVER \
|
||||
"echo $LATEST_VERSION $BUILD_TIME | tee /rw/disk/$REMOTE_PATH/NEWEST6.$CHANNEL; chown -R 32768:32768 /rw/disk/$REMOTE_PATH/"
|
||||
|
||||
|
||||
# - name: Upload to R2 Bucket
|
||||
# if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
# uses: ryand56/r2-upload-action@latest
|
||||
# with:
|
||||
# r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
|
||||
# r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
# r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
# r2-bucket: routeros
|
||||
# source-dir: ./publish
|
||||
# destination-dir: ./routeros
|
||||
# keep-file-fresh: true
|
||||
# output-file-url: false
|
||||
|
||||
|
||||
- name: Clear Cloudflare cache
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
@@ -367,6 +383,7 @@ jobs:
|
||||
- name: Delete Release tag ${{ env.LATEST_VERSION }}
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sed -i "1i Build Time:$BUILD_TIME" CHANGELOG
|
||||
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION)
|
||||
RELEASE_ID=$(echo $RELEASE_INFO | jq -r '.id')
|
||||
|
||||
207
.github/workflows/mikrotik_patch_7.yml
vendored
207
.github/workflows/mikrotik_patch_7.yml
vendored
@@ -159,18 +159,8 @@ jobs:
|
||||
7z x -p"${{ secrets.LOADER_7Z_PASSWORD }}" loader.7z >> /dev/null
|
||||
rm loader.7z
|
||||
|
||||
- name: Cache Squashfs
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
id: cache-squashfs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
python3.sfs
|
||||
option.sfs
|
||||
key: busybox-python3-squashfs-${{ matrix.arch }}
|
||||
|
||||
- name: Create Squashfs for option and python3
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-squashfs.outputs.cache-hit != 'true'
|
||||
if: steps.get_latest.outputs.has_new_version == 'true'
|
||||
run: |
|
||||
sudo mkdir -p ./option-root/bin/
|
||||
if [ "${{ matrix.arch }}" == "x86" ]; then
|
||||
@@ -221,6 +211,7 @@ jobs:
|
||||
path: |
|
||||
mikrotik.iso
|
||||
key: mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
||||
restore-keys: mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
||||
|
||||
- name: Get mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-mikrotik.outputs.cache-hit != 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||
@@ -255,6 +246,16 @@ jobs:
|
||||
sudo -E python3 npk.py sign "$file" "$file"
|
||||
done
|
||||
fi
|
||||
if [ "$LATEST_VERSION" = "7.12.1" ]; then
|
||||
URL="https://download.mikrotik.com/routeros/$LATEST_VERSION/routeros-${{ matrix.arch }}-$LATEST_VERSION.npk"
|
||||
sudo wget -nv -O "routeros-${{ matrix.arch }}-$LATEST_VERSION.npk" "$URL"
|
||||
sudo -E python3 patch.py npk routeros-${{ matrix.arch }}-$LATEST_VERSION.npk
|
||||
sudo mv "routeros-${{ matrix.arch }}-$LATEST_VERSION.npk" ./new_iso
|
||||
URL="https://download.mikrotik.com/routeros/$LATEST_VERSION/system-$LATEST_VERSION.npk"
|
||||
sudo wget -nv -O "system-$LATEST_VERSION.npk" "$URL"
|
||||
sudo -E python3 patch.py npk system-$LATEST_VERSION.npk
|
||||
sudo mv "system-$LATEST_VERSION.npk" ./new_iso
|
||||
fi
|
||||
sudo cp -f routeros-$LATEST_VERSION$ARCH.npk ./new_iso/
|
||||
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./option-$LATEST_VERSION$ARCH.npk option ./option.sfs -desc="busybox"
|
||||
sudo cp option-$LATEST_VERSION$ARCH.npk ./new_iso/
|
||||
@@ -311,6 +312,7 @@ jobs:
|
||||
path: |
|
||||
chr.img
|
||||
key: chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||
restore-keys: chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||
|
||||
- name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-chr-img.outputs.cache-hit != 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||
@@ -323,17 +325,110 @@ jobs:
|
||||
- name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && (matrix.arch == 'x86' || matrix.arch == 'arm64')
|
||||
run: |
|
||||
OVF_TEMPLATE='<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Envelope vmw:buildId="build-18663434" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<References>
|
||||
<File ovf:href="{VMDK_FILE}" ovf:id="file1" ovf:size="{FILE_SIZE}"/>
|
||||
</References>
|
||||
<DiskSection>
|
||||
<Info>Virtual disk information</Info>
|
||||
<Disk ovf:capacity="{CAPACITY_MB}" ovf:capacityAllocationUnits="byte * 2^20" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized"/>
|
||||
</DiskSection>
|
||||
<NetworkSection>
|
||||
<Info>The list of logical networks</Info>
|
||||
<Network ovf:name="VM Network">
|
||||
<Description>The VM Network network</Description>
|
||||
</Network>
|
||||
</NetworkSection>
|
||||
<VirtualSystem ovf:id="vm">
|
||||
<Info>A virtual machine</Info>
|
||||
<Name>MikroTik_RouterOS_CHR</Name>
|
||||
<OperatingSystemSection ovf:id="100" vmw:osType="other3xLinux64Guest">
|
||||
<Info>The kind of installed guest operating system</Info>
|
||||
</OperatingSystemSection>
|
||||
<VirtualHardwareSection>
|
||||
<Info>Virtual hardware requirements</Info>
|
||||
<System>
|
||||
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
|
||||
<vssd:InstanceID>0</vssd:InstanceID>
|
||||
<vssd:VirtualSystemIdentifier>MikroTik_RouterOS_CHR</vssd:VirtualSystemIdentifier>
|
||||
<vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
|
||||
</System>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
|
||||
<rasd:Description>Number of Virtual CPUs</rasd:Description>
|
||||
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
|
||||
<rasd:InstanceID>1</rasd:InstanceID>
|
||||
<rasd:ResourceType>3</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>1024MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>2</rasd:InstanceID>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>1024</rasd:VirtualQuantity>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:Address>0</rasd:Address>
|
||||
<rasd:Description>IDE Controller</rasd:Description>
|
||||
<rasd:ElementName>ideController0</rasd:ElementName>
|
||||
<rasd:InstanceID>3</rasd:InstanceID>
|
||||
<rasd:ResourceType>5</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>0</rasd:AddressOnParent>
|
||||
<rasd:ElementName>disk0</rasd:ElementName>
|
||||
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
|
||||
<rasd:InstanceID>4</rasd:InstanceID>
|
||||
<rasd:Parent>3</rasd:Parent>
|
||||
<rasd:ResourceType>17</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item>
|
||||
<rasd:AddressOnParent>1</rasd:AddressOnParent>
|
||||
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
|
||||
<rasd:Connection>VM Network</rasd:Connection>
|
||||
<rasd:Description>VmxNet3 ethernet adapter on "VM Network"</rasd:Description>
|
||||
<rasd:ElementName>ethernet0</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>10</rasd:ResourceType>
|
||||
<vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="160"/>
|
||||
<vmw:Config ovf:required="false" vmw:key="connectable.allowGuestControl" vmw:value="true"/>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>video</rasd:ElementName>
|
||||
<rasd:InstanceID>6</rasd:InstanceID>
|
||||
<rasd:ResourceType>24</rasd:ResourceType>
|
||||
</Item>
|
||||
<Item ovf:required="false">
|
||||
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
|
||||
<rasd:ElementName>vmci</rasd:ElementName>
|
||||
<rasd:InstanceID>7</rasd:InstanceID>
|
||||
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
|
||||
<rasd:ResourceType>1</rasd:ResourceType>
|
||||
</Item>
|
||||
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="{FIRMWARE_TYPE}"/>
|
||||
</VirtualHardwareSection>
|
||||
<AnnotationSection ovf:required="false">
|
||||
<Info>A human-readable annotation</Info>
|
||||
<Annotation>MikroTik RouterOS CHR v7.19.4</Annotation>
|
||||
</AnnotationSection>
|
||||
</VirtualSystem>
|
||||
</Envelope>'
|
||||
sudo modprobe nbd
|
||||
sudo apt-get install -y qemu-utils > /dev/null
|
||||
truncate --size 128M chr-$LATEST_VERSION$ARCH.img
|
||||
sgdisk --clear --set-alignment=8 \
|
||||
sgdisk --clear --set-alignment=2 \
|
||||
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
||||
--new=2::-0 --typecode=2:8300 --change-name=2:"RouterOS" \
|
||||
--gpttombr=1:2 \
|
||||
chr-$LATEST_VERSION$ARCH.img
|
||||
dd if=chr-$LATEST_VERSION$ARCH.img of=pt.bin bs=1 count=66 skip=446
|
||||
echo -e "\x80" | dd of=pt.bin bs=1 count=1 conv=notrunc
|
||||
sgdisk --mbrtogpt --clear --set-alignment=8 \
|
||||
sgdisk --mbrtogpt --clear --set-alignment=2 \
|
||||
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
||||
--new=2::-0 --typecode=2:8300 --change-name=2:"RouterOS" \
|
||||
chr-$LATEST_VERSION$ARCH.img
|
||||
@@ -369,7 +464,27 @@ jobs:
|
||||
sudo qemu-img convert -f raw -O vpc chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vhd
|
||||
sudo qemu-img convert -f raw -O vhdx chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vhdx
|
||||
sudo qemu-img convert -f raw -O vdi chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios.vdi
|
||||
|
||||
|
||||
sudo qemu-img convert -f raw -O vmdk -o subformat=streamOptimized chr-$LATEST_VERSION$ARCH-legacy-bios.img chr-$LATEST_VERSION$ARCH-legacy-bios-disk1.vmdk
|
||||
VMDK=chr-$LATEST_VERSION$ARCH-legacy-bios-disk1.vmdk
|
||||
OVF=chr-$LATEST_VERSION$ARCH-legacy-bios.ovf
|
||||
OVA=chr-$LATEST_VERSION$ARCH-legacy-bios.ova
|
||||
FILE_SIZE=$(stat -c %s "$VMDK")
|
||||
VIRTUAL_SIZE=$(qemu-img info --output=json "$VMDK" | jq '.["virtual-size"]' | head -n 1)
|
||||
CAPACITY_MB=$((VIRTUAL_SIZE / 1024 / 1024))
|
||||
POPULATED_SIZE=$FILE_SIZE
|
||||
FIRMWARE_TYPE="bios"
|
||||
echo "$OVF_TEMPLATE" | sudo sed -e "s|{VMDK_FILE}|$VMDK|g" \
|
||||
-e "s|{FILE_SIZE}|$FILE_SIZE|g" \
|
||||
-e "s|{CAPACITY_MB}|$CAPACITY_MB|g" \
|
||||
-e "s|{POPULATED_SIZE}|$POPULATED_SIZE|g" \
|
||||
-e "s|{FIRMWARE_TYPE}|$FIRMWARE_TYPE|g" |sudo tee $OVF
|
||||
sudo tar -cvf "$OVA" "$OVF" "$VMDK"
|
||||
sudo rm $VMDK
|
||||
sudo rm $OVF
|
||||
sudo zip $OVA.zip $OVA
|
||||
sudo rm $OVA
|
||||
|
||||
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2.zip chr-$LATEST_VERSION$ARCH-legacy-bios.qcow2
|
||||
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vmdk
|
||||
sudo zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhd.zip chr-$LATEST_VERSION$ARCH-legacy-bios.vhd
|
||||
@@ -405,11 +520,31 @@ jobs:
|
||||
sudo qemu-nbd -d /dev/nbd0
|
||||
|
||||
sudo qemu-img convert -f raw -O qcow2 chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.qcow2
|
||||
sudo qemu-img convert -f raw -O vmdk chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vmdk
|
||||
sudo qemu-img convert -f raw -O vmdk chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vmdk
|
||||
sudo qemu-img convert -f raw -O vpc chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vhd
|
||||
sudo qemu-img convert -f raw -O vhdx chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vhdx
|
||||
sudo qemu-img convert -f raw -O vdi chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vdi
|
||||
|
||||
sudo qemu-img convert -f raw -O vmdk -o subformat=streamOptimized chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH-disk1.vmdk
|
||||
VMDK=chr-$LATEST_VERSION$ARCH-disk1.vmdk
|
||||
OVF=chr-$LATEST_VERSION$ARCH.ovf
|
||||
OVA=chr-$LATEST_VERSION$ARCH.ova
|
||||
FILE_SIZE=$(stat -c %s "$VMDK")
|
||||
VIRTUAL_SIZE=$(qemu-img info --output=json "$VMDK" | jq '.["virtual-size"]' | head -n 1)
|
||||
CAPACITY_MB=$((VIRTUAL_SIZE / 1024 / 1024))
|
||||
POPULATED_SIZE=$FILE_SIZE
|
||||
FIRMWARE_TYPE="efi"
|
||||
echo "$OVF_TEMPLATE" | sudo sed -e "s|{VMDK_FILE}|$VMDK|g" \
|
||||
-e "s|{FILE_SIZE}|$FILE_SIZE|g" \
|
||||
-e "s|{CAPACITY_MB}|$CAPACITY_MB|g" \
|
||||
-e "s|{POPULATED_SIZE}|$POPULATED_SIZE|g" \
|
||||
-e "s|{FIRMWARE_TYPE}|$FIRMWARE_TYPE|g" |sudo tee $OVF
|
||||
sudo tar -cvf "$OVA" "$OVF" "$VMDK"
|
||||
sudo rm $VMDK
|
||||
sudo rm $OVF
|
||||
sudo zip $OVA.zip $OVA
|
||||
sudo rm $OVA
|
||||
|
||||
sudo zip chr-$LATEST_VERSION$ARCH.qcow2.zip chr-$LATEST_VERSION$ARCH.qcow2
|
||||
sudo zip chr-$LATEST_VERSION$ARCH.vmdk.zip chr-$LATEST_VERSION$ARCH.vmdk
|
||||
sudo zip chr-$LATEST_VERSION$ARCH.vhd.zip chr-$LATEST_VERSION$ARCH.vhd
|
||||
@@ -423,6 +558,7 @@ jobs:
|
||||
sudo rm chr-$LATEST_VERSION$ARCH.vhdx
|
||||
sudo rm chr-$LATEST_VERSION$ARCH.vdi
|
||||
sudo rm chr-$LATEST_VERSION$ARCH.img
|
||||
|
||||
|
||||
- name: Cache all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
||||
@@ -431,6 +567,7 @@ jobs:
|
||||
with:
|
||||
path: all_packages.zip
|
||||
key: all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||
restore-keys: all_packages${{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||
|
||||
- name: Get all_packages{{ env.ARCH }}-${{ env.LATEST_VERSION }}.zip
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-all-packages.outputs.cache-hit != 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
||||
@@ -444,6 +581,7 @@ jobs:
|
||||
with:
|
||||
path: routeros.npk
|
||||
key: routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||
restore-keys: routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||
|
||||
- name: Get Main package routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-main-package.outputs.cache-hit != 'true' && matrix.arch != 'x86' && matrix.arch != 'arm64'
|
||||
@@ -474,6 +612,7 @@ jobs:
|
||||
with:
|
||||
path: refind-bin-0.14.2.zip
|
||||
key: refind
|
||||
restore-keys: refind
|
||||
|
||||
- name: Get refind
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true' && env.RELEASE == 'true'
|
||||
@@ -527,6 +666,7 @@ jobs:
|
||||
netinstall.zip
|
||||
netinstall.tar.gz
|
||||
key: netinstall-${{ env.LATEST_VERSION }}
|
||||
restore-keys: netinstall-${{ env.LATEST_VERSION }}
|
||||
|
||||
- name: Get netinstall ${{ env.LATEST_VERSION }}
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true' && env.RELEASE == 'true'
|
||||
@@ -540,18 +680,26 @@ jobs:
|
||||
sudo unzip netinstall.zip
|
||||
sudo -E python3 patch.py netinstall netinstall.exe
|
||||
sudo zip netinstall-$LATEST_VERSION.zip ./netinstall.exe
|
||||
sudo tar -xvf netinstall.tar.gz
|
||||
sudo -E python3 patch.py netinstall netinstall-cli
|
||||
sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli
|
||||
# sudo tar -xvf netinstall.tar.gz
|
||||
# sudo -E python3 patch.py netinstall netinstall-cli
|
||||
# sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli
|
||||
|
||||
- name: Upload Files
|
||||
- name: Prepare for Upload
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sudo mkdir -p ./publish/$LATEST_VERSION
|
||||
sudo cp CHANGELOG ./publish/$LATEST_VERSION/
|
||||
sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
||||
# sudo cp mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp chr-${{ env.LATEST_VERSION }}*.zip ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp netinstall-${{ env.LATEST_VERSION }}.* ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
# sudo cp install-image-${{ env.LATEST_VERSION }}.zip ./publish/$LATEST_VERSION/ 2>/dev/null || true
|
||||
echo $LATEST_VERSION $BUILD_TIME | sudo tee ./publish/NEWESTa7.${{ matrix.channel }}
|
||||
|
||||
- name: Upload Files
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sudo chown -R root:root ./publish/
|
||||
|
||||
LOCAL_PATH=./publish/$LATEST_VERSION
|
||||
REMOTE_PATH=${{ secrets.SSH_DIRECTORY }}
|
||||
SERVER=${{ secrets.SSH_SERVER }}
|
||||
@@ -572,10 +720,22 @@ jobs:
|
||||
"echo $LATEST_VERSION $BUILD_TIME | tee /rw/disk/$REMOTE_PATH/NEWESTa7.$CHANNEL; bash /rw/disk/$REMOTE_PATH/packages.sh /rw/disk/$REMOTE_PATH/$LATEST_VERSION"
|
||||
|
||||
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no -p $PORT $USER@$SERVER \
|
||||
"chown -R 32768:32768 /rw/disk/$REMOTE_PATH/"
|
||||
|
||||
|
||||
"chown -R 32768:32768 /rw/disk/$REMOTE_PATH/"
|
||||
|
||||
# - name: Upload to R2 Bucket
|
||||
# if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
# uses: ryand56/r2-upload-action@latest
|
||||
# with:
|
||||
# r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
|
||||
# r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
# r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
# r2-bucket: routeros
|
||||
# source-dir: ./publish
|
||||
# destination-dir: ./routeros
|
||||
# keep-file-fresh: true
|
||||
# output-file-url: false
|
||||
|
||||
|
||||
- name: Clear Cloudflare cache
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
@@ -587,6 +747,7 @@ jobs:
|
||||
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ env.ARCH }}
|
||||
if: steps.get_latest.outputs.has_new_version == 'true' && env.RELEASE == 'true'
|
||||
run: |
|
||||
sed -i "1i Build Time:$BUILD_TIME" CHANGELOG
|
||||
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||
RELEASE_INFO=$(curl -s -H "$HEADER" https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
|
||||
RELEASE_ID=$(echo $RELEASE_INFO | jq -r '.id')
|
||||
|
||||
19
README.md
19
README.md
@@ -1,6 +1,11 @@
|
||||
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_6.yml)
|
||||
[](https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_7.yml)
|
||||
|
||||
### 感谢赞助
|
||||
[](https://www.digitalocean.com/?refcode=dbf6ed365068&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)
|
||||
|
||||
[DartNode(aff)](https://dartnode.com?aff=SnazzyLobster067) | [ZMTO(aff)](https://console.zmto.com/?affid=1588) | [Vultr(aff)](https://www.vultr.com/?ref=9807160-9J)
|
||||
|
||||
# MikroTik RouterOS Patch [[English](README_EN.md)]
|
||||
[](./LICENSE)
|
||||
[](./CODE_OF_CONDUCT.md)
|
||||
@@ -9,8 +14,8 @@
|
||||
|
||||
支持:在线更新、在线授权、云备份、DDNS
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
*如果云服务或部署云服务的虚拟主机都不在线,那么在线更新、在线授权、云备份、DDNS以及ROS_Keygen_Bot都暂时不能使用*
|
||||
|
||||
@@ -22,7 +27,7 @@ graph TD
|
||||
B -->|否| D[检查 rc.local 文件是否存在]
|
||||
C --> D
|
||||
D -->|是| E[fork 执行 /bin/sh rc.local]
|
||||
D -->|否| F[结束]
|
||||
D -->|否| F[启动服务]
|
||||
E --> F
|
||||
```
|
||||

|
||||
@@ -60,10 +65,10 @@ graph TD
|
||||
|
||||
## 所有的修补操作都自动运行在[Github Action](https://github.com/elseif/MikroTikPatch/blob/main/.github/workflows/)。
|
||||
|
||||
### 感谢赞助
|
||||
[ZMTO](https://console.zmto.com)
|
||||
|
||||
[](https://dartnode.com "Powered by DartNode - Free VPS for Open Source")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
361
chr.sh
361
chr.sh
@@ -1,15 +1,346 @@
|
||||
curl -# -L https://github.com/elseif/MikroTikPatch/releases/download/7.19.3/chr-7.19.3-legacy-bios.img.zip -o /tmp/chr.img.zip && cd /tmp && \
|
||||
gunzip -c chr.img.zip > chr.img && \
|
||||
STORAGE=`lsblk | grep disk | cut -d ' ' -f 1 | head -n 1` && \
|
||||
echo STORAGE is $STORAGE && \
|
||||
ETH=`ip route show default | sed -n 's/.* dev \([^\ ]*\) .*/\1/p'` && \
|
||||
echo ETH is $ETH && \
|
||||
ADDRESS=`ip addr show $ETH | grep global | cut -d' ' -f 6 | head -n 1` && \
|
||||
echo ADDRESS is $ADDRESS && \
|
||||
GATEWAY=`ip route list | grep default | cut -d' ' -f 3` && \
|
||||
echo GATEWAY is $GATEWAY && \
|
||||
sleep 5 && \
|
||||
dd if=chr.img of=/dev/$STORAGE bs=4M oflag=sync && \
|
||||
echo "Ok, reboot" && \
|
||||
echo 1 > /proc/sys/kernel/sysrq && \
|
||||
echo b > /proc/sysrq-trigger
|
||||
#!/bin/bash
|
||||
set -e
|
||||
_ask() {
|
||||
local _redo=0
|
||||
|
||||
read resp
|
||||
case "$resp" in
|
||||
!) echo "Type 'exit' to return to setup."
|
||||
sh
|
||||
_redo=1
|
||||
;;
|
||||
!*) eval "${resp#?}"
|
||||
_redo=1
|
||||
;;
|
||||
esac
|
||||
return $_redo
|
||||
}
|
||||
ask() {
|
||||
local _question="$1" _default="$2"
|
||||
while :; do
|
||||
printf %s "$_question "
|
||||
[ -z "$_default" ] || printf "[%s] " "$_default"
|
||||
_ask && : ${resp:=$_default} && break
|
||||
done
|
||||
}
|
||||
ask_until() {
|
||||
resp=
|
||||
while [ -z "$resp" ] ; do
|
||||
ask "$1" "$2"
|
||||
done
|
||||
}
|
||||
yesno() {
|
||||
case $1 in
|
||||
[Yy]) return 0;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
ask_yesno() {
|
||||
while true; do
|
||||
ask "$1" "$2"
|
||||
case "$resp" in
|
||||
Y|y|N|n) break;;
|
||||
esac
|
||||
done
|
||||
yesno "$resp"
|
||||
}
|
||||
|
||||
|
||||
select_language() {
|
||||
while true; do
|
||||
echo "Select your language:"
|
||||
echo "1. English"
|
||||
echo "2. 简体中文"
|
||||
ask_until "Please choose an option" "1"
|
||||
case $resp in
|
||||
1)
|
||||
MSG_ARCH="Arch:"
|
||||
MSG_BOOTMODE="BootMode:"
|
||||
MSG_STORAGE_DEVICE="Input storage device name:"
|
||||
MSG_ADDRESS="Input IP address:"
|
||||
MSG_GATEWAY="Input gateway:"
|
||||
MSG_DNS="Input domain name server:"
|
||||
MSG_SELECT_VERSION="Select the version you want to install:"
|
||||
MSG_STABLE="stable (v7)"
|
||||
MSG_TEST="testing (v7)"
|
||||
MSG_LTS="long-term (v6)"
|
||||
MSG_STABLE6="stable (v6)"
|
||||
MSG_PLEASE_CHOOSE="Please choose an option:"
|
||||
MSG_UNSUPPORTED_ARCH="Error: Unsupported architecture: "
|
||||
MSG_INVALID_OPTION="Error: Invalid option!"
|
||||
MSG_ARM64_NOT_SUPPORT_V6="arm64 does not support v6 version for now."
|
||||
MSG_SELECTED_VERSION="Selected version:"
|
||||
MSG_FILE_DOWNLOAD="Download file: "
|
||||
MSG_DOWNLOAD_ERROR="Error: No wget nor curl is installed. Cannot download."
|
||||
MSG_EXTRACT_ERROR="Error: No unzip nor gunzip is installed. Cannot uncompress."
|
||||
MSG_DOWNLOAD_FAILED="Error: Download failed!"
|
||||
MSG_OPERATION_ABORTED="Error: Operation aborted."
|
||||
MSG_WARNING="Warn: All data on /dev/%s will be lost!"
|
||||
MSG_REBOOTING="Ok, rebooting..."
|
||||
MSG_ADMIN_PASSWORD="admin password:"
|
||||
MSG_MANUAL_PASS_CHOICE="Do you want to enter a password manually? (y/N): "
|
||||
MSG_ENTER_NEW_PASS="Enter new password: "
|
||||
MSG_PASS_EMPTY="Password cannot be empty, please try again."
|
||||
MSG_ERROR_MOUNT="Error: Failed to mount partition"
|
||||
MSG_ERROR_LOOP="Error: Failed to setup loop device"
|
||||
MSG_AUTO_RUN_FILE_CREATED="autorun.scr file created."
|
||||
MSG_AUTO_RUN_FILE_NOT_CREATED="Warn: autorun.scr file create failed"
|
||||
MSG_CONFIRM_CONTINUE="Do you want to continue? [y/n]"
|
||||
;;
|
||||
2)
|
||||
MSG_ARCH="CPU架构:"
|
||||
MSG_BOOTMODE="引导模式:"
|
||||
MSG_STORAGE_DEVICE="输入存储设备名称:"
|
||||
MSG_ADDRESS="输入IP地址:"
|
||||
MSG_GATEWAY="输入网关地址:"
|
||||
MSG_DNS="输入DNS服务器:"
|
||||
MSG_SELECT_VERSION="请选择您要安装的版本:"
|
||||
MSG_STABLE="稳定版 (v7)"
|
||||
MSG_TEST="测试版 (v7)"
|
||||
MSG_LTS="长期支持版 (v6)"
|
||||
MSG_STABLE6="稳定版 (v6)"
|
||||
MSG_PLEASE_CHOOSE="请选择一个选项:"
|
||||
MSG_UNSUPPORTED_ARCH="错误: 不支持的架构: "
|
||||
MSG_INVALID_OPTION="错误: 无效选项"
|
||||
MSG_ARM64_NOT_SUPPORT_V6="ARM64架构暂不支持安装v6版本"
|
||||
MSG_SELECTED_VERSION="已选择版本:"
|
||||
MSG_FILE_DOWNLOAD="下载文件: "
|
||||
MSG_DOWNLOAD_ERROR="错误: wget 或 curl 都未安装,无法下载文件。"
|
||||
MSG_EXTRACT_ERROR="错误: unzip 或 gunzip 都未安装,无法解压文件。"
|
||||
MSG_DOWNLOAD_FAILED="错误: 下载失败!"
|
||||
MSG_OPERATION_ABORTED="错误: 操作已中止。"
|
||||
MSG_WARNING="警告:/dev/%s 上的数据将会丢失!"
|
||||
MSG_REBOOTING="好的,正在重启..."
|
||||
MSG_ADMIN_PASSWORD="管理员密码:"
|
||||
MSG_MANUAL_PASS_CHOICE="是否手动输入密码?(y/N): "
|
||||
MSG_ENTER_NEW_PASS="请输入新密码: "
|
||||
MSG_PASS_EMPTY="密码不能为空,请重新输入。"
|
||||
MSG_ERROR_MOUNT="错误: 挂载分区失败"
|
||||
MSG_ERROR_LOOP="错误: 设置 loop 设备失败"
|
||||
MSG_AUTO_RUN_FILE_CREATED="autorun.scr 文件已创建。"
|
||||
MSG_AUTO_RUN_FILE_NOT_CREATED="警告:autorun.scr 文件创建失败!"
|
||||
MSG_CONFIRM_CONTINUE="您是否确定继续? [y/n]"
|
||||
;;
|
||||
*)
|
||||
echo "Error: Invalid option!"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
show_system_info() {
|
||||
ARCH=$(uname -m)
|
||||
BOOT_MODE=$( [ -d "/sys/firmware/efi" ] && echo "UEFI" || echo "BIOS" )
|
||||
echo "$MSG_ARCH $ARCH"
|
||||
echo "$MSG_BOOTMODE $BOOT_MODE"
|
||||
}
|
||||
|
||||
confirm_storge() {
|
||||
if command -v lsblk >/dev/null 2>&1; then
|
||||
STORAGE=$(lsblk -d -n -o NAME,TYPE | awk '$2=="disk"{print $1; exit}')
|
||||
else
|
||||
STORAGE=$(fdisk -l | awk '/^Disk \/dev/ {print $2; exit}' | sed 's#:##' | sed 's#/dev/##')
|
||||
fi
|
||||
ask_until "$MSG_STORAGE_DEVICE" "$STORAGE"
|
||||
STORAGE=$resp
|
||||
}
|
||||
confirm_address() {
|
||||
ETH=$(ip route show default | grep '^default' | sed -n 's/.* dev \([^\ ]*\) .*/\1/p')
|
||||
ADDRESS=$(ip addr show $ETH | grep global | cut -d' ' -f 6 | head -n 1)
|
||||
GATEWAY=$(ip route list | grep default | cut -d' ' -f 3)
|
||||
if [ -f "/etc/resolv.conf" ]; then
|
||||
DNS=$(grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | head -n 1)
|
||||
fi
|
||||
[ -z "$DNS" ] && DNS="8.8.8.8"
|
||||
ask_until "$MSG_ADDRESS" "$ADDRESS"
|
||||
ADDRESS=$resp
|
||||
ask_until "$MSG_GATEWAY" "$GATEWAY"
|
||||
GATEWAY=$resp
|
||||
ask_until "$MSG_DNS" "$DNS"
|
||||
DNS=$resp
|
||||
}
|
||||
|
||||
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() {
|
||||
if [[ -n "$VERSION" ]]; then
|
||||
if [[ "$VERSION" == 7.* ]]; then
|
||||
V7=1
|
||||
elif [[ "$VERSION" == 6.* ]]; then
|
||||
V7=0
|
||||
else
|
||||
echo "Error: Unsupported version $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
echo "$MSG_SELECTED_VERSION $VERSION"
|
||||
return
|
||||
fi
|
||||
while true; do
|
||||
case $ARCH in
|
||||
x86_64|i386|i486|i586|i686)
|
||||
echo "$MSG_SELECT_VERSION"
|
||||
echo "1. $MSG_STABLE"
|
||||
echo "2. $MSG_TEST"
|
||||
echo "3. $MSG_LTS"
|
||||
echo "4. $MSG_STABLE6"
|
||||
read -p "$MSG_PLEASE_CHOOSE [1-4]" version_choice
|
||||
;;
|
||||
aarch64)
|
||||
echo "$MSG_SELECT_VERSION"
|
||||
echo "1. $MSG_STABLE"
|
||||
echo "2. $MSG_TEST"
|
||||
read -p "$MSG_PLEASE_CHOOSE [1-2]" version_choice
|
||||
;;
|
||||
*)
|
||||
echo "$MSG_UNSUPPORTED_ARCH $ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
case $version_choice in
|
||||
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)
|
||||
if [[ "$ARCH" == "aarch64" ]]; then
|
||||
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
||||
continue
|
||||
fi
|
||||
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term" | cut -d' ' -f1)
|
||||
V7=0
|
||||
;;
|
||||
4)
|
||||
if [[ "$ARCH" == "aarch64" ]]; then
|
||||
echo "$MSG_ARM64_NOT_SUPPORT_V6"
|
||||
continue
|
||||
fi
|
||||
VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable" | cut -d' ' -f1)
|
||||
V7=0
|
||||
;;
|
||||
*)
|
||||
echo "$MSG_INVALID_OPTION"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
echo "$MSG_SELECTED_VERSION $VERSION"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
download_image(){
|
||||
case $ARCH in
|
||||
x86_64|i386|i486|i586|i686)
|
||||
if [[ $V7 == 1 && $BOOT_MODE == "BIOS" ]]; then
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$VERSION/chr-$VERSION-legacy-bios.img.zip"
|
||||
else
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$VERSION/chr-$VERSION.img.zip"
|
||||
fi
|
||||
;;
|
||||
aarch64)
|
||||
IMG_URL="https://github.com/elseif/MikroTikPatch/releases/download/$VERSION-arm64/chr-$VERSION-arm64.img.zip"
|
||||
;;
|
||||
*)
|
||||
echo "$MSG_UNSUPPORTED_ARCH"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
echo "$MSG_FILE_DOWNLOAD $(basename "$IMG_URL")"
|
||||
http_get "$IMG_URL" "/tmp/chr.img.zip"
|
||||
cd /tmp
|
||||
extract_zip "chr.img.zip" chr.img
|
||||
}
|
||||
|
||||
create_autorun() {
|
||||
if LOOP=$(losetup -Pf --show chr.img 2>/dev/null); then
|
||||
sleep 1
|
||||
MNT=/tmp/chr
|
||||
mkdir -p $MNT
|
||||
PARTITION=$([ "$V7" == 1 ] && echo "p2" || echo "p1")
|
||||
if mount "${LOOP}${PARTITION}" "$MNT" 2>/dev/null; then
|
||||
confirm_address
|
||||
RANDOM_ADMIN_PASS=$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 16)
|
||||
ask_until "$MSG_ADMIN_PASSWORD" "$RANDOM_ADMIN_PASS"
|
||||
RANDOM_ADMIN_PASS=$resp
|
||||
cat <<EOF > "$MNT/rw/autorun.scr"
|
||||
/user set admin password="$RANDOM_ADMIN_PASS"
|
||||
/ip dns set servers=$DNS
|
||||
/ip address add address=$ADDRESS interface=ether1
|
||||
/ip route add gateway=$GATEWAY
|
||||
EOF
|
||||
echo "$MSG_AUTO_RUN_FILE_CREATED"
|
||||
umount $MNT
|
||||
losetup -d "$LOOP"
|
||||
else
|
||||
losetup -d "$LOOP"
|
||||
echo "$MSG_ERROR_MOUNT $PARTITION"
|
||||
echo "$MSG_AUTO_RUN_FILE_NOT_CREATED"
|
||||
fi
|
||||
else
|
||||
echo "$MSG_ERROR_LOOP"
|
||||
echo "$MSG_AUTO_RUN_FILE_NOT_CREATED"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
write_and_reboot() {
|
||||
confirm_storge
|
||||
printf "$MSG_WARNING\n" "$STORAGE"
|
||||
ask_yesno "$MSG_CONFIRM_CONTINUE"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$MSG_OPERATION_ABORTED"
|
||||
exit 1
|
||||
fi
|
||||
dd if=chr.img of=/dev/$STORAGE bs=4M conv=fsync
|
||||
echo "$MSG_REBOOTING"
|
||||
echo 1 > /proc/sys/kernel/sysrq 2>/dev/null || true
|
||||
echo b > /proc/sysrq-trigger 2>/dev/null || true
|
||||
reboot -f
|
||||
}
|
||||
|
||||
select_language
|
||||
show_system_info
|
||||
select_version
|
||||
download_image
|
||||
create_autorun
|
||||
write_and_reboot
|
||||
exit 0
|
||||
|
||||
819
index.html
Normal file
819
index.html
Normal file
@@ -0,0 +1,819 @@
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en" class="scroll-smooth">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MikroTik RouterOS Patched Versions</title>
|
||||
|
||||
<!-- Tailwind CSS framework for styling -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Iconify icon library for icons -->
|
||||
<script src="https://code.iconify.design/3/3.1.1/iconify.min.js"></script>
|
||||
<!-- Google Fonts preconnect for performance optimization -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<!-- Mirror fonts for Chinese users (fonts.loli.net) -->
|
||||
<link rel="preconnect" href="https://fonts.loli.net">
|
||||
<link rel="preconnect" href="https://gstatic.loli.net" crossorigin>
|
||||
<!-- Main font stylesheet with Inter and Fira Code fonts -->
|
||||
<link id="webfont-css" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fira+Code&display=swap" rel="stylesheet">
|
||||
<!-- Font loading fallback script for Chinese users -->
|
||||
<script>
|
||||
(function(){
|
||||
var linkEl = document.getElementById('webfont-css');
|
||||
if (!linkEl) return;
|
||||
var mirrorHref = 'https://fonts.loli.net/css2?family=Inter:wght@400;500;600;700&family=Fira+Code&display=swap';
|
||||
// Check if a specific font is loaded
|
||||
function isLoaded(name){
|
||||
if (!('fonts' in document)) return false;
|
||||
try { return document.fonts.check('1em "' + name + '"'); } catch (e) { return false; }
|
||||
}
|
||||
// Switch to mirror font server if Google Fonts fails
|
||||
function switchToMirror(){
|
||||
if (linkEl.href !== mirrorHref) { linkEl.href = mirrorHref; }
|
||||
}
|
||||
if (!('fonts' in document)) { switchToMirror(); return; }
|
||||
var decided = false;
|
||||
// Timeout fallback - switch to mirror after 2.5 seconds if fonts not loaded
|
||||
var timer = setTimeout(function(){
|
||||
if (!decided && (!isLoaded('Inter') || !isLoaded('Fira Code'))) {
|
||||
decided = true; switchToMirror();
|
||||
}
|
||||
}, 2500);
|
||||
// Check when fonts are ready
|
||||
document.fonts.ready.then(function(){
|
||||
if (!decided && (!isLoaded('Inter') || !isLoaded('Fira Code'))) {
|
||||
decided = true; switchToMirror();
|
||||
} else {
|
||||
decided = true; clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Custom CSS styles using Tailwind CSS -->
|
||||
<style type="text/tailwindcss">
|
||||
/* Main body styling with gradient background */
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-image: radial-gradient(circle at top, #dde3ee 0%, #f1f5f9 60%);
|
||||
}
|
||||
/* Dark mode gradient background */
|
||||
html.dark body {
|
||||
background-image: radial-gradient(circle at top, #1e293b 0%, #0f172a 60%);
|
||||
}
|
||||
/* Monospace font for command code blocks */
|
||||
#command pre, #command code {
|
||||
font-family: 'Fira Code', monospace;
|
||||
}
|
||||
/* Custom scrollbar styling */
|
||||
.custom-scrollbar::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background: #94a3b8;
|
||||
border-radius: 10px;
|
||||
}
|
||||
/* Dark mode scrollbar */
|
||||
html.dark .custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background: #475569;
|
||||
}
|
||||
/* Active state for version selection buttons */
|
||||
#version-buttons button.active {
|
||||
@apply bg-blue-600 text-white shadow-md;
|
||||
}
|
||||
/* Hide default details marker for custom styling */
|
||||
summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
/* Content card animation classes */
|
||||
.content-card {
|
||||
@apply transition-all duration-700;
|
||||
}
|
||||
/* Loading state animation */
|
||||
.loading .content-card {
|
||||
@apply opacity-0 translate-y-4;
|
||||
}
|
||||
</style>
|
||||
<!-- Tailwind CSS configuration -->
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class', // Enable class-based dark mode
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'sans-serif'], // Default sans-serif font
|
||||
mono: ['Fira Code', 'monospace'], // Monospace font for code
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<!-- Main body with dark mode support and loading animation -->
|
||||
<body class="bg-slate-100 dark:bg-gray-900 text-slate-700 dark:text-slate-300 transition-colors duration-300 loading">
|
||||
|
||||
<!-- GitHub corner ribbon (top-right corner) -->
|
||||
<a href="https://github.com/elseif/MikroTikPatch" class="github-corner fixed top-0 right-0 z-50" aria-label="View source on GitHub" target="_blank">
|
||||
<svg width="80" height="80" viewBox="0 0 250 250" class="fill-slate-800 dark:fill-slate-50" style="position: absolute; top: 0; border: 0; right: 0;">
|
||||
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
|
||||
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm text-slate-50 dark:text-gray-900"></path>
|
||||
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.6,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body text-slate-50 dark:text-gray-900"></path>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<!-- Main container with responsive padding -->
|
||||
<div class="container mx-auto max-w-7xl px-4 py-8 md:py-16">
|
||||
|
||||
<!-- Page header section -->
|
||||
<header class="text-center mb-12 content-card" style="transition-delay: 100ms;">
|
||||
<!-- Main title with gradient text effect -->
|
||||
<h1 class="text-4xl md:text-5xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-sky-400 dark:from-blue-400 dark:to-sky-300 mb-3">MikroTik RouterOS</h1>
|
||||
<p class="text-xl md:text-2xl text-slate-600 dark:text-slate-400">Patched Versions</p>
|
||||
|
||||
<!-- Status badges for build workflows and services -->
|
||||
<div class="mt-6 flex justify-center items-center gap-4 flex-wrap">
|
||||
<a href="https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_6.yml" target="_blank"><img src="https://mikrotik.ltd/badge/mikrotik_patch_6.yml" alt="Patch Mikrotik RouterOS 6.x"></a>
|
||||
<a href="https://github.com/elseif/MikroTikPatch/actions/workflows/mikrotik_patch_7.yml" target="_blank"><img src="https://mikrotik.ltd/badge/mikrotik_patch_7.yml" alt="Patch Mikrotik RouterOS 7.x"></a>
|
||||
<img src="https://img.shields.io/endpoint?logo=icloud&url=https://mikrotik.ltd/status/cloud" alt="Cloud Status">
|
||||
<img src="https://img.shields.io/endpoint?logo=googlecloudstorage&url=https://mikrotik.ltd/status/dartnode" alt="VPS Status">
|
||||
</div>
|
||||
<!-- GitHub social buttons -->
|
||||
<div class="mt-4 flex justify-center items-center gap-2">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
<a class="github-button" href="https://github.com/elseif/MikroTikPatch" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star elseif/MikroTikPatch on GitHub">Star</a>
|
||||
<a class="github-button" href="https://github.com/elseif/MikroTikPatch/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="true" aria-label="Fork elseif/MikroTikPatch on GitHub">Fork</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
<!-- Main content area -->
|
||||
<main class="space-y-12">
|
||||
|
||||
<!-- Information and settings card -->
|
||||
<div class="bg-white/60 dark:bg-gray-800/60 rounded-2xl shadow-lg p-6 md:p-8 ring-1 ring-black/5 backdrop-blur-xl content-card" style="transition-delay: 200ms;">
|
||||
<div class="grid md:grid-cols-2 gap-8">
|
||||
<!-- Quick information section -->
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-slate-800 dark:text-white mb-4 flex items-center"><span class="iconify mr-2 text-blue-500" data-icon="ph:info-bold"></span><span data-i18n="quickInformation"></span></h2>
|
||||
<div class="space-y-3 text-sm">
|
||||
<p data-i18n="infoLabel1"></p>
|
||||
<p data-i18n="infoLabel2"></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Settings section -->
|
||||
<div class="border-t md:border-t-0 md:border-l border-slate-200 dark:border-gray-700 pt-6 md:pt-0 md:pl-8">
|
||||
<h2 class="text-lg font-semibold text-slate-800 dark:text-white mb-4 flex items-center"><span class="iconify mr-2 text-blue-500" data-icon="ph:gear-six-bold"></span><span data-i18n="settings"></span></h2>
|
||||
<div class="space-y-4">
|
||||
|
||||
<!-- Theme toggle switch -->
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="theme-toggle-btn" class="font-medium" data-i18n="theme"></label>
|
||||
<button id="theme-toggle-btn" class="p-2 rounded-full text-slate-500 hover:bg-slate-200 dark:text-slate-400 dark:hover:bg-slate-700 transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 focus:ring-offset-white dark:focus:ring-offset-gray-900">
|
||||
<span class="sr-only">Toggle theme</span>
|
||||
<span class="iconify text-xl sun-icon" data-icon="ph:sun-bold"></span>
|
||||
<span class="iconify text-xl moon-icon" data-icon="ph:moon-bold"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Language selector -->
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="lang-switcher" data-i18n="language" class="font-medium"></label>
|
||||
<select id="lang-switcher" class="bg-slate-100 dark:bg-gray-700 border border-slate-300 dark:border-gray-600 rounded-md p-1.5 text-sm focus:ring-blue-500 focus:border-blue-500">
|
||||
<option value="en">English</option>
|
||||
<option value="zh">中文</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- GitHub proxy toggle -->
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="gh-proxy" data-i18n="proxyLabel" class="font-medium text-sm"></label>
|
||||
<label class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" id="gh-proxy" name="gh-proxy" class="sr-only peer">
|
||||
<div class="w-11 h-6 bg-slate-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Clear cache button -->
|
||||
<div>
|
||||
<button data-i18n="clearCache" id="clear-cache" class="w-full text-sm font-semibold bg-slate-100 hover:bg-slate-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-slate-700 dark:text-slate-200 py-2 px-4 rounded-lg transition-colors flex items-center justify-center gap-2"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Install command section -->
|
||||
<div class="bg-white/60 dark:bg-gray-800/60 rounded-2xl shadow-lg ring-1 ring-black/5 backdrop-blur-xl overflow-hidden content-card" style="transition-delay: 300ms;">
|
||||
<div class="p-6 md:p-8">
|
||||
<h2 class="text-lg font-semibold text-slate-800 dark:text-white mb-4 flex items-center" data-i18n="installCmdLabel"><span class="iconify mr-2 text-blue-500" data-icon="ph:terminal-window-bold"></span></h2>
|
||||
<!-- Version and tool selection controls -->
|
||||
<div class="flex flex-wrap items-center gap-2 mb-4">
|
||||
<!-- Version selection buttons (populated by JavaScript) -->
|
||||
<div id="version-buttons" class="flex flex-wrap items-center gap-2 p-1 bg-slate-100 dark:bg-gray-700/50 rounded-lg">
|
||||
|
||||
</div>
|
||||
<!-- Tool selection (curl/wget) -->
|
||||
<div class="flex items-center gap-2 p-1 bg-slate-100 dark:bg-gray-700/50 rounded-lg">
|
||||
<label class="flex items-center px-2 cursor-pointer">
|
||||
<input type="radio" name="tool" value="curl" checked class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
||||
<span class="ml-2 text-sm font-medium">curl</span>
|
||||
</label>
|
||||
<label class="flex items-center px-2 cursor-pointer">
|
||||
<input type="radio" name="tool" value="wget" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
||||
<span class="ml-2 text-sm font-medium">wget</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Command display area with copy button -->
|
||||
<div id="command-container" class="relative bg-slate-900 dark:bg-black/50 p-4 text-sm">
|
||||
<button id="copy-btn" class="absolute top-3 right-3 p-1.5 bg-slate-700 hover:bg-slate-600 rounded-md text-slate-300 hover:text-white transition-colors">
|
||||
<span class="sr-only">Copy command</span>
|
||||
<span class="iconify text-lg copy-icon" data-icon="ph:copy-bold"></span>
|
||||
<span class="iconify text-lg check-icon hidden" data-icon="ph:check-bold"></span>
|
||||
</button>
|
||||
<div id="command"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Download sections container (populated by JavaScript) -->
|
||||
<div id="download-rows" class="space-y-8 content-card" style="transition-delay: 400ms;">
|
||||
|
||||
<!-- Loading overlay shown while fetching version data -->
|
||||
<div class="loading-overlay fixed inset-0 bg-slate-100/80 dark:bg-gray-900/80 flex flex-col items-center justify-center z-50" id="loading">
|
||||
<span class="iconify text-4xl text-blue-600 animate-spin" data-icon="ph:spinner-gap-bold"></span>
|
||||
<span data-i18n="loading" class="mt-4 text-lg font-medium"></span>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
<!-- Footer with banner-style social links -->
|
||||
<footer class="mt-16 pt-8 border-t border-slate-200 dark:border-gray-700/50">
|
||||
<div class="text-center">
|
||||
<!-- Social links without container background -->
|
||||
<div class="flex justify-center items-center gap-4">
|
||||
<!-- Telegram link -->
|
||||
<a href="https://t.me/mikrotikpatch" target="_blank"
|
||||
class="group flex items-center gap-3 px-6 py-3 rounded-xl bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white shadow-md hover:shadow-lg transition-all duration-300 hover:scale-105">
|
||||
<span class="iconify text-xl transition-transform duration-300 group-hover:rotate-12" data-icon="ph:telegram-logo-bold"></span>
|
||||
<span class="font-semibold text-sm">Telegram</span>
|
||||
</a>
|
||||
|
||||
<!-- GitHub link -->
|
||||
<a href="https://github.com/elseif/MikroTikPatch" target="_blank"
|
||||
class="group flex items-center gap-3 px-6 py-3 rounded-xl bg-gradient-to-r from-gray-800 to-gray-900 hover:from-gray-700 hover:to-gray-800 dark:from-slate-600 dark:to-slate-700 dark:hover:from-slate-500 dark:hover:to-slate-600 text-white shadow-md hover:shadow-lg transition-all duration-300 hover:scale-105">
|
||||
<span class="iconify text-xl transition-transform duration-300 group-hover:rotate-12" data-icon="ph:github-logo-bold"></span>
|
||||
<span class="font-semibold text-sm">GitHub</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- URLs modal for cache clearing -->
|
||||
<div id="urls-pannel" class="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4 hidden" tabindex="-1">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col transform transition-all opacity-0 scale-95" id="modal-content">
|
||||
<header class="p-4 border-b border-slate-200 dark:border-gray-700 flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-slate-800 dark:text-white" data-i18n="copyUrlsClearCache"></h3>
|
||||
<button id="urls-close" class="p-1 rounded-full text-slate-400 hover:bg-slate-100 dark:hover:bg-gray-700">
|
||||
<span class="sr-only">Close modal</span>
|
||||
<span class="iconify text-2xl" data-icon="ph:x-bold"></span>
|
||||
</button>
|
||||
</header>
|
||||
<!-- URLs list display area -->
|
||||
<div id="urls-list" class="p-6 text-sm text-slate-600 dark:text-slate-400 overflow-y-auto custom-scrollbar flex-grow bg-slate-50 dark:bg-gray-900/50 rounded-b-xl whitespace-pre-wrap break-all"></div>
|
||||
<footer class="p-4 border-t border-slate-200 dark:border-gray-700">
|
||||
<button id="copy-to-clear-cache" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 focus:ring-offset-white dark:focus:ring-offset-gray-800 flex items-center justify-center gap-2" data-i18n="copyUrlsClearCache" href="#"></button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Changelog popup modal -->
|
||||
<div id="changelog-modal" class="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4 hidden" tabindex="-1">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] flex flex-col transform transition-all opacity-0 scale-95" id="changelog-modal-content">
|
||||
<header class="p-4 border-b border-slate-200 dark:border-gray-700 flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-slate-800 dark:text-white flex items-center gap-2">
|
||||
<span class="iconify text-blue-500" data-icon="ph:newspaper-clipping-bold"></span>
|
||||
<span data-i18n="changelog"></span>
|
||||
</h3>
|
||||
<button id="changelog-close" class="p-1 rounded-full text-slate-400 hover:bg-slate-100 dark:hover:bg-gray-700">
|
||||
<span class="sr-only">Close modal</span>
|
||||
<span class="iconify text-2xl" data-icon="ph:x-bold"></span>
|
||||
</button>
|
||||
</header>
|
||||
<!-- Changelog content display area -->
|
||||
<div id="changelog-content" class="p-6 text-sm text-slate-600 dark:text-slate-400 overflow-y-auto custom-scrollbar flex-grow bg-slate-50 dark:bg-gray-900/50 rounded-b-xl">
|
||||
<!-- Loading state for changelog -->
|
||||
<div class="flex items-center justify-center py-8">
|
||||
<span class="iconify text-4xl text-blue-600 animate-spin" data-icon="ph:spinner-gap-bold"></span>
|
||||
<span class="ml-4 text-lg font-medium" data-i18n="loadingChangelog"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Main JavaScript functionality -->
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
// Icon definitions for consistent icon usage
|
||||
const ICONS = {
|
||||
download: 'ph:download-simple-bold',
|
||||
changelog: 'ph:newspaper-clipping-bold',
|
||||
trash: 'ph:trash-bold',
|
||||
copyAndOpen: 'ph:copy-simple-bold'
|
||||
};
|
||||
|
||||
// Function to fetch latest version numbers with timeout fallback
|
||||
async function fetch_latest_versions(url, defaultValue, timeout = 3000) {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
clearTimeout(id);
|
||||
if (res.ok) {
|
||||
const text = await res.text();
|
||||
return text.split(" ")[0]; // Extract version number from response
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("fetch failed or timeout:", e);
|
||||
}
|
||||
return defaultValue; // Return fallback version if fetch fails
|
||||
}
|
||||
|
||||
// Internationalization (i18n) translations for English and Chinese
|
||||
const i18n = {
|
||||
en: {
|
||||
language: "Language",
|
||||
infoLabel1:`If you are already running <b>patched</b> RouterOS, upgrading to the latest version can be done by clicking on <b>"Check For Updates"</b> in <b>QuickSet or System > Packages</b> menu in WebFig or WinBox.`,
|
||||
infoLabel2:`For more information about <b>install and upgrade</b> see the <a href="https://help.mikrotik.com/docs/" target="_blank" class="text-blue-500 dark:text-blue-400 hover:underline">Documentation</a>. For more information about <b>patch</b> see the <a href="https://github.com/elseif/MikroTikPatch" target="_blank" class="text-blue-500 dark:text-blue-400 hover:underline">MikroTikPatch</a>.`,
|
||||
installCmdLabel:"Install Command",
|
||||
proxyLabel:"Enable GitHub Proxy Accelerator",
|
||||
clearCache:"Clear gh-proxy Cache",
|
||||
copyUrlsClearCache:"Copy URLs & Open Clear Cache Page",
|
||||
loading:"Loading latest versions...",
|
||||
quickInformation:"Quick Information",
|
||||
settings:"Settings",
|
||||
theme:"Theme",
|
||||
changelog:"Changelog",
|
||||
loadingChangelog:"Loading changelog...",
|
||||
changelogError:"Failed to load changelog. Please try again later.",
|
||||
},
|
||||
zh: {
|
||||
language: "语言",
|
||||
infoLabel1:`如果你已经在运行<b>Patch</b>过的RouterOS,可以通过WebFig或WinBox中的<b>QuickSet或System > Packages</b>菜单点击<b>"Check For Updates"</b>来升级到最新版本。`,
|
||||
infoLabel2:`有关<b>安装和升级</b>的更多信息,请参阅<a href="https://help.mikrotik.com/docs/" target="_blank" class="text-blue-500 dark:text-blue-400 hover:underline">文档</a><br>有关<b>Patch</b>的更多信息,请参阅<a href="https://github.com/elseif/MikroTikPatch" target="_blank" class="text-blue-500 dark:text-blue-400 hover:underline">MikroTikPatch</a>`,
|
||||
installCmdLabel:"安装命令",
|
||||
proxyLabel:"启用GitHub代理加速",
|
||||
clearCache:"清除gh-proxy缓存",
|
||||
copyUrlsClearCache:"复制链接并打开缓存清除页面",
|
||||
loading:"正在加载最新版本...",
|
||||
quickInformation:"快速信息",
|
||||
settings:"设置",
|
||||
theme:"主题",
|
||||
changelog:"更新日志",
|
||||
loadingChangelog:"正在加载更新日志...",
|
||||
changelogError:"加载更新日志失败,请稍后重试。",
|
||||
}
|
||||
};
|
||||
|
||||
// Function to set language and update all i18n elements
|
||||
function setLanguage(lang) {
|
||||
document.querySelectorAll("[data-i18n]").forEach(el => {
|
||||
const key = el.getAttribute("data-i18n");
|
||||
if (i18n[lang] && i18n[lang][key]) {
|
||||
// Special handling for buttons that need icons
|
||||
if (key === 'clearCache') {
|
||||
el.innerHTML = `<span class="iconify" data-icon="${ICONS.trash}"></span> ${i18n[lang][key]}`;
|
||||
} else if (key === 'copyUrlsClearCache' && el.id === 'copy-to-clear-cache') {
|
||||
el.innerHTML = `<span class="iconify" data-icon="${ICONS.copyAndOpen}"></span> ${i18n[lang][key]}`;
|
||||
} else if (key === 'installCmdLabel') {
|
||||
el.innerHTML = `<span class="iconify mr-2 text-blue-500" data-icon="ph:terminal-window-bold"></span>${i18n[lang][key]}`;
|
||||
}
|
||||
else {
|
||||
el.innerHTML = i18n[lang][key];
|
||||
}
|
||||
}
|
||||
});
|
||||
localStorage.setItem("lang", lang); // Save language preference
|
||||
}
|
||||
|
||||
// Initialize language based on saved preference or browser language
|
||||
function initLanguage() {
|
||||
let savedLang = localStorage.getItem("lang");
|
||||
if (!savedLang) {
|
||||
// Auto-detect Chinese language, default to English
|
||||
savedLang = navigator.language.startsWith("zh") ? "zh" : "en";
|
||||
}
|
||||
document.getElementById("lang-switcher").value = savedLang;
|
||||
setLanguage(savedLang);
|
||||
}
|
||||
|
||||
// Language switcher event listener
|
||||
document.getElementById("lang-switcher").addEventListener("change", e => {
|
||||
setLanguage(e.target.value);
|
||||
});
|
||||
|
||||
// Theme toggle functionality
|
||||
const themeBtn = document.getElementById("theme-toggle-btn");
|
||||
const htmlEl = document.documentElement;
|
||||
const sunIcon = themeBtn.querySelector('.sun-icon');
|
||||
const moonIcon = themeBtn.querySelector('.moon-icon');
|
||||
|
||||
// Update theme UI icons based on current theme
|
||||
function updateThemeUI() {
|
||||
if (htmlEl.classList.contains('dark')) {
|
||||
sunIcon.classList.remove('hidden');
|
||||
moonIcon.classList.add('hidden');
|
||||
} else {
|
||||
sunIcon.classList.add('hidden');
|
||||
moonIcon.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize theme based on saved preference or system preference
|
||||
function initializeTheme() {
|
||||
const savedTheme = localStorage.getItem("theme");
|
||||
if (savedTheme) {
|
||||
htmlEl.classList.toggle("dark", savedTheme === "dark");
|
||||
} else {
|
||||
// Use system preference if no saved theme
|
||||
htmlEl.classList.toggle("dark", window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
}
|
||||
updateThemeUI();
|
||||
}
|
||||
|
||||
// Theme toggle button event listener
|
||||
themeBtn.addEventListener("click", () => {
|
||||
htmlEl.classList.toggle("dark");
|
||||
localStorage.setItem("theme", htmlEl.classList.contains("dark") ? "dark" : "light");
|
||||
updateThemeUI();
|
||||
});
|
||||
|
||||
// Initialize theme and language
|
||||
initializeTheme();
|
||||
initLanguage();
|
||||
|
||||
// Fetch latest version numbers from MikroTik servers
|
||||
const loadingOverlay = document.getElementById("loading");
|
||||
const [routeros7_stable, routeros7_testing, routeros6_longterm, routeros6_stable] = await Promise.all([
|
||||
fetch_latest_versions(`https://upgrade.mikrotik.ltd/routeros/NEWESTa7.stable?ts=${Date.now()}`, "7.19.4"),
|
||||
fetch_latest_versions(`https://upgrade.mikrotik.ltd/routeros/NEWESTa7.testing?ts=${Date.now()}`, "7.20rc1"),
|
||||
fetch_latest_versions(`https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term?ts=${Date.now()}`, "6.49.18"),
|
||||
fetch_latest_versions(`https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable?ts=${Date.now()}`, "6.49.19"),
|
||||
]);
|
||||
// Hide loading overlay and remove loading class
|
||||
loadingOverlay.style.display = "none";
|
||||
document.body.classList.remove('loading');
|
||||
|
||||
// Download sections configuration with versions and file types
|
||||
const downloads =[
|
||||
{
|
||||
title:"RouterOS v7",
|
||||
versions:[ { title:"Stable", version:routeros7_stable }, { title:"Testing", version:routeros7_testing } ],
|
||||
groups: [
|
||||
{ title:"ARM64 / AMPERE", arch:"arm64", downloads:[ { title:"Main package", type:"main" }, { title:"Extra packages", type:"extra" }, { title:"ISO image for AMPERE", type:"iso" } ] },
|
||||
{ title:"X86", arch:"x86", downloads:[ { title:"Main package", type:"main" }, { title:"Extra packages", type:"extra" }, { title:"CD Image", type:"iso" }, { title:"Install image", type:"install" } ] },
|
||||
{ title:"GENERAL", arch:"general", downloads:[ { title:"Netinstall (Windows)", type:"netinstall_windows" }, { title:"Netinstall (CLI Linux)", type:"netinstall_linux_cli" }, { title:"Changelog", type:"changlog" } ] }
|
||||
]
|
||||
},
|
||||
{
|
||||
title:"RouterOS v6",
|
||||
versions:[ { title:"Long-Term", version:routeros6_longterm }, { title:"Stable", version:routeros6_stable } ],
|
||||
groups: [
|
||||
{ title:"X86", arch:"x86", downloads:[ { title:"Extra packages", type:"extra" }, { title:"CD Image", type:"iso" }, { title:"Install image", type:"install" }, { title:"Changelog", type:"changlog" } ] }
|
||||
]
|
||||
},
|
||||
{
|
||||
title:"Cloud Hosted Router",
|
||||
versions:[ { title:"Long-Term", version:routeros6_longterm }, { title:"Stable", version:routeros6_stable }, { title:"Stable", version:routeros7_stable }, { title:"Testing", version:routeros7_testing } ],
|
||||
groups:[
|
||||
{ title:"X86", arch:"x86", downloads:[ { title:"Main package", type:"main" }, { title:"Extra packages", type:"extra" }, { title:"VHDX image", type:"vhdx" }, { title:"VMDK image", type:"vmdk" }, { title:"VDI image", type:"vdi" }, { title:"VirtualPC image", type:"vhd" }, { title:"Raw disk image", type:"img" }, { title:"OVA template", type:"ova" } ] },
|
||||
{ title:"ARM64 / AMPERE", arch:"arm64", downloads:[ { title:"Main package", type:"main" }, { title:"Extra packages", type:"extra" }, { title:"VHDX image", type:"vhdx" }, { title:"VMDK image", type:"vmdk" }, { title:"VDI image", type:"vdi" }, { title:"VirtualPC image", type:"vhd" }, { title:"Raw disk image", type:"img" } ] }
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
// Function to generate file names based on version, architecture, and type
|
||||
const fileNames = (version, arch, type) => {
|
||||
const files = [];
|
||||
// RouterOS v6 only supports x86 architecture
|
||||
if (version.charAt(0) === "6" && arch !== "x86") return files;
|
||||
// Main package for RouterOS v7
|
||||
if (type === "main" && version.charAt(0) === "7") files.push(`routeros-${version}${arch === "x86" ? "" : "-" + arch}.npk`);
|
||||
// ISO images
|
||||
if (type === "iso") files.push(`mikrotik-${version}${arch === "x86" ? "" : "-" + arch}.iso`);
|
||||
// Extra packages
|
||||
if (type === "extra") files.push(`all_packages-${arch}-${version}.zip`);
|
||||
// Install images
|
||||
if (type === "install") files.push(`install-image-${version}${arch === "x86" ? "" : "-" + arch}.zip`);
|
||||
// Virtual machine images
|
||||
if (type in { vhdx: 1, vmdk: 1, vdi: 1, vhd: 1, img: 1 }) {
|
||||
files.push(`chr-${version}${arch === "x86" ? "" : "-" + arch}.${type}.zip`);
|
||||
// Add legacy BIOS version for x86 RouterOS v7
|
||||
if (arch === "x86" && version.charAt(0) !== "6") files.push(`chr-${version}-legacy-bios.${type}.zip`);
|
||||
}
|
||||
// OVA templates (RouterOS v7 only)
|
||||
if (type === "ova" && version.charAt(0) !== "6") {
|
||||
files.push(`chr-${version}${arch === "x86" ? "" : "-" + arch}.${type}.zip`);
|
||||
if (arch === "x86") files.push(`chr-${version}-legacy-bios.${type}.zip`);
|
||||
}
|
||||
// Netinstall packages
|
||||
if (type === "netinstall_windows") files.push(`netinstall-${version}.zip`);
|
||||
if (type === "netinstall_linux_cli") files.push(`netinstall-${version}.tar.gz`);
|
||||
return files;
|
||||
};
|
||||
|
||||
// Generate base URL for downloads with optional GitHub proxy
|
||||
const baseUrl = (version, arch) => `${localStorage.getItem("gh-proxy-enabled") === "true" ? "https://gh-proxy.com/" : ""}https://github.com/elseif/MikroTikPatch/releases/download/${version}${arch === "x86" || arch === "general" ? "" : "-" + arch}/`;
|
||||
|
||||
// Clear and populate download sections
|
||||
const container = document.getElementById("download-rows");
|
||||
container.innerHTML = '';
|
||||
|
||||
// Generate download sections dynamically
|
||||
downloads.forEach((download, index) => {
|
||||
const accordion = document.createElement("details");
|
||||
accordion.className = "bg-white/60 dark:bg-gray-800/60 rounded-2xl shadow-lg ring-1 ring-black/5 backdrop-blur-xl overflow-hidden group";
|
||||
accordion.open = index === 0; // Open first section by default
|
||||
|
||||
const summary = document.createElement("summary");
|
||||
summary.className = "p-6 cursor-pointer text-xl font-bold text-slate-800 dark:text-white flex justify-between items-center";
|
||||
summary.innerHTML = `<span>${download.title}</span><span class="iconify text-2xl transition-transform duration-300 group-open:rotate-180" data-icon="ph:caret-down-bold"></span>`;
|
||||
|
||||
const content = document.createElement("div");
|
||||
content.className = "px-6 pb-6";
|
||||
|
||||
const table = document.createElement("div");
|
||||
table.className = "overflow-x-auto";
|
||||
table.innerHTML = `
|
||||
<table class="w-full min-w-max text-sm text-left text-slate-500 dark:text-slate-400">
|
||||
<thead class="text-xs text-slate-700 dark:text-slate-200 uppercase bg-slate-50/80 dark:bg-gray-700/80">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 rounded-l-lg">Package / Architecture</th>
|
||||
${download.versions.map(v => `<th scope="col" class="px-6 py-3 text-center">${v.version}<br><span class="font-normal normal-case">${v.title}</span></th>`).join("")}
|
||||
<th class="rounded-r-lg"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${download.groups.map(g => `
|
||||
<tr class="bg-slate-100/80 dark:bg-gray-700/50">
|
||||
<th colspan="${download.versions.length + 2}" class="px-6 py-2 text-base font-semibold text-slate-800 dark:text-white">${g.title}</th>
|
||||
</tr>
|
||||
${g.downloads.map(d => `
|
||||
<tr class="bg-transparent border-b last:border-b-0 border-slate-200 dark:border-gray-700 hover:bg-slate-50/50 dark:hover:bg-gray-800/50 transition-colors">
|
||||
<td class="px-6 py-4 font-medium text-slate-900 dark:text-white whitespace-nowrap">${d.title}</td>
|
||||
${download.versions.map(v => {
|
||||
if (d.type === "changlog") {
|
||||
return `<td class="px-6 py-4 text-center"><button onclick="showChangelog('${v.version}')" class="inline-flex items-center gap-1.5 text-blue-500 dark:text-blue-400 hover:underline cursor-pointer" title="Changelog"><span class="iconify" data-icon="${ICONS.changelog}"></span> View</button></td>`;
|
||||
}
|
||||
const files = fileNames(v.version, g.arch, d.type);
|
||||
if (!files || files.length === 0) return `<td class="px-6 py-4"></td>`;
|
||||
const links = files.map(file => {
|
||||
const url = `${baseUrl(v.version, g.arch)}${file}`;
|
||||
let label = "Download";
|
||||
if (download.title === "Cloud Hosted Router" && file.includes('chr')) {
|
||||
if (v.version.charAt(0) === "6" ){
|
||||
label = "Legacy";
|
||||
} else {
|
||||
label = file.includes("legacy-bios") ? "Legacy" : "UEFI";
|
||||
}
|
||||
}
|
||||
return `<a href="${url}" class="inline-flex items-center gap-1.5 text-blue-500 dark:text-blue-400 hover:underline" title="${file}" target="_blank"><span class="iconify" data-icon="${ICONS.download}"></span> ${label}</a>`;
|
||||
}).join("");
|
||||
return `<td class="px-6 py-4 text-center space-x-2">${links}</td>`;
|
||||
}).join("")}
|
||||
<td></td>
|
||||
</tr>
|
||||
`).join("")}
|
||||
`).join("")}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
|
||||
content.appendChild(table);
|
||||
accordion.appendChild(summary);
|
||||
accordion.appendChild(content);
|
||||
container.appendChild(accordion);
|
||||
});
|
||||
|
||||
// GitHub proxy functionality
|
||||
const ghProxyCheckbox = document.getElementById("gh-proxy");
|
||||
const clearCacheBtn = document.getElementById("clear-cache");
|
||||
if (localStorage.getItem("gh-proxy-enabled") === null && navigator.language.startsWith("zh")) {
|
||||
// Enable GitHub proxy by default for Chinese users
|
||||
localStorage.setItem("gh-proxy-enabled", "true");
|
||||
}
|
||||
ghProxyCheckbox.checked = localStorage.getItem("gh-proxy-enabled") === "true";
|
||||
clearCacheBtn.style.display = ghProxyCheckbox.checked ? "inline-flex" : "none";
|
||||
|
||||
// Update all download links with/without GitHub proxy
|
||||
function updateAllDownloadLinks() {
|
||||
// Only apply proxy to download links (releases/download), not to other GitHub links
|
||||
document.querySelectorAll('a[href*="github.com/elseif/MikroTikPatch/releases/download"]').forEach(link => {
|
||||
const isProxyEnabled = localStorage.getItem("gh-proxy-enabled") === "true";
|
||||
const hasProxy = link.href.includes('gh-proxy.com');
|
||||
if (isProxyEnabled && !hasProxy) {
|
||||
link.href = link.href.replace("https://github.com/", "https://gh-proxy.com/https://github.com/");
|
||||
} else if (!isProxyEnabled && hasProxy) {
|
||||
link.href = link.href.replace("https://gh-proxy.com/", "");
|
||||
}
|
||||
});
|
||||
// Update command display if a version is selected
|
||||
const activeBtn = document.querySelector("#version-buttons button.active");
|
||||
activeBtn ? updateCommand(activeBtn.dataset.version) : updateCommand();
|
||||
}
|
||||
|
||||
// GitHub proxy toggle event listener
|
||||
ghProxyCheckbox.addEventListener("change", () => {
|
||||
localStorage.setItem("gh-proxy-enabled", ghProxyCheckbox.checked ? "true" : "false");
|
||||
clearCacheBtn.style.display = ghProxyCheckbox.checked ? "inline-flex" : "none";
|
||||
updateAllDownloadLinks();
|
||||
});
|
||||
|
||||
// Cache clearing modal functionality
|
||||
const modal = document.getElementById("urls-pannel");
|
||||
const modalContent = document.getElementById("modal-content");
|
||||
clearCacheBtn.addEventListener("click", () => {
|
||||
const links = document.querySelectorAll('a[href^="https://gh-proxy.com/https://github.com/elseif/MikroTikPatch/"]');
|
||||
document.getElementById("urls-list").innerText = Array.from(links).map(a => a.href).filter(href => !href.includes(".yml")).join("\n");
|
||||
modal.classList.remove('hidden');
|
||||
setTimeout(() => { modalContent.classList.add('opacity-100', 'scale-100'); modalContent.classList.remove('opacity-0', 'scale-95'); }, 10);
|
||||
});
|
||||
|
||||
// Modal close functionality
|
||||
document.getElementById("urls-close").addEventListener("click", () => {
|
||||
modalContent.classList.remove('opacity-100', 'scale-100');
|
||||
modalContent.classList.add('opacity-0', 'scale-95');
|
||||
setTimeout(() => modal.classList.add('hidden'), 200);
|
||||
});
|
||||
|
||||
// Copy URLs and open cache clearing page
|
||||
document.getElementById("copy-to-clear-cache").addEventListener("click", () => {
|
||||
navigator.clipboard.writeText(document.getElementById("urls-list").innerText);
|
||||
window.open("https://cache.gh-proxy.com/", "_blank");
|
||||
document.getElementById("urls-close").click();
|
||||
});
|
||||
|
||||
// Changelog modal functionality
|
||||
const changelogModal = document.getElementById("changelog-modal");
|
||||
const changelogModalContent = document.getElementById("changelog-modal-content");
|
||||
const changelogContent = document.getElementById("changelog-content");
|
||||
const changelogClose = document.getElementById("changelog-close");
|
||||
|
||||
// Fetch changelog content from MikroTik servers
|
||||
async function fetchChangelog(version) {
|
||||
try {
|
||||
const response = await fetch(`https://upgrade.mikrotik.ltd/routeros/${version}/CHANGELOG`);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const text = await response.text();
|
||||
return text;
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch changelog:", error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Global function to show changelog modal
|
||||
window.showChangelog = function(version) {
|
||||
changelogModal.classList.remove('hidden');
|
||||
changelogContent.innerHTML = `
|
||||
<div class="flex items-center justify-center py-8">
|
||||
<span class="iconify text-4xl text-blue-600 animate-spin" data-icon="ph:spinner-gap-bold"></span>
|
||||
<span class="ml-4 text-lg font-medium" data-i18n="loadingChangelog"></span>
|
||||
</div>
|
||||
`;
|
||||
setLanguage(document.getElementById("lang-switcher").value);
|
||||
|
||||
setTimeout(() => {
|
||||
changelogModalContent.classList.add('opacity-100', 'scale-100');
|
||||
changelogModalContent.classList.remove('opacity-0', 'scale-95');
|
||||
}, 10);
|
||||
|
||||
// Fetch and display changelog content
|
||||
fetchChangelog(version).then(content => {
|
||||
if (content) {
|
||||
changelogContent.innerHTML = `
|
||||
<div class="prose prose-slate dark:prose-invert max-w-none">
|
||||
<pre class="whitespace-pre-wrap text-sm leading-relaxed">${content}</pre>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
// Show error state with retry button
|
||||
changelogContent.innerHTML = `
|
||||
<div class="flex flex-col items-center justify-center py-8 text-center">
|
||||
<span class="iconify text-6xl text-red-500 mb-4" data-icon="ph:warning-circle-bold"></span>
|
||||
<p class="text-lg font-medium text-slate-700 dark:text-slate-300 mb-2" data-i18n="changelogError"></p>
|
||||
<button onclick="showChangelog('${version}')" class="mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors">
|
||||
<span class="iconify mr-2" data-icon="ph:arrow-clockwise-bold"></span>
|
||||
Retry
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
setLanguage(document.getElementById("lang-switcher").value);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Hide changelog modal with animation
|
||||
function hideChangelog() {
|
||||
changelogModalContent.classList.remove('opacity-100', 'scale-100');
|
||||
changelogModalContent.classList.add('opacity-0', 'scale-95');
|
||||
setTimeout(() => changelogModal.classList.add('hidden'), 200);
|
||||
}
|
||||
|
||||
changelogClose.addEventListener("click", hideChangelog);
|
||||
|
||||
// Close modal when clicking outside
|
||||
changelogModal.addEventListener("click", (e) => {
|
||||
if (e.target === changelogModal) {
|
||||
hideChangelog();
|
||||
}
|
||||
});
|
||||
|
||||
// Close modal with Escape key
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape" && !changelogModal.classList.contains("hidden")) {
|
||||
hideChangelog();
|
||||
}
|
||||
});
|
||||
|
||||
// Command generation and version selection
|
||||
const versionBtnsContainer = document.getElementById("version-buttons");
|
||||
const commandDiv = document.getElementById("command");
|
||||
const copyBtn = document.getElementById("copy-btn");
|
||||
|
||||
// Generate version selection buttons
|
||||
versionBtnsContainer.innerHTML = `
|
||||
<button data-version="${routeros7_stable}" class="px-3 py-1.5 text-sm font-medium rounded-md hover:bg-blue-200 dark:hover:bg-gray-600 transition-all">v7 Stable</button>
|
||||
<button data-version="${routeros7_testing}" class="px-3 py-1.5 text-sm font-medium rounded-md hover:bg-blue-200 dark:hover:bg-gray-600 transition-all">v7 Testing</button>
|
||||
<button data-version="${routeros6_longterm}" class="px-3 py-1.5 text-sm font-medium rounded-md hover:bg-blue-200 dark:hover:bg-gray-600 transition-all">v6 Long-Term</button>
|
||||
<button data-version="${routeros6_stable}" class="px-3 py-1.5 text-sm font-medium rounded-md hover:bg-blue-200 dark:hover:bg-gray-600 transition-all">v6 Stable</button>
|
||||
`;
|
||||
|
||||
// Update command display based on selected tool and version
|
||||
function updateCommand(version) {
|
||||
const tool = document.querySelector('input[name="tool"]:checked').value;
|
||||
const _version = version===undefined?"": `<span class="text-green-500 font-semibold">VERSION</span>=<span class="text-yellow-400">${version}</span> `
|
||||
const cmd = tool === "curl"
|
||||
? `<pre class="text-slate-300"><code>${_version}<span class="text-blue-400 font-bold">bash</span> <span class="text-pink-400"><(</span><span class="text-blue-400 font-bold">curl</span> <span class="text-teal-400">https://mikrotik.ltd/chr.sh</span><span class="text-pink-400">)</span></code></pre>`
|
||||
: `<pre class="text-slate-300"><code>${_version}<span class="text-blue-400 font-bold">bash</span> <span class="text-pink-400"><(</span><span class="text-blue-400 font-bold">wget -O - </span><span class="text-teal-400">https://mikrotik.ltd/chr.sh</span><span class="text-pink-400">)</span></code></pre>`;
|
||||
commandDiv.innerHTML = cmd;
|
||||
}
|
||||
|
||||
// Tool selection event listeners
|
||||
document.querySelectorAll('input[name="tool"]').forEach(radio => {
|
||||
radio.addEventListener("change", () => {
|
||||
const activeBtn = document.querySelector("#version-buttons button.active");
|
||||
activeBtn ? updateCommand(activeBtn.dataset.version) : updateCommand();
|
||||
});
|
||||
});
|
||||
|
||||
// Version button event listeners
|
||||
const buttons = document.querySelectorAll("#version-buttons button");
|
||||
buttons.forEach(btn => {
|
||||
btn.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
if (btn.classList.contains("active")) {
|
||||
updateCommand();
|
||||
btn.classList.remove("active");
|
||||
}else{
|
||||
updateCommand(btn.dataset.version);
|
||||
buttons.forEach(b => b.classList.remove("active"));
|
||||
btn.classList.add("active");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
updateCommand();
|
||||
|
||||
// Copy command to clipboard functionality
|
||||
copyBtn.addEventListener("click", () => {
|
||||
const code = commandDiv.querySelector("code").innerText;
|
||||
navigator.clipboard.writeText(code).then(() => {
|
||||
copyBtn.querySelector('.copy-icon').classList.add('hidden');
|
||||
copyBtn.querySelector('.check-icon').classList.remove('hidden');
|
||||
setTimeout(() => {
|
||||
copyBtn.querySelector('.copy-icon').classList.remove('hidden');
|
||||
copyBtn.querySelector('.check-icon').classList.add('hidden');
|
||||
}, 2000);
|
||||
}).catch(err => console.error("Copy failed:", err));
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
49
npk.py
49
npk.py
@@ -207,6 +207,7 @@ class NovaPackage(Package):
|
||||
self._parts.append(NpkPartItem(NpkPartID(part_id),NpkInfo.unserialize_from(part_data)))
|
||||
else:
|
||||
self._parts.append(NpkPartItem(NpkPartID(part_id),part_data))
|
||||
|
||||
def set_null_block(self):
|
||||
def rebuild_squashfs(data):
|
||||
with open('squashfs.sfs', 'wb') as f:
|
||||
@@ -217,19 +218,20 @@ class NovaPackage(Package):
|
||||
os.system('rm -rf squashfs-root')
|
||||
with open('squashfs.sfs', 'rb') as f:
|
||||
return f.read()
|
||||
|
||||
if len(self._packages) > 0:
|
||||
def get_size(package,size):
|
||||
for part in package._parts:
|
||||
size += 6
|
||||
size += len(part.data)
|
||||
return size
|
||||
|
||||
def set_null(package,offset):
|
||||
has_squashfs = False
|
||||
for package in self._packages:
|
||||
for part in package._parts:
|
||||
if part.id == NpkPartID.SQUASHFS:
|
||||
part.data = rebuild_squashfs(part.data)
|
||||
has_squashfs = True
|
||||
|
||||
if not has_squashfs:
|
||||
return
|
||||
for package in self._packages:
|
||||
count = 8
|
||||
for part in package._parts:
|
||||
if part.id == NpkPartID.SQUASHFS and len(part.data) >= 4 and part.data[:4] in [b'hsqs',b'sqsh']:
|
||||
part.data = rebuild_squashfs(part.data)
|
||||
has_squashfs = True
|
||||
if has_squashfs:
|
||||
count = offset
|
||||
for part in package._parts:
|
||||
count += 6
|
||||
if part.id == NpkPartID.NULL_BLOCK:
|
||||
@@ -239,23 +241,12 @@ class NovaPackage(Package):
|
||||
pad_len = (4096 - (count % 4096)) % 4096
|
||||
package[NpkPartID.NULL_BLOCK].data = b'\x00' * pad_len
|
||||
|
||||
else:
|
||||
has_squashfs = False
|
||||
for part in self._parts:
|
||||
if part.id == NpkPartID.SQUASHFS:
|
||||
part.data = rebuild_squashfs(part.data)
|
||||
has_squashfs = True
|
||||
if not has_squashfs:
|
||||
return
|
||||
count = 8
|
||||
for part in self._parts:
|
||||
count += 6
|
||||
if part.id == NpkPartID.NULL_BLOCK:
|
||||
break
|
||||
count += len(part.data)
|
||||
count += 6
|
||||
pad_len = (4096 - (count % 4096)) % 4096
|
||||
self[NpkPartID.NULL_BLOCK].data = b'\x00' * pad_len
|
||||
set_null(self,8)
|
||||
offset = get_size(self,8)
|
||||
for package in self._packages:
|
||||
set_null(package,offset)
|
||||
offset += get_size(package,0)
|
||||
|
||||
def get_digest(self,hash_fnc,package:Package=None)->bytes:
|
||||
parts = package._parts if package else self._parts
|
||||
for part in parts:
|
||||
|
||||
6
patch.py
6
patch.py
@@ -328,6 +328,12 @@ def patch_squashfs(path,key_dict):
|
||||
if _file =='loader':
|
||||
patch_loader(file)
|
||||
continue
|
||||
if _file =='BOOTX64.EFI':
|
||||
print(f'patch {file} ...')
|
||||
data = open(file,'rb').read()
|
||||
data = patch_kernel(data,key_dict)
|
||||
open(file,'wb').write(data)
|
||||
continue
|
||||
data = open(file,'rb').read()
|
||||
for old_public_key,new_public_key in key_dict.items():
|
||||
_data = replace_key(old_public_key,new_public_key,data,file)
|
||||
|
||||
Reference in New Issue
Block a user