├── .github └── workflows │ ├── delete-workflows.yml │ └── multi-arch.yml ├── .gitignore ├── .vscode └── settings.json ├── Dockerfile ├── LICENSE ├── README.md ├── config ├── mini-packages.config ├── normal-packages.config ├── platform.config └── repositories.conf ├── docker-compose-启动第二个.yml ├── docker-compose.yml ├── dockerhub-readme.md ├── files ├── etc │ ├── config │ │ ├── dhcp │ │ └── network │ ├── firewall.user │ ├── opkg │ │ └── distfeeds.conf │ ├── rc.local │ └── uci-defaults │ │ └── 99-init-settings └── root │ ├── .vimrc │ └── .zshrc ├── scripts └── preset-terminal-tools.sh ├── test └── x86_64.sh ├── tutorial.md └── 遇到的报错.md /.github/workflows/delete-workflows.yml: -------------------------------------------------------------------------------- 1 | name: Delete Workflows 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | # schedule: 7 | # - cron: 0 0 * * * 8 | 9 | permissions: 10 | contents: write 11 | 12 | jobs: 13 | del_runs: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Delete Workflow Runs 17 | uses: GitRML/delete-workflow-runs@main 18 | with: 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | retain_days: 3 21 | -------------------------------------------------------------------------------- /.github/workflows/multi-arch.yml: -------------------------------------------------------------------------------- 1 | #================================================= 2 | # https://github.com/P3TERX/Actions-OpenWrt 3 | # Description: Build OpenWrt using GitHub Actions 4 | # Lisence: MIT 5 | # Author: P3TERX 6 | # Blog: https://p3terx.com 7 | #================================================= 8 | 9 | name: Multi-Arch Images 10 | 11 | env: 12 | PREFIX_URL: https://downloads.immortalwrt.org/snapshots/targets 13 | 14 | on: 15 | push: 16 | branches: 17 | - main 18 | 19 | workflow_dispatch: 20 | inputs: 21 | INPUT_TARGET: 22 | description: "Target to build (platform/target/subtarget)" 23 | required: false 24 | default: "all" 25 | schedule: 26 | - cron: '0 0 * * 0' 27 | 28 | jobs: 29 | Config: 30 | name: Generate Config 31 | runs-on: ubuntu-latest 32 | outputs: 33 | TARGETS: ${{ steps.find-targets.outputs.TARGETS }} 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@main 38 | 39 | - name: Find Targets 40 | id: find-targets 41 | env: 42 | INPUT_TARGET: ${{ github.event.inputs.INPUT_TARGET }} 43 | run: | 44 | if [ "$INPUT_TARGET" = "all" ] || [ "$INPUT_TARGET" = "" ]; then 45 | export TARGETS="$(cat config/platform.config)" 46 | else 47 | export TARGETS="$INPUT_TARGET" 48 | fi 49 | JSON='{"config": ["default"], "targets":[' 50 | FIRST=1 51 | for TARGET in $TARGETS; do 52 | [[ $FIRST -ne 1 ]] && JSON="$JSON"',' 53 | JSON="$JSON"'"'"${TARGET}"'"' 54 | FIRST=0 55 | done 56 | JSON="$JSON"']}' 57 | echo $JSON 58 | echo "::set-output name=TARGETS::$JSON" 59 | 60 | Docker-Images: 61 | name: ${{ matrix.TARGETS }} 62 | needs: [Config] 63 | runs-on: ubuntu-latest 64 | strategy: 65 | fail-fast: false 66 | matrix: ${{fromJson(needs.Config.outputs.TARGETS)}} 67 | 68 | steps: 69 | - name: Checkout 70 | uses: actions/checkout@main 71 | 72 | - name: Initialization Environment 73 | env: 74 | DEBIAN_FRONTEND: noninteractive 75 | run: | 76 | sudo -E apt-get -qq update 77 | sudo -E apt-get -qq install build-essential libncurses5-dev libncursesw5-dev \ 78 | zlib1g-dev gawk git gettext libssl-dev xsltproc rsync wget unzip python3 qemu-utils 79 | 80 | - name: Set Up QEMU 81 | uses: docker/setup-qemu-action@v1 82 | 83 | - name: Set Up Docker Buildx 84 | uses: docker/setup-buildx-action@v1 85 | - name: Login To DockerHub 86 | uses: docker/login-action@v1 87 | with: 88 | username: ${{ secrets.DOCKERHUB_USERNAME }} 89 | password: ${{ secrets.DOCKERHUB_PWD }} 90 | 91 | - name: Login To GHCR 92 | uses: docker/login-action@v3 93 | with: 94 | registry: ghcr.io 95 | username: ${{ github.actor }} 96 | password: ${{ secrets.GITHUB_TOKEN }} 97 | 98 | # - name: Login To Alibaba Cloud Container Registry 99 | # run: | 100 | # docker login -u ${{ secrets.ALIYUN_USERNAME }} -p ${{ secrets.ALIYUN_PWD }} registry.cn-shanghai.aliyuncs.com 101 | # DOCKER_IMAGE_ARCH可以设置QEMU和buildX的编译环境 102 | - name: Generate Variables 103 | id: env 104 | run: | 105 | export DEVICE_PLATFORM=$(echo ${{ matrix.TARGETS }} | awk -F '/' '{print $1}') 106 | echo "DEVICE_PLATFORM=$DEVICE_PLATFORM" >> $GITHUB_ENV 107 | export DEVICE_TARGET=$(echo ${{ matrix.TARGETS }} | awk -F '/' '{print $2}') 108 | echo "DEVICE_TARGET=$DEVICE_TARGET" >> $GITHUB_ENV 109 | export DEVICE_SUBTARGET=$(echo ${{ matrix.TARGETS }} | awk -F '/' '{print $3}') 110 | echo "DEVICE_SUBTARGET=$DEVICE_SUBTARGET" >> $GITHUB_ENV 111 | export DOCKER_IMAGE_ARCH=$(echo ${{ matrix.TARGETS }} | awk -F '/' '{print $4}' | sed 's/-/\//g') 112 | echo "DOCKER_IMAGE_ARCH=$DOCKER_IMAGE_ARCH" >> $GITHUB_ENV 113 | export DOCKER_EXTERA_TAG=$(echo ${{ matrix.TARGETS }} | awk -F '/' '{print $5}') 114 | echo "DOCKER_EXTERA_TAG=$DOCKER_EXTERA_TAG" >> $GITHUB_ENV 115 | 116 | - name: Download Image Builder 117 | run: | 118 | wget -q $PREFIX_URL/$DEVICE_TARGET/$DEVICE_SUBTARGET/immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64.tar.zst 119 | # example: https://downloads.immortalwrt.org/snapshots/targets/x86/64/immortalwrt-imagebuilder-x86-64.Linux-x86_64.tar.zst 120 | 121 | - name: Set Mini Image Builder 122 | run: | 123 | tar -I zstd -xf *.tar.zst 124 | cd immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 125 | cp -rf $GITHUB_WORKSPACE/files . 126 | chmod +x files/etc/rc.local 127 | export KERNEL_VERSION="$(ls packages | grep kernel | awk -F '_' '{print $2}')" 128 | sed -i "s/DEVICE_SUBTARGET/$DEVICE_SUBTARGET/g; \ 129 | s/DEVICE_TARGET/$DEVICE_TARGET/g; \ 130 | s/KERNEL_VERSION/$KERNEL_VERSION/g; \ 131 | s/DEVICE_PLATFORM/$DEVICE_PLATFORM/g" files/etc/opkg/distfeeds.conf 132 | # cat repositories.conf > files/etc/opkg/distfeeds.conf 133 | sed -i '/^src imagebuilder file:packages$/d' files/etc/opkg/distfeeds.conf || true 134 | sed -i '/^option check_signature$/d' files/etc/opkg/distfeeds.conf || true 135 | 136 | - name: Build Mini RootFS 137 | run: | 138 | cd immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 139 | sed -i '/^CONFIG_ISO_IMAGES=y$/d' .config || true 140 | sed -i '/# CONFIG_TARGET_ROOTFS_TARGZ is not set/s/.*/CONFIG_TARGET_ROOTFS_TARGZ=y/' .config 141 | sed -i "/CONFIG_TARGET_ROOTFS_SQUASHFS/s/.*/# CONFIG_TARGET_ROOTFS_SQUASHFS is not set/; 142 | /CONFIG_TARGET_ROOTFS_EXT4FS/s/.*/# CONFIG_TARGET_ROOTFS_EXT4FS is not set/" .config 143 | export CONFIG_MINI_PACKAGES=$(cat $GITHUB_WORKSPACE/config/mini-packages.config | tr -s "\n" " ") 144 | make image PACKAGES="$CONFIG_MINI_PACKAGES -ipv6helper" FILES="files" V=s 145 | ls -lR bin/targets/ 146 | cp bin/targets/$DEVICE_TARGET/$DEVICE_SUBTARGET/*rootfs.tar.gz $GITHUB_WORKSPACE 147 | cd $GITHUB_WORKSPACE 148 | rm -rf immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 149 | 150 | - name: Build & Push Mini Image (Default) 151 | if: env.DOCKER_EXTERA_TAG == null 152 | uses: docker/build-push-action@v2 153 | with: 154 | platforms: ${{ env.DOCKER_IMAGE_ARCH }} 155 | file: Dockerfile 156 | context: . 157 | push: true 158 | tags: | 159 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt-mini:${{ env.DEVICE_PLATFORM }} 160 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt-mini:${{ env.DEVICE_PLATFORM }} 161 | - name: Build & Push Mini Image (Extra Tag) 162 | if: env.DOCKER_EXTERA_TAG != null 163 | uses: docker/build-push-action@v2 164 | with: 165 | platforms: ${{ env.DOCKER_IMAGE_ARCH }} 166 | file: Dockerfile 167 | context: . 168 | push: true 169 | tags: | 170 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt-mini:${{ env.DEVICE_PLATFORM }} 171 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt-mini:${{ env.DOCKER_EXTERA_TAG }} 172 | ghcr.io/${{ github.actor }}/openwrt-mini:${{ env.DEVICE_PLATFORM }} 173 | ghcr.io/${{ github.actor }}/openwrt-mini:${{ env.DOCKER_EXTERA_TAG }} 174 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt-mini:${{ env.DEVICE_PLATFORM }} 175 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt-mini:${{ env.DOCKER_EXTERA_TAG }} 176 | 177 | - name: Set Normal Image Builder 178 | run: | 179 | tar -I zstd -xf *.tar.zst 180 | cd immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 181 | cp -rf $GITHUB_WORKSPACE/files . 182 | chmod +x files/etc/rc.local 183 | export KERNEL_VERSION="$(ls packages | grep kernel | awk -F '_' '{print $2}')" 184 | sed -i "s/DEVICE_SUBTARGET/$DEVICE_SUBTARGET/g; \ 185 | s/DEVICE_TARGET/$DEVICE_TARGET/g; \ 186 | s/KERNEL_VERSION/$KERNEL_VERSION/g; \ 187 | s/DEVICE_PLATFORM/$DEVICE_PLATFORM/g" files/etc/opkg/distfeeds.conf 188 | # cat repositories.conf > files/etc/opkg/distfeeds.conf 189 | sed -i '/^src imagebuilder file:packages$/d' files/etc/opkg/distfeeds.conf || true 190 | sed -i '/^option check_signature$/d' files/etc/opkg/distfeeds.conf || true 191 | 192 | - name: Build Normal RootFS 193 | run: | 194 | cd immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 195 | chmod +x $GITHUB_WORKSPACE/scripts/* 196 | $GITHUB_WORKSPACE/scripts/preset-terminal-tools.sh 197 | sed -i '/^CONFIG_ISO_IMAGES=y$/d' .config || true 198 | sed -i '/# CONFIG_TARGET_ROOTFS_TARGZ is not set/s/.*/CONFIG_TARGET_ROOTFS_TARGZ=y/' .config 199 | sed -i "/CONFIG_TARGET_ROOTFS_SQUASHFS/s/.*/# CONFIG_TARGET_ROOTFS_SQUASHFS is not set/; 200 | /CONFIG_TARGET_ROOTFS_EXT4FS/s/.*/# CONFIG_TARGET_ROOTFS_EXT4FS is not set/" .config 201 | export CONFIG_NORMAL_PACKAGES=$(cat $GITHUB_WORKSPACE/config/normal-packages.config | tr -s "\n" " ") 202 | make image PACKAGES="$CONFIG_NORMAL_PACKAGES -ipv6helper" FILES="files" V=s 203 | ls -lR bin/targets/ 204 | cp bin/targets/$DEVICE_TARGET/$DEVICE_SUBTARGET/*rootfs.tar.gz $GITHUB_WORKSPACE 205 | cd $GITHUB_WORKSPACE 206 | rm -rf immortalwrt-imagebuilder* 207 | 208 | - name: Build & Push Normal Image (Default) 209 | if: env.DOCKER_EXTERA_TAG == null 210 | uses: docker/build-push-action@v2 211 | with: 212 | platforms: ${{ env.DOCKER_IMAGE_ARCH }} 213 | file: Dockerfile 214 | context: . 215 | push: true 216 | tags: | 217 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt:${{ env.DEVICE_PLATFORM }} 218 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt:${{ env.DEVICE_PLATFORM }} 219 | 220 | - name: Build & Push Normal Image (Extra Tag) 221 | if: env.DOCKER_EXTERA_TAG != null 222 | uses: docker/build-push-action@v2 223 | with: 224 | platforms: ${{ env.DOCKER_IMAGE_ARCH }} 225 | file: Dockerfile 226 | context: . 227 | push: true 228 | tags: | 229 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt:${{ env.DEVICE_PLATFORM }} 230 | ${{ secrets.DOCKERHUB_USERNAME }}/openwrt:${{ env.DOCKER_EXTERA_TAG }} 231 | ghcr.io/${{ github.actor }}/openwrt:${{ env.DEVICE_PLATFORM }} 232 | ghcr.io/${{ github.actor }}/openwrt:${{ env.DOCKER_EXTERA_TAG }} 233 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt:${{ env.DEVICE_PLATFORM }} 234 | # registry.cn-shanghai.aliyuncs.com/${{ secrets.ALIYUN_NAMESPACES }}/openwrt:${{ env.DOCKER_EXTERA_TAG }} 235 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | immortalwrt-*/ 2 | immortalwrt-* -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "github-actions.workflows.pinned.workflows": [] 3 | } 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | 3 | LABEL org.opencontainers.image.authors="liuweiqing" 4 | 5 | ADD *.tar.gz / 6 | 7 | # CMD ["/sbin/init"] 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 P3TERX 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [OpenWrt-In-Docker](https://github.com/14790897/OpenWrt-In-Docker) 2 | 3 | 5 | 6 | [![Docker Stars](https://img.shields.io/docker/stars/14790897/openwrt.svg?style=flat-square&label=Stars&logo=docker)](https://hub.docker.com/r/14790897/openwrt) 7 | [![Docker Pulls](https://img.shields.io/docker/pulls/14790897/openwrt.svg?style=flat-square&label=Pulls&logo=docker&color=orange)](https://hub.docker.com/r/14790897/openwrt) 8 | 9 | 本项目旨在构建适用于树莓派 1~4 、适用于 armv6/armv7/armv8(aarch64)/x86_64(amd64) 平台设备的 OpenWrt 镜像 (每日更新)。 10 | 11 | Github: 12 | 13 | DockerHub: 14 | 15 | ## 支持设备及镜像版本 16 | 17 | 本项目基于 [immortalwrt: master](https://github.com/immortalwrt/immortalwrt/tree/master),每日上午 8 点编译 OpenWrt 镜像 18 | 19 | ### OpenWrt 标准镜像 20 | 21 | OpenWrt 标准镜像为集成常用软件包的 Docker 镜像,镜像自带软件包可满足大多数情景下的使用需求。 22 | 23 | | 支持设备/平台 | DockerHub | 24 | | :-------------: | :-----------------------: | 25 | | 树莓派 1B | 14790897/openwrt:rpi1 | 26 | | 树莓派 2B | 14790897/openwrt:rpi2 | 27 | | 树莓派 3B / 3B+ | 14790897/openwrt:rpi3 | 28 | | 树莓派 4B | 14790897/openwrt:rpi4 | 29 | | 树莓派 5 | 14790897/openwrt:rpi5 | 30 | | armv7 | 14790897/openwrt:armv7 | 31 | | arm8/aarch64 | 14790897/openwrt:armv8 | 32 | | x86_64/amd64 | 14790897/openwrt:x86_64 | 33 | | 玩客云 | 14790897/openwrt:onecloud | 34 | 35 | ### OpenWrt-Mini 镜像 36 | 37 | OpenWrt-Mni 镜像为几乎未添加额外软件包的 Docker 镜像,你可以自行通过 opkg 安装你需要的软件包。 38 | 39 | | 支持设备/平台 | DockerHub | 40 | | :-------------: | :----------------------------: | 41 | | 树莓派 1B | 14790897/openwrt-mini:rpi1 | 42 | | 树莓派 2B | 14790897/openwrt-mini:rpi2 | 43 | | 树莓派 3B / 3B+ | 14790897/openwrt-mini:rpi3 | 44 | | 树莓派 4B | 14790897/openwrt-mini:rpi4 | 45 | | 树莓派 5 | 14790897/openwrt-mini:rpi5 | 46 | | armv7 | 14790897/openwrt-mini:armv7 | 47 | | arm8/aarch64 | 14790897/openwrt-mini:armv8 | 48 | | x86_64/amd64 | 14790897/openwrt-mini:x86_64 | 49 | | 玩客云 | 14790897/openwrt-mini:onecloud | 50 | 51 | ### 国内可以从南京大学镜像源下载 52 | 53 | 只需要在原来的标签前面加上 `ghcr.nju.edu.cn` 即可,例如: 54 | 55 | ```sh 56 | docker pull ghcr.nju.edu.cn/14790897/openwrt: 57 | docker pull ghcr.nju.edu.cn/14790897/openwrt-mini: 58 | ``` 59 | 60 | ## 注意事项 61 | 62 | - 其中,树莓派 2B 镜像同时适用于 2B/3B/3B+/4B 。 63 | - 若拉取镜像时不加任何标签,则将使用 latest 标签拉取镜像,latest 指向的镜像与树莓派 2B 镜像实际上为同一镜像。 64 | 65 | - 由于 Docker 容器与宿主机共享内核,所以 Docker 容器的内核特性与宿主机当前的内核特性相同。 66 | - 本项目固件支持 opkg 安装软件包,软件源内有 7000+ 个软件包可供选择。 67 | - (对于高级用户) 某些软件包可能依赖一些特定的内核特性,所以我不保证 opkg 软件源中的所有软件包都可以正常使用。且因为上文所述原因,在 OpenWrt 中安装 kmod 是无效的,如果有需求,请提前在宿主机中提前载入相应的内核模块,例如: 68 | 69 | ```sh 70 | modprobe ip6_udp_tunnel 71 | modprobe ip6table_nat 72 | modprobe pppoe 73 | modprobe tun 74 | modprobe udp_tunnel 75 | modprobe xt_TPROXY 76 | ``` 77 | 78 | ## 镜像详细使用方法 79 | 80 | [「在 Docker 中运行 OpenWrt 旁路网关」](./tutorial.md) 81 | 82 | ## 鸣谢 83 | 84 | 85 | 86 | P3TERX/Actions-OpenWrt (本项目基于此项目): 87 | 88 | 89 | 90 | OpenWrt Source Repository: 91 | 92 | 93 | 94 | Lean's OpenWrt source: 95 | 96 | 97 | 98 | CTCGFW's Team: 99 | 100 | 101 | -------------------------------------------------------------------------------- /config/mini-packages.config: -------------------------------------------------------------------------------- 1 | -luci-app-cpufreq 2 | bash 3 | curl 4 | htop 5 | luci-i18n-base-zh-cn 6 | nano 7 | vim-full -------------------------------------------------------------------------------- /config/normal-packages.config: -------------------------------------------------------------------------------- 1 | -luci-app-cpufreq 2 | htop 3 | luci-app-argon-config 4 | luci-app-aria2 5 | luci-app-commands 6 | luci-app-ddns 7 | luci-app-firewall 8 | luci-app-frpc 9 | luci-app-netdata 10 | luci-app-nlbwmon 11 | luci-app-nps 12 | luci-app-openclash 13 | luci-app-v2raya 14 | luci-app-passwall 15 | luci-app-smartdns 16 | luci-app-softethervpn 17 | luci-app-transmission 18 | luci-app-ttyd 19 | luci-app-zerotier 20 | luci-app-opkg 21 | luci-lib-ip 22 | luci-lib-ipkg 23 | luci-lib-jsonc 24 | luci-lib-nixio 25 | luci-mod-admin-full 26 | luci-mod-network 27 | luci-mod-status 28 | luci-mod-system 29 | luci-proto-3g 30 | luci-proto-ipip 31 | luci-proto-ipv6 32 | luci-proto-ncm 33 | luci-proto-openconnect 34 | luci-proto-ppp 35 | luci-proto-qmi 36 | luci-proto-relay 37 | luci-base 38 | luci-compat 39 | luci-i18n-argon-config-zh-cn 40 | luci-i18n-aria2-zh-cn 41 | luci-i18n-base-zh-cn 42 | luci-i18n-commands-zh-cn 43 | luci-i18n-ddns-zh-cn 44 | luci-i18n-firewall-zh-cn 45 | luci-i18n-frpc-zh-cn 46 | luci-i18n-netdata-zh-cn 47 | luci-i18n-nlbwmon-zh-cn 48 | luci-i18n-nps-zh-cn 49 | luci-i18n-passwall-zh-cn 50 | luci-i18n-smartdns-zh-cn 51 | luci-i18n-softethervpn-zh-cn 52 | luci-i18n-transmission-zh-cn 53 | luci-i18n-ttyd-zh-cn 54 | luci-i18n-zerotier-zh-cn 55 | luci-theme-material 56 | ariang 57 | coremark 58 | ddns-scripts 59 | ddns-scripts_aliyun 60 | ddns-scripts_cloudflare.com-v4 61 | ddns-scripts_cnkuai_cn 62 | ddns-scripts_digitalocean.com-v2 63 | ddns-scripts_freedns_42_pl 64 | ddns-scripts_godaddy.com-v1 65 | ddns-scripts_no-ip_com 66 | ddns-scripts_nsupdate 67 | ddns-scripts_route53-v1 68 | iperf 69 | libcap 70 | libcap-bin 71 | rsync 72 | rsyncd 73 | bind-dig 74 | bind-host 75 | openssh-sftp-client 76 | openssh-sftp-server 77 | xl2tpd 78 | ppp-mod-pptp 79 | bsdtar 80 | bzip2 81 | gzip 82 | unzip 83 | lsblk 84 | lscpu 85 | nano 86 | vim-full 87 | zsh 88 | screen 89 | tmate 90 | tmux 91 | tree 92 | whereis -------------------------------------------------------------------------------- /config/platform.config: -------------------------------------------------------------------------------- 1 | aarch64_cortex-a53/armsr/armv8/linux-arm64/armv8 2 | aarch64_cortex-a53/bcm27xx/bcm2710/linux-arm64/rpi3 3 | aarch64_cortex-a72/bcm27xx/bcm2711/linux-arm64/rpi4 4 | aarch64_cortex-a76/bcm27xx/bcm2712/linux-arm64/rpi5 5 | aarch64_generic/rockchip/armv8/linux-arm64 6 | arm_arm1176jzf-s_vfp/bcm27xx/bcm2708/linux-arm-v6/rpi1 7 | arm_arm926ej-s/at91/sam9x/linux-arm-v7 8 | arm_cortex-a5_vfpv4/at91/sama5/linux-arm-v7/onecloud 9 | arm_cortex-a7/mediatek/mt7629/linux-arm-v7 10 | arm_cortex-a7_neon-vfpv4/bcm27xx/bcm2709/linux-arm-v7/rpi2 11 | arm_cortex-a9/bcm53xx/generic/linux-arm-v7 12 | arm_cortex-a9_vfpv3-d16/mvebu/cortexa9/linux-arm-v7 13 | x86_64/x86/64/linux-amd64/amd64 -------------------------------------------------------------------------------- /config/repositories.conf: -------------------------------------------------------------------------------- 1 | ## Place your custom repositories here, they must match the architecture and version. 2 | # src/gz %n %U 3 | # src custom file:///usr/src/openwrt/bin/%T/packages 4 | 5 | src/gz openwrt_core https://downloads.immortalwrt.org/snapshots/targets/DEVICE_TARGET/DEVICE_SUBTARGET/packages 6 | src/gz openwrt_base https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/base 7 | src/gz openwrt_luci https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/luci 8 | src/gz openwrt_packages https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/packages 9 | src/gz openwrt_routing https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/routing 10 | src/gz openwrt_telephony https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/telephony 11 | 12 | ## This is the local package repository, do not remove! 13 | src imagebuilder file:packages 14 | 15 | option check_signature -------------------------------------------------------------------------------- /docker-compose-启动第二个.yml: -------------------------------------------------------------------------------- 1 | services: 2 | openwrt: 3 | image: 14790897/openwrt:x86_64 4 | container_name: openwrt-another 5 | restart: always 6 | privileged: true 7 | networks: 8 | openwrt_macvlan_net: 9 | command: /sbin/init 10 | 11 | networks: 12 | openwrt_macvlan_net: 13 | external: true 14 | # ip link add macvlan0 link enp1s0 type macvlan mode bridge # 注意重启后不保留 15 | # ip addr add 192.168.0.198/24 dev macvlan0 # 分配在与容器相同子网内的 IP 16 | # ip link set macvlan0 up 17 | # ip route add 192.168.0.188 dev macvlan0 18 | # 使用这个不需要开启网卡混杂模式 ip link set dev enp1s0 promisc on 19 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | openwrt: 3 | image: 14790897/openwrt:x86_64 4 | container_name: openwrt 5 | restart: always 6 | # privileged: true 7 | cap_add: 8 | - NET_ADMIN # 增加 NET_ADMIN 权限 9 | - NET_RAW 10 | networks: 11 | macvlan_net: 12 | command: /sbin/init 13 | # command: /bin/sh -c "echo 'MY_IP is ${MY_IP}' && /sbin/init && sed -i \"s/option ipaddr '192.168.0.188'/option ipaddr '192.168.0.178'/\" /etc/config/network && /etc/init.d/network restart" 14 | networks: 15 | macvlan_net: 16 | driver: macvlan 17 | driver_opts: 18 | parent: enp1s0 # 宿主机的网卡名称,需要使用ip link show 手动查询,保持一致 19 | ipam: 20 | config: 21 | - subnet: 192.168.0.0/24 # 定义容器使用的子网,需要和当前网络一致 22 | gateway: 192.168.0.1 # 定义网关,需要和当前网络一致 23 | # ip link add macvlan0 link enp1s0 type macvlan mode bridge # 注意重启后不保留 24 | # ip addr add 192.168.0.198/24 dev macvlan0 # 分配在与容器相同子网内的 IP 25 | # ip link set macvlan0 up 26 | # ip route add 192.168.0.188 dev macvlan0 27 | # ip route del default via 192.168.0.188 dev enp1s0 # 删除默认路由 28 | # ip route add default via 192.168.0.188 dev macvlan0 # 添加macvlan0默认路由 172.24.66.92 29 | # 使用这个不需要开启网卡混杂模式 ip link set dev enp1s0 promisc on 30 | -------------------------------------------------------------------------------- /dockerhub-readme.md: -------------------------------------------------------------------------------- 1 | # [OpenWrt-In-Docker](https://github.com/14790897/OpenWrt-In-Docker) 2 | 3 | [![GitHub Stars](https://img.shields.io/github/stars/14790897/OpenWrt-In-Docker.svg?style=flat-square&label=Stars&logo=github)](https://github.com/14790897/OpenWrt-In-Docker/stargazers) 4 | [![GitHub Forks](https://img.shields.io/github/forks/14790897/OpenWrt-In-Docker.svg?style=flat-square&label=Forks&logo=github)](https://github.com/14790897/OpenWrt-In-Dockerr/fork) 5 | [![Docker Stars](https://img.shields.io/docker/stars/14790897/openwrt.svg?style=flat-square&label=Stars&logo=docker)](https://hub.docker.com/r/14790897/openwrt) 6 | [![Docker Pulls](https://img.shields.io/docker/pulls/14790897/openwrt.svg?style=flat-square&label=Pulls&logo=docker&color=orange)](https://hub.docker.com/r/14790897/openwrt) 7 | 8 | 本项目旨在构建适用于树莓派 1~4 、适用于 armv6/armv7/armv8(aarch64)/x86_64(amd64) 平台设备的 OpenWrt 镜像 (每日更新)。 9 | 10 | Github: 11 | 12 | DockerHub: 13 | 14 | ## 支持设备及镜像版本 15 | 16 | 本项目基于 [immortalwrt: master](https://github.com/immortalwrt/immortalwrt/tree/master),每日上午 8 点编译 OpenWrt 镜像 17 | 18 | ### OpenWrt 标准镜像 19 | 20 | OpenWrt 标准镜像为集成常用软件包的 Docker 镜像,镜像自带软件包可满足大多数情景下的使用需求。 21 | 22 | | 支持设备/平台 | DockerHub | 23 | | :-------------: | :-----------------------: | 24 | | 树莓派 1B | 14790897/openwrt:rpi1 | 25 | | 树莓派 2B | 14790897/openwrt:rpi2 | 26 | | 树莓派 3B / 3B+ | 14790897/openwrt:rpi3 | 27 | | 树莓派 4B | 14790897/openwrt:rpi4 | 28 | | 树莓派 5 | 14790897/openwrt:rpi5 | 29 | | armv7 | 14790897/openwrt:armv7 | 30 | | arm8/aarch64 | 14790897/openwrt:armv8 | 31 | | x86_64/amd64 | 14790897/openwrt:x86_64 | 32 | | 玩客云 | 14790897/openwrt:onecloud | 33 | 34 | ### OpenWrt-Mini 镜像 35 | 36 | OpenWrt-Mni 镜像为几乎未添加额外软件包的 Docker 镜像,你可以自行通过 opkg 安装你需要的软件包。 37 | 38 | | 支持设备/平台 | DockerHub | 39 | | :-------------: | :----------------------------: | 40 | | 树莓派 1B | 14790897/openwrt-mini:rpi1 | 41 | | 树莓派 2B | 14790897/openwrt-mini:rpi2 | 42 | | 树莓派 3B / 3B+ | 14790897/openwrt-mini:rpi3 | 43 | | 树莓派 4B | 14790897/openwrt-mini:rpi4 | 44 | | 树莓派 5 | 14790897/openwrt-mini:rpi5 | 45 | | armv7 | 14790897/openwrt-mini:armv7 | 46 | | arm8/aarch64 | 14790897/openwrt-mini:armv8 | 47 | | x86_64/amd64 | 14790897/openwrt-mini:x86_64 | 48 | | 玩客云 | 14790897/openwrt-mini:onecloud | 49 | 50 | ## 注意事项 51 | 52 | - 其中,树莓派 2B 镜像同时适用于 2B/3B/3B+/4B 。 53 | - 若拉取镜像时不加任何标签,则将使用 latest 标签拉取镜像,latest 指向的镜像与树莓派 2B 镜像实际上为同一镜像。 54 | 55 | - 由于 Docker 容器与宿主机共享内核,所以 Docker 容器的内核特性与宿主机当前的内核特性相同。 56 | - 本项目固件支持 opkg 安装软件包,软件源内有 7000+ 个软件包可供选择。 57 | - (对于高级用户) 某些软件包可能依赖一些特定的内核特性,所以我不保证 opkg 软件源中的所有软件包都可以正常使用。且因为上文所述原因,在 OpenWrt 中安装 kmod 是无效的,如果有需求,请提前在宿主机中提前载入相应的内核模块,例如: 58 | 59 | ```sh 60 | modprobe ip6_udp_tunnel 61 | modprobe ip6table_nat 62 | modprobe pppoe 63 | modprobe tun 64 | modprobe udp_tunnel 65 | modprobe xt_TPROXY 66 | ``` 67 | 68 | ## 镜像详细使用方法 69 | 70 | [「在 Docker 中运行 OpenWrt 旁路网关」](./tutorial.md) 71 | 72 | ## 鸣谢 73 | 74 | 75 | 76 | P3TERX/Actions-OpenWrt (本项目基于此项目): 77 | 78 | 79 | 80 | OpenWrt Source Repository: 81 | 82 | 83 | 84 | Lean's OpenWrt source: 85 | 86 | 87 | 88 | CTCGFW's Team: 89 | 90 | 91 | -------------------------------------------------------------------------------- /files/etc/config/dhcp: -------------------------------------------------------------------------------- 1 | 2 | config dnsmasq 3 | option domainneeded '1' 4 | option boguspriv '1' 5 | option filterwin2k '0' 6 | option localise_queries '1' 7 | option rebind_protection '1' 8 | option rebind_localhost '1' 9 | option local '/lan/' 10 | option domain 'lan' 11 | option expandhosts '1' 12 | option nonegcache '0' 13 | option authoritative '1' 14 | option readethers '1' 15 | option leasefile '/tmp/dhcp.leases' 16 | option nonwildcard '1' 17 | option localservice '1' 18 | option filter_aaaa '1' 19 | option port '53' 20 | option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto' 21 | option noresolv '0' 22 | 23 | config dhcp 'lan' 24 | option interface 'lan' 25 | option ignore '1' 26 | 27 | config dhcp 'wan' 28 | option interface 'wan' 29 | option ignore '1' 30 | 31 | config srvhost 32 | option srv '_vlmcs._tcp' 33 | option target 'OpenWrt' 34 | option port '1688' 35 | option class '0' 36 | option weight '100' 37 | 38 | -------------------------------------------------------------------------------- /files/etc/config/network: -------------------------------------------------------------------------------- 1 | 2 | config interface 'loopback' 3 | option ifname 'lo' 4 | option proto 'static' 5 | option ipaddr '127.0.0.1' 6 | option netmask '255.0.0.0' 7 | 8 | config globals 'globals' 9 | 10 | config interface 'lan' 11 | option type 'bridge' 12 | option ifname 'eth0' 13 | option proto 'static' 14 | option netmask '255.255.255.0' 15 | option ip6assign '60' 16 | option ipaddr '192.168.0.188' 17 | option gateway '192.168.0.1' 18 | option dns '192.168.0.1' 19 | 20 | config interface 'vpn0' 21 | option ifname 'tun0' 22 | option proto 'none' 23 | 24 | -------------------------------------------------------------------------------- /files/etc/firewall.user: -------------------------------------------------------------------------------- 1 | # This file is interpreted as shell script. 2 | # Put your custom iptables rules here, they will 3 | # be executed with each firewall (re-)start. 4 | 5 | # Internal uci firewall chains are flushed and recreated on reload, so 6 | # put custom rules into the root chains e.g. INPUT or FORWARD or into the 7 | # special user chains, e.g. input_wan_rule or postrouting_lan_rule. 8 | # 你好呀 9 | iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 10 | iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 11 | iptables -t nat -I POSTROUTING -j MASQUERADE 12 | -------------------------------------------------------------------------------- /files/etc/opkg/distfeeds.conf: -------------------------------------------------------------------------------- 1 | src/gz openwrt_core https://downloads.immortalwrt.org/snapshots/targets/DEVICE_TARGET/DEVICE_SUBTARGET/packages 2 | src/gz openwrt_kmods https://downloads.immortalwrt.org/snapshots/targets/DEVICE_TARGET/DEVICE_SUBTARGET/kmods/KERNEL_VERSION 3 | src/gz openwrt_base https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/base 4 | src/gz openwrt_luci https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/luci 5 | src/gz openwrt_packages https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/packages 6 | src/gz openwrt_routing https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/routing 7 | src/gz openwrt_telephony https://downloads.immortalwrt.org/snapshots/packages/DEVICE_PLATFORM/telephony 8 | #example: https://downloads.immortalwrt.org/snapshots/packages/x86_64/luci/ -------------------------------------------------------------------------------- /files/etc/rc.local: -------------------------------------------------------------------------------- 1 | # Put your custom commands here that should be executed once 2 | # the system init finished. By default this file does nothing. 3 | 4 | # Fix Luci Don't Remove!! 5 | umount /etc/resolv.conf 6 | rm /etc/resolv.conf 7 | ln -s /tmp/resolv.conf.auto /etc/resolv.conf 8 | 9 | exit 0 10 | -------------------------------------------------------------------------------- /files/etc/uci-defaults/99-init-settings: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #================================================= 3 | # File name: init-settings.sh 4 | # Description: This script will be executed during the first boot 5 | # Author: SuLingGG 6 | # Blog: https://mlapp.cn 7 | #================================================= 8 | 9 | # Set default theme to luci-theme-argon 10 | uci set luci.main.mediaurlbase='/luci-static/argon' 11 | 12 | exit 0 13 | -------------------------------------------------------------------------------- /files/root/.vimrc: -------------------------------------------------------------------------------- 1 | " General Settings 2 | set nocompatible " 禁用兼容模式,启用 Vim 扩展功能 3 | set number " 显示行号 4 | set relativenumber " 显示相对行号 5 | set showcmd " 显示命令 6 | set cursorline " 高亮显示当前行 7 | set wildmenu " 启用命令行自动补全菜单 8 | set ignorecase " 搜索时忽略大小写 9 | set smartcase " 如果搜索中包含大写字母,则大小写敏感 10 | set incsearch " 增量搜索 11 | set hlsearch " 搜索结果高亮 12 | 13 | " Tabs and Indentation 14 | set tabstop=4 " Tab 宽度为4个空格 15 | set shiftwidth=4 " 自动缩进为4个空格 16 | set expandtab " 将Tab替换为空格 17 | set autoindent " 自动缩进 18 | set smartindent " 智能缩进 19 | 20 | " Visual Settings 21 | set background=dark " 适合深色主题 22 | syntax on " 启用语法高亮 23 | set wrap " 自动换行 24 | set linebreak " 在单词边界处换行 25 | 26 | " Clipboard 27 | set clipboard=unnamedplus " 使用系统剪贴板 28 | 29 | " File Handling 30 | set backspace=indent,eol,start " 启用更智能的退格键 31 | set undofile " 启用撤销文件保存功能 32 | 33 | " Performance 34 | set lazyredraw " 在宏或脚本执行时优化重绘 35 | set ttyfast " 提升终端速度 36 | 37 | " Status Line 38 | set laststatus=2 " 始终显示状态栏 39 | 40 | " Mappings 41 | nnoremap :w " Ctrl+s 保存文件 42 | 43 | 44 | -------------------------------------------------------------------------------- /files/root/.zshrc: -------------------------------------------------------------------------------- 1 | # If you come from bash you might have to change your $PATH. 2 | # export PATH=$HOME/bin:/usr/local/bin:$PATH 3 | 4 | # Path to your oh-my-zsh installation. 5 | export ZSH=$HOME/.oh-my-zsh 6 | 7 | # Set name of the theme to load --- if set to "random", it will 8 | # load a random theme each time oh-my-zsh is loaded, in which case, 9 | # to know which specific one was loaded, run: echo $RANDOM_THEME 10 | # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 11 | ZSH_THEME="ys" 12 | 13 | # Set list of themes to pick from when loading at random 14 | # Setting this variable when ZSH_THEME=random will cause zsh to load 15 | # a theme from this variable instead of looking in $ZSH/themes/ 16 | # If set to an empty array, this variable will have no effect. 17 | # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) 18 | 19 | # Uncomment the following line to use case-sensitive completion. 20 | # CASE_SENSITIVE="true" 21 | 22 | # Uncomment the following line to use hyphen-insensitive completion. 23 | # Case-sensitive completion must be off. _ and - will be interchangeable. 24 | # HYPHEN_INSENSITIVE="true" 25 | 26 | # Uncomment the following line to disable bi-weekly auto-update checks. 27 | DISABLE_AUTO_UPDATE="true" 28 | 29 | # Uncomment the following line to automatically update without prompting. 30 | # DISABLE_UPDATE_PROMPT="true" 31 | 32 | # Uncomment the following line to change how often to auto-update (in days). 33 | # export UPDATE_ZSH_DAYS=13 34 | 35 | # Uncomment the following line if pasting URLs and other text is messed up. 36 | # DISABLE_MAGIC_FUNCTIONS="true" 37 | 38 | # Uncomment the following line to disable colors in ls. 39 | # DISABLE_LS_COLORS="true" 40 | 41 | # Uncomment the following line to disable auto-setting terminal title. 42 | # DISABLE_AUTO_TITLE="true" 43 | 44 | # Uncomment the following line to enable command auto-correction. 45 | # ENABLE_CORRECTION="true" 46 | 47 | # Uncomment the following line to display red dots whilst waiting for completion. 48 | # COMPLETION_WAITING_DOTS="true" 49 | 50 | # Uncomment the following line if you want to disable marking untracked files 51 | # under VCS as dirty. This makes repository status check for large repositories 52 | # much, much faster. 53 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 54 | 55 | # Uncomment the following line if you want to change the command execution time 56 | # stamp shown in the history command output. 57 | # You can set one of the optional three formats: 58 | # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 59 | # or set a custom format using the strftime function format specifications, 60 | # see 'man strftime' for details. 61 | # HIST_STAMPS="mm/dd/yyyy" 62 | 63 | # Would you like to use another custom folder than $ZSH/custom? 64 | # ZSH_CUSTOM=/path/to/new-custom-folder 65 | 66 | # Which plugins would you like to load? 67 | # Standard plugins can be found in $ZSH/plugins/ 68 | # Custom plugins may be added to $ZSH_CUSTOM/plugins/ 69 | # Example format: plugins=(rails git textmate ruby lighthouse) 70 | # Add wisely, as too many plugins slow down shell startup. 71 | plugins=(git command-not-found extract z docker zsh-syntax-highlighting zsh-autosuggestions zsh-completions) 72 | 73 | source $ZSH/oh-my-zsh.sh 74 | 75 | # User configuration 76 | 77 | # export MANPATH="/usr/local/man:$MANPATH" 78 | 79 | # You may need to manually set your language environment 80 | # export LANG=en_US.UTF-8 81 | 82 | # Preferred editor for local and remote sessions 83 | # if [[ -n $SSH_CONNECTION ]]; then 84 | # export EDITOR='vim' 85 | # else 86 | # export EDITOR='mvim' 87 | # fi 88 | 89 | # Compilation flags 90 | # export ARCHFLAGS="-arch x86_64" 91 | 92 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 93 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 94 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 95 | # For a full list of active aliases, run `alias`. 96 | # 97 | # Example aliases 98 | # alias zshconfig="mate ~/.zshrc" 99 | # alias ohmyzsh="mate ~/.oh-my-zsh" 100 | 101 | autoload -U compinit && compinit 102 | -------------------------------------------------------------------------------- /scripts/preset-terminal-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #================================================= 3 | # File name: preset-terminal-tools.sh 4 | # System Required: Linux 5 | # Version: 1.0 6 | # Lisence: MIT 7 | # Author: SuLingGG 8 | # Blog: https://mlapp.cn 9 | #================================================= 10 | 11 | mkdir -p files/root 12 | pushd files/root 13 | 14 | ## Install oh-my-zsh 15 | # Clone oh-my-zsh repository 16 | git clone https://github.com/robbyrussell/oh-my-zsh ./.oh-my-zsh 17 | 18 | # Install extra plugins 19 | git clone https://github.com/zsh-users/zsh-autosuggestions ./.oh-my-zsh/custom/plugins/zsh-autosuggestions 20 | git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ./.oh-my-zsh/custom/plugins/zsh-syntax-highlighting 21 | git clone https://github.com/zsh-users/zsh-completions ./.oh-my-zsh/custom/plugins/zsh-completions 22 | 23 | popd 24 | -------------------------------------------------------------------------------- /test/x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 设置一些环境变量 3 | PREFIX_URL="https://downloads.immortalwrt.org/snapshots/targets" 4 | DEVICE_PLATFORM="x86_64" 5 | DEVICE_TARGET="x86" 6 | DEVICE_SUBTARGET="64" 7 | DOCKER_IMAGE_ARCH="linux/amd64" 8 | KERNEL_VERSION="" 9 | 10 | # 选择 ImageBuilder 的下载路径和文件名 11 | IMAGEBUILDER_URL="$PREFIX_URL/$DEVICE_TARGET/$DEVICE_SUBTARGET/immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64.tar.zst" 12 | 13 | # 下载 Image Builder 14 | echo "Downloading Image Builder..." 15 | wget -q $IMAGEBUILDER_URL 16 | 17 | # 解压 Image Builder 18 | echo "Extracting Image Builder..." 19 | tar -I zstd -xf *.tar.zst 20 | 21 | # 进入解压后的 Image Builder 目录 22 | cd immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 23 | 24 | # 复制配置文件并修改 25 | echo "Copying and modifying repositories.conf..." 26 | cp -f ../../config/repositories.conf . 27 | sed -i "s/DEVICE_SUBTARGET/$DEVICE_SUBTARGET/g; \ 28 | s/DEVICE_TARGET/$DEVICE_TARGET/g; \ 29 | s/DEVICE_PLATFORM/$DEVICE_PLATFORM/g" repositories.conf 30 | 31 | # 复制文件目录 32 | cp -rf ../../files . 33 | chmod +x files/etc/rc.local 34 | 35 | # 获取内核版本 36 | echo "Getting Kernel Version..." 37 | KERNEL_VERSION=$(ls packages | grep kernel | awk -F '_' '{print $2}') 38 | echo "Kernel Version: $KERNEL_VERSION" 39 | 40 | # 修改 distfeeds.conf 41 | sed -i "s/DEVICE_SUBTARGET/$DEVICE_SUBTARGET/g; \ 42 | s/DEVICE_TARGET/$DEVICE_TARGET/g; \ 43 | s/KERNEL_VERSION/$KERNEL_VERSION/g; \ 44 | s/DEVICE_PLATFORM/$DEVICE_PLATFORM/g" files/etc/opkg/distfeeds.conf 45 | 46 | # 构建 Mini RootFS 47 | echo "Building Mini RootFS..." 48 | sed -i "/CONFIG_TARGET_ROOTFS_SQUASHFS/s/.*/# CONFIG_TARGET_ROOTFS_SQUASHFS is not set/; \ 49 | /CONFIG_TARGET_ROOTFS_EXT4FS/s/.*/# CONFIG_TARGET_ROOTFS_EXT4FS is not set/" .config 50 | CONFIG_MINI_PACKAGES=$(cat ../../config/mini-packages.config | tr -s "\n" " ") 51 | make image PACKAGES="$CONFIG_MINI_PACKAGES" FILES="files" 52 | # 测试:make image PACKAGES="luci" FILES="files" 53 | # 将生成的 RootFS 复制回上一级目录 54 | cp bin/targets/$DEVICE_TARGET/$DEVICE_SUBTARGET/*rootfs.tar.gz ../ 55 | 56 | # 清理工作目录 57 | echo "Cleaning up..." 58 | # cd ../ 59 | # rm -rf immortalwrt-imagebuilder-$DEVICE_TARGET-$DEVICE_SUBTARGET.Linux-x86_64 60 | 61 | echo "Build complete! The generated RootFS is in $(pwd)." 62 | -------------------------------------------------------------------------------- /tutorial.md: -------------------------------------------------------------------------------- 1 | ## docker 运行方法 2 | 3 | 使用 docker-compose 4 | 5 | ```yml 6 | services: 7 | openwrt: 8 | image: 14790897/openwrt:x86_64 9 | container_name: openwrt 10 | restart: always 11 | # privileged: true 12 | cap_add: 13 | - NET_ADMIN # 增加 NET_ADMIN 权限 14 | - NET_RAW 15 | networks: 16 | macvlan_net: 17 | command: /sbin/init 18 | 19 | networks: 20 | macvlan_net: 21 | driver: macvlan 22 | driver_opts: 23 | parent: enp1s0 # 宿主机的网卡名称,需要使用ip link show 手动查询,保持一致 24 | ipam: 25 | config: 26 | - subnet: 192.168.0.0/24 # 定义容器使用的子网,需要和当前网络一致 27 | gateway: 192.168.0.1 # 定义网关,需要和当前网络一致 28 | ``` 29 | 30 | 运行后进入 容器 31 | 32 | ```sh 33 | docker exec -it openwrt /bin/bash 34 | ``` 35 | 36 | ```sh 37 | nano /etc/config/network 38 | ``` 39 | 40 | 修改 IP 地址和路由器同一网段,网关是路由器地址 41 | ![image|369x500](https://linux.do/uploads/default/original/3X/1/b/1bc20192030fc5da0c9b652341b77f34c55b211f.png) 42 | 然后重启网络服务: 43 | 44 | 45 | 46 | /etc/init.d/network restart 47 | 48 | 然后访问配置的 IP 地址就可以用了 49 | 50 | 参考: 51 | 52 | https://post.smzdm.com/p/arqxqm8q/ 53 | 54 | ## 自定义包和系统配置发布到自己的 dockerhub 55 | 56 | ### 1.fork 仓库 57 | 58 | ### 2.配置 action 的 secrets 59 | 60 | 设置 DOCKERHUB_USERNAME 和 DOCKERHUB_PWD 用于登录 dockerhub 61 | 62 | ### 3.自定义安装的包 63 | 64 | 修改 config\normal-packages.config,添加自己的包 65 | 66 | ### 4.自定义系统配置 67 | 68 | 修改 files\etc 下面的系统文件就可以更改系统上对应的配置 69 | 70 | ### 5.编译和上传 71 | 72 | 点击 Actions,选择 workflow,Multi-Arch Images,点击 Run workflow,等待编译完成 73 | 74 | ## 代码解读 75 | 76 | config/platform.config 77 | 举例:x86_64/x86/64/linux-amd64/amd64 78 | 解释:x86_64 是镜像的标签, x86 是 target, 64 是 subtarget, linux-amd64 是镜像构建时使用的平台, 第五个是额外的镜像标签 79 | 80 | arm_cortex-a15_neon-vfpv4/armsr/armv7/linux-arm-v7/armv7 需要在 stable 分支构建 81 | 82 | ## 可以安装的包 83 | 84 | 来源: https://github.com/ophub/amlogic-s9xxx-openwrt/blob/main/config/imagebuilder/imagebuilder.sh#L188 85 | acpid attr base-files bash bc blkid block-mount blockd bsdtar btrfs-progs busybox bzip2 \ 86 | cgi-io chattr comgt comgt-ncm containerd coremark coreutils coreutils-base64 coreutils-nohup \ 87 | coreutils-truncate curl docker docker-compose dockerd dosfstools dumpe2fs e2freefrag e2fsprogs \ 88 | exfat-mkfs f2fs-tools f2fsck fdisk gawk getopt git gzip hostapd-common iconv iw iwinfo jq \ 89 | jshn kmod-brcmfmac kmod-brcmutil kmod-cfg80211 kmod-mac80211 libjson-script liblucihttp \ 90 | liblucihttp-lua losetup lsattr lsblk lscpu mkf2fs mount-utils openssl-util parted \ 91 | perl-http-date perlbase-file perlbase-getopt perlbase-time perlbase-unicode perlbase-utf8 \ 92 | pigz ppp ppp-mod-pppoe proto-bonding pv rename resize2fs runc tar tini ttyd tune2fs \ 93 | uclient-fetch uhttpd uhttpd-mod-ubus unzip uqmi usb-modeswitch uuidgen wget-ssl whereis \ 94 | which wpad-basic wwan xfs-fsck xfs-mkfs xz xz-utils ziptool zoneinfo-asia zoneinfo-core zstd \ 95 | \ 96 | luci luci-base luci-compat luci-i18n-base-zh-cn luci-lib-base luci-lib-docker \ 97 | luci-lib-ip luci-lib-ipkg luci-lib-jsonc luci-lib-nixio luci-mod-admin-full luci-mod-network \ 98 | luci-mod-status luci-mod-system luci-proto-3g luci-proto-bonding luci-proto-ipip luci-proto-ipv6 \ 99 | luci-proto-ncm luci-proto-openconnect luci-proto-ppp luci-proto-qmi luci-proto-relay \ 100 | \ 101 | luci-app-amlogic luci-i18n-amlogic-zh-cn \ 102 | -------------------------------------------------------------------------------- /遇到的报错.md: -------------------------------------------------------------------------------- 1 | # error encountered 2 | 3 | ## 1 4 | 5 | make[3]: *** No rule to make target 'generic-images', needed by '/home/ubuntu/git-program/test-openwrt/test/immortalwrt-imagebuilder-x86-64.Linux-x86_64/build_dir/target-x86_64_musl/linux-x86_64/tmp/immortalwrt-x86-64-generic-image.iso'. Stop. 6 | make[2]: *** [Makefile:247: build_image] Error 2 7 | make[1]: *** [Makefile:153: _call_image] Error 2 8 | make: *** [Makefile:310:image] 错误 2 9 | J3160% make info 10 | 11 | Current Target: "x86/64" 12 | Current Architecture: "x86_64" 13 | Current Revision: "r31949-b8b8ccdf89" 14 | Default Packages: base-files ca-bundle dropbear fstools libc libgcc libustream-openssl logd mtd netifd uci uclient-fetch urandom-seed urngd alsa-utils partx-utils mkf2fs fdisk kmod-button-hotplug kmod-usb-hid kmod-e1000e kmod-i40e kmod-igb kmod-igbvf kmod-igc kmod-ixgbe kmod-ixgbevf kmod-pcnet32 kmod-tulip kmod-vmxnet3 kmod-r8101 kmod-r8125 kmod-r8126 kmod-r8168 kmod-8139cp kmod-8139too kmod-fs-f2fs kmod-ac97 kmod-sound-hda-core kmod-sound-hda-codec-realtek kmod-sound-hda-codec-via kmod-sound-via82xx kmod-sound-hda-intel kmod-sound-hda-codec-hdmi kmod-sound-i8x0 kmod-usb-audio kmod-usb-net kmod-usb-net-asix kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8150 kmod-usb-net-rtl8152-vendor grub2-bios-setup intel-igpu-firmware-dmc automount opkg busybox procd procd-ujail procd-seccomp dnsmasq-full firewall4 nftables kmod-nft-offload ipv6helper ppp ppp-mod-pppoe 15 | Available Profiles: 16 | 17 | generic: 18 | Generic x86/64 19 | Packages: kmod-amazon-ena kmod-amd-xgbe kmod-bnx2 kmod-e1000 kmod-dwmac-intel kmod-forcedeth kmod-fs-vfat kmod-tg3 20 | hasImageMetadata: 0 21 | 22 | ## 2 mini 找不到包 23 | 24 | * opkg_install_cmd: Cannot install package luci-i18n-filetransfer-zh-cn. 25 | * opkg_install_cmd: Cannot install package luci-i18n-turboacc-zh-cn. 26 | 27 | ## 3 normal 找不到包 28 | * opkg_install_cmd: Cannot install package luci-app-fileassistant. 29 | * opkg_install_cmd: Cannot install package luci-app-filetransfer. 30 | * opkg_install_cmd: Cannot install package luci-app-gowebdav. 31 | * opkg_install_cmd: Cannot install package luci-app-n2n_v2. 32 | * opkg_install_cmd: Cannot install package luci-app-samba. 33 | * opkg_install_cmd: Cannot install package luci-app-serverchan. 34 | * opkg_install_cmd: Cannot install package luci-app-ssr-plus. 35 | * opkg_install_cmd: Cannot install package luci-app-webadmin. 36 | * opkg_install_cmd: Cannot install package luci-app-wireguard. 37 | * opkg_install_cmd: Cannot install package luci-app-wrtbwmon. 38 | * opkg_install_cmd: Cannot install package luci-i18n-gowebdav-zh-cn. 39 | * opkg_install_cmd: Cannot install package luci-i18n-n2n_v2-zh-cn. 40 | * opkg_install_cmd: Cannot install package luci-i18n-samba-zh-cn. 41 | * opkg_install_cmd: Cannot install package luci-i18n-ssr-plus-zh-cn. 42 | * opkg_install_cmd: Cannot install package luci-i18n-webadmin-zh-cn. 43 | * opkg_install_cmd: Cannot install package luci-i18n-wireguard-zh-cn. 44 | * opkg_install_cmd: Cannot install package luci-i18n-wrtbwmon-zh-cn. 45 | * opkg_install_cmd: Cannot install package luci-theme-argonv3. 46 | * opkg_install_cmd: Cannot install package ddns-scripts_dnspod. 47 | make[2]: *** [Makefile:220: package_install] Error 255 48 | make[1]: *** [Makefile:151: _call_image] Error 2 49 | 50 | ## 4. GitHub action 从image builder编译某些固件会失败,无法生成rootfs.tar.gz 51 | 因为.config中没有配置允许生成,同时作者原始的编译文件中也不会存在rootfs.tar.gz,例如https://downloads.immortalwrt.org/snapshots/targets/bcm27xx/bcm2710/ 不存在rootfs.tar.gz 52 | .config文件中将# CONFIG_TARGET_ROOTFS_TARGZ is not set 53 | 改为CONFIG_TARGET_ROOTFS_TARGZ=y 54 | 参考链接:https://github.com/immortalwrt/immortalwrt/discussions/1502 55 | 56 | ## 5. arm_cortex-a15_neon-vfpv4/armsr/armv7/linux-arm-v7/armv7无法正常编译 57 | * opkg_install_cmd: Cannot install package kmod-amazon-ena. 58 | 622 59 | * opkg_install_cmd: Cannot install package kmod-bcmgenet. 60 | 623 61 | * opkg_install_cmd: Cannot install package kmod-dwmac-imx. 62 | 624 63 | * opkg_install_cmd: Cannot install package kmod-dwmac-rockchip. 64 | 625 65 | * opkg_install_cmd: Cannot install package kmod-dwmac-sun8i. 66 | 626 67 | * opkg_install_cmd: Cannot install package kmod-fsl-dpaa1-net. 68 | 627 69 | * opkg_install_cmd: Cannot install package kmod-fsl-dpaa2-net. 70 | 628 71 | * opkg_install_cmd: Cannot install package kmod-fsl-enetc-net. 72 | 629 73 | * opkg_install_cmd: Cannot install package kmod-fsl-fec. 74 | 630 75 | * opkg_install_cmd: Cannot install package kmod-mvneta. 76 | 631 77 | * opkg_install_cmd: Cannot install package kmod-mvpp2. 78 | 632 79 | * opkg_install_cmd: Cannot install package kmod-octeontx2-net. 80 | 633 81 | * opkg_install_cmd: Cannot install package kmod-renesas-net-avb. 82 | 634 83 | * opkg_install_cmd: Cannot install package kmod-thunderx-net. 84 | 635 85 | make[2]: *** [Makefile:220: package_install] Error 255 86 | 636 87 | make[1]: *** [Makefile:151: _call_image] Error 2 88 | 637 89 | make: *** [Makefile:310: image] Error 2 90 | 91 | ## 启动容器直接进入openwrt命令行,重启容器导致主机也重启 92 | 解决方法:关闭privileged模式 93 | --------------------------------------------------------------------------------