2024-06-15 02:18:14 +03:00
|
|
|
name: Patch Mikrotik RouterOS
|
|
|
|
on:
|
|
|
|
# push:
|
|
|
|
# branches: [ "main" ]
|
|
|
|
schedule:
|
|
|
|
- cron: "0 0 * * *"
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
|
|
|
|
jobs:
|
2024-06-16 00:04:10 +03:00
|
|
|
Create_SquashFS:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
TZ: 'Asia/Shanghai'
|
|
|
|
steps:
|
|
|
|
- name: Create squashfs for option npk
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
sudo wget -O bash -nv https://busybox.net/downloads/binaries/1.31.0-i686-uclibc/busybox_ASH
|
|
|
|
sudo wget -O busybox -nv https://busybox.net/downloads/binaries/1.31.0-i686-uclibc/busybox
|
|
|
|
sudo chmod +x busybox
|
|
|
|
sudo chmod +x bash
|
|
|
|
sudo mkdir -p ./option-root/bin/
|
|
|
|
sudo mv busybox ./option-root/bin/
|
|
|
|
sudo mv bash ./option-root/bin/
|
|
|
|
COMMANDS=$(./option-root/bin/busybox --list)
|
|
|
|
for cmd in $COMMANDS; do
|
|
|
|
sudo ln -sf /pckg/option/bin/busybox ./option-root/bin/$cmd
|
|
|
|
done
|
|
|
|
sudo rm -f option.sfs
|
|
|
|
sudo mksquashfs option-root option.sfs -quiet -comp xz -no-xattrs -b 256k
|
|
|
|
sudo rm -rf option-root
|
|
|
|
|
2024-06-16 01:13:29 +03:00
|
|
|
# - name: Create squashfs for python3 npk
|
|
|
|
# run: |
|
|
|
|
# wget -nv https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz
|
|
|
|
# tar -xf Python-3.11.9.tar.xz
|
|
|
|
# rm -f Python-3.11.9.tar.xz
|
|
|
|
# sudo mkdir -p /pckg/python3/
|
|
|
|
# cd Python-3.11.9
|
|
|
|
# sudo apt install -y pkg-config libffi-dev uuid-dev libbz2-dev liblzma-dev libssl-dev libgd-dev libreadline-dev zlib1g-dev libgdbm-dev libexpat1-dev libncursesw5-dev
|
|
|
|
# ./configure --enable-optimizations --prefix=/pckg/python3/ --disable-test-modules --without-static-libpython CONFIGURE_LDFLAGS="-static" CONFIGURE_LDFLAGS_NODIST="-static" PY_LDFLAGS_NODIST="-static"
|
|
|
|
# make -j$(nproc)
|
|
|
|
# sudo make altinstall
|
|
|
|
# cd ..
|
|
|
|
# sudo rm -rf Python-3.11.9
|
|
|
|
# sudo rm -rf /pckg/python3/include
|
|
|
|
# sudo rm -rf /pckg/python3/share
|
|
|
|
# sudo mksquashfs /pckg/python3 python3.sfs -quiet -comp xz -no-xattrs -b 256k
|
|
|
|
# sudo rm -rf /pckg
|
2024-06-16 00:04:10 +03:00
|
|
|
|
|
|
|
- name: Upload Artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
retention-days: 1
|
|
|
|
name: squashfs
|
|
|
|
path: |
|
2024-06-16 01:13:29 +03:00
|
|
|
./*.sfs
|
2024-06-16 00:04:10 +03:00
|
|
|
|
2024-06-16 00:09:32 +03:00
|
|
|
Patch_RouterOS:
|
2024-06-15 02:18:14 +03:00
|
|
|
runs-on: ubuntu-latest
|
2024-06-16 00:04:10 +03:00
|
|
|
needs: Create_SquashFS
|
2024-06-15 02:18:14 +03:00
|
|
|
env:
|
|
|
|
TZ: 'Asia/Shanghai'
|
|
|
|
LATEST_STABLE_VERSION_URL: 'https://upgrade.mikrotik.com/routeros/NEWESTa7.stable'
|
|
|
|
LATEST_VERSION: "7.15"
|
|
|
|
CUSTOM_LICENSE_PRIVATE_KEY: ${{ secrets.CUSTOM_LICENSE_PRIVATE_KEY }}
|
|
|
|
CUSTOM_LICENSE_PUBLIC_KEY: ${{ secrets.CUSTOM_LICENSE_PUBLIC_KEY }}
|
|
|
|
CUSTOM_NPK_SIGN_PRIVATE_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PRIVATE_KEY }}
|
|
|
|
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
|
|
|
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
|
|
|
MIKRO_NPK_SIGN_PUBLIC_LKEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_LKEY }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v5
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
2024-06-16 00:04:10 +03:00
|
|
|
|
|
|
|
- name: Download Artifact
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: squashfs
|
|
|
|
|
2024-06-15 02:18:14 +03:00
|
|
|
- name: Get latest routeros stable version
|
|
|
|
run: |
|
|
|
|
echo $(uname -a)
|
|
|
|
LATEST_VERSION=$(wget -nv -O - $LATEST_STABLE_VERSION_URL | cut -d ' ' -f1)
|
|
|
|
echo Latest Stabel Version:$LATEST_VERSION
|
|
|
|
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Create keygen
|
|
|
|
run: |
|
|
|
|
zip keygen.zip ./keygen.exe
|
2024-06-15 22:15:54 +03:00
|
|
|
|
2024-06-15 02:18:14 +03:00
|
|
|
- name: Get mikrotik-${{ env.LATEST_VERSION }}.iso
|
2024-06-15 18:04:46 +03:00
|
|
|
run: |
|
|
|
|
sudo wget -nv -O mikrotik-$LATEST_VERSION.iso https://download.mikrotik.com/routeros/$LATEST_VERSION/mikrotik-$LATEST_VERSION.iso
|
|
|
|
|
2024-06-15 02:18:14 +03:00
|
|
|
- name: Patch mikrotik-${{ env.LATEST_VERSION }}.iso
|
|
|
|
run: |
|
|
|
|
sudo apt-get install -y mkisofs > /dev/null
|
|
|
|
sudo mkdir ./iso
|
|
|
|
sudo mount -o loop,ro mikrotik-$LATEST_VERSION.iso ./iso
|
|
|
|
sudo mkdir ./new_iso
|
|
|
|
sudo cp -r ./iso/* ./new_iso/
|
|
|
|
sudo rsync -a ./iso/ ./new_iso/
|
|
|
|
sudo umount ./iso
|
|
|
|
sudo rm -rf ./iso
|
|
|
|
sudo rm -f mikrotik-$LATEST_VERSION.iso
|
2024-06-15 18:10:23 +03:00
|
|
|
sudo mv ./new_iso/routeros-$LATEST_VERSION.npk ./
|
|
|
|
sudo -E python3 patch.py routeros-$LATEST_VERSION.npk
|
2024-06-15 11:59:02 +03:00
|
|
|
sudo cp keygen.exe ./new_iso/
|
2024-06-15 02:18:14 +03:00
|
|
|
NPK_FILES=$(find ./new_iso/*.npk)
|
|
|
|
for file in $NPK_FILES; do
|
|
|
|
sudo -E python3 npk.py sign $file $file
|
|
|
|
done
|
|
|
|
sudo cp routeros-$LATEST_VERSION.npk ./new_iso/
|
2024-06-15 22:16:11 +03:00
|
|
|
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION.npk ./option-$LATEST_VERSION.npk option ./option.sfs -desc="busybox and ash"
|
2024-06-15 02:18:14 +03:00
|
|
|
sudo cp option-$LATEST_VERSION.npk ./new_iso/
|
2024-06-16 01:13:29 +03:00
|
|
|
# sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION.npk ./python3-$LATEST_VERSION.npk python3 ./python3.sfs -desc="python 3.11.9"
|
|
|
|
# sudo cp python3-$LATEST_VERSION.npk ./new_iso/
|
2024-06-15 02:18:14 +03:00
|
|
|
sudo cp linux ./new_iso/isolinux/
|
|
|
|
sudo mkdir ./efiboot
|
|
|
|
sudo mount -o loop ./new_iso/efiboot.img ./efiboot
|
|
|
|
sudo cp linux ./efiboot/linux.x86_64
|
|
|
|
sudo umount ./efiboot
|
|
|
|
sudo rm -rf ./efiboot
|
|
|
|
sudo mkisofs -o mikrotik-$LATEST_VERSION.iso \
|
|
|
|
-V "MikroTik $LATEST_VERSION Patched" \
|
|
|
|
-sysid "" -preparer "MiKroTiK" \
|
|
|
|
-publisher "" -A "MiKroTiK RouterOS" \
|
|
|
|
-b isolinux/isolinux.bin \
|
|
|
|
-c isolinux/boot.cat \
|
|
|
|
-no-emul-boot \
|
|
|
|
-boot-load-size 4 \
|
|
|
|
-boot-info-table \
|
|
|
|
-eltorito-alt-boot \
|
|
|
|
-e efiboot.img \
|
|
|
|
-no-emul-boot \
|
|
|
|
-R \
|
|
|
|
./new_iso
|
|
|
|
sudo rm -rf ./new_iso
|
|
|
|
|
2024-06-15 18:04:46 +03:00
|
|
|
- name: Get install-image-${{ env.LATEST_VERSION }}.img
|
|
|
|
run: |
|
2024-06-15 18:07:33 +03:00
|
|
|
sudo wget -nv -O install-image-$LATEST_VERSION.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/install-image-$LATEST_VERSION.zip
|
2024-06-15 18:04:46 +03:00
|
|
|
|
|
|
|
- name: Patch install-image-${{ env.LATEST_VERSION }}.img
|
|
|
|
run: |
|
|
|
|
sudo unzip install-image-$LATEST_VERSION.zip
|
|
|
|
sudo mkdir ./install
|
|
|
|
sudo mount -o loop install-image-$LATEST_VERSION.img ./install
|
|
|
|
sudo rm install-image-$LATEST_VERSION.zip
|
|
|
|
sudo rm ./install/1.npk
|
|
|
|
NPK_FILES=$(find ./install/*.npk)
|
|
|
|
for file in $NPK_FILES; do
|
|
|
|
sudo -E python3 npk.py sign $file $file
|
|
|
|
done
|
|
|
|
sudo cp routeros-$LATEST_VERSION.npk ./install/1.npk
|
|
|
|
sudo cp keygen.exe ./install/
|
|
|
|
sudo cp option-$LATEST_VERSION.npk ./install/100.npk
|
2024-06-16 01:13:29 +03:00
|
|
|
# sudo cp python3-$LATEST_VERSION.npk ./install/101.npk
|
2024-06-15 18:10:23 +03:00
|
|
|
sudo cp linux ./install/
|
2024-06-15 18:04:46 +03:00
|
|
|
sudo umount ./install
|
|
|
|
sudo rm -rf ./install
|
|
|
|
sudo zip install-image-$LATEST_VERSION.zip ./install-image-$LATEST_VERSION.img
|
|
|
|
|
2024-06-15 02:18:14 +03:00
|
|
|
- name: Delete Release tag ${{ env.LATEST_VERSION }}
|
|
|
|
run: |
|
|
|
|
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.LATEST_VERSION }})
|
|
|
|
RELEASE_ID=$(echo $RELEASE_INFO | jq -r '.id')
|
|
|
|
echo "Release ID: $RELEASE_ID"
|
|
|
|
if [ "$RELEASE_ID" != "null" ]; then
|
|
|
|
curl -X DELETE -H "$HEADER" https://api.github.com/repos/${{ github.repository }}/git/refs/tags/${{ env.LATEST_VERSION }}
|
|
|
|
echo "Tag ${{ env.LATEST_VERSION }} deleted successfully."
|
|
|
|
curl -X DELETE -H "$HEADER" https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
|
|
|
|
echo "Release with tag ${{ env.LATEST_VERSION }} deleted successfully."
|
|
|
|
else
|
|
|
|
echo "Release not found for tag: ${{ env.LATEST_VERSION }})"
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Create Release tag ${{ env.LATEST_VERSION }}
|
|
|
|
uses: softprops/action-gh-release@v2
|
|
|
|
with:
|
|
|
|
name: "MikroTik ${{ env.LATEST_VERSION }}"
|
|
|
|
body: "MikroTik ${{ env.LATEST_VERSION }}"
|
|
|
|
tag_name: ${{ env.LATEST_VERSION }}
|
|
|
|
make_latest: "true"
|
|
|
|
files: |
|
|
|
|
mikrotik-${{ env.LATEST_VERSION }}.iso
|
2024-06-15 18:04:46 +03:00
|
|
|
install-image-${{ env.LATEST_VERSION }}.zip
|
2024-06-15 02:18:14 +03:00
|
|
|
|