Share

openwrt编译笔记

修改ip

vi package/base-files/files/bin/config_generate

修改banner

vi package/base-files/files/etc/banner

wifi

vi package/kernel/mac80211/files/lib/wifi/mac80211.sh

set wireless.default_radio${devidx}.ssid=OpenWrt-$(cat /sys/class/ieee80211/${dev}/macaddress|awk -F ":" '{print $4""$5""$6 }'| tr a-z A-Z)
set wireless.default_radio${devidx}.encryption=psk2
set wireless.default_radio${devidx}.key=password

 

Target Images —> (16) Kernel partition size (in MB) #默认是 (16) 建议修改 (256)
Target Images —> (160) Root filesystem partition size (in MB) #默认是 (160) 建议修改 (1024)

支持 iPv6:
1、Extra packages —> ipv6helper (选定这个后下面几项自动选择了)
Network —> odhcp6c
Network —> odhcpd-ipv6only
LuCI —> Protocols —> luci-proto-ipv6
LuCI —> Protocols —> luci-proto-ppp

默认拨号
vi package/base-files/files/lib/functions/uci-defaults.sh

ucidef_set_interface_wan() {
#dhcp改成pppoe
ucidef_set_interface "wan" ifname "$1" protocol "${2:-pppoe}"
}

 

GitHub – coolsnowwolf/lede: Lean’s LEDE source

一、默认IP地址,最直接的方法是修改OpenWrt源码

位置在下面的位置

/package/base-files/files/lib/functions/uci-defaults.sh

或者

/package/base-files/files/bin/config_generate

修改完之后保存,再进行编译操作。

二、修改或添加管理页面admin/status的文字代码,添加个人标识链接

源码里面搜索admin_status文件夹,修改下面路径的index.htm、index_x86.htm文件
/feeds/luci/modules/luci-mod-admin-full/luasrc/view/admin_status/
/staging_dir/target-x86_64_musl/root-x86/usr/lib/lua/luci/view/
/usr/lib/lua/luci/view/admin_status/

lean大的源码主页修改位置
/package/lean/autocore/files

https://jmdonj.com/%E7%BC%96%E8%AF%91openwrt.html

export http_proxy="http://192.168.188.233:10809"
export https_proxy="http://192.168.188.233:10809"
sudo apt update
sudo apt-get install subversion g++ zlib1g-dev build-essential git python python3 python3-distutils libncurses5-dev gawk gettext unzip file libssl-dev wget libelf-dev ecj fastjar java-propose-classpath
sudo apt install vim net-tools screen

下载代码

git clone https://github.com/openwrt/openwrt

更新源

# 如果出现ssl错误需要设置这个
export GIT_SSL_NO_VERIFY=1
#or
git config --global http.sslverify false

添加下面代码到 openwrt 或 lede 源码根目录下的 feeds.conf.default 文件:

src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git small https://github.com/kenzok8/small
src-git nas https://github.com/linkease/nas-packages.git
src-git passwall https://github.com/xiaorouji/openwrt-passwall.git;main
src-git passwall_packages https://github.com/xiaorouji/openwrt-passwall-packages.git;main
src-git helloworld https://github.com/fw876/helloworld.git

将下载好的包安装

./scripts/feeds update -a
./scripts/feeds install -a

进入编辑界面

make menuconfig

# fix bios boot partition is under 1 MiB
# sed -i 's/256/1024/g' target/linux/x86/image/Makefile

必选,uhttp,这是界面,openwrt原版是没有界面组件的。
两个地方要打开,collection-luca

菜单项”Target Images”,”Root filesystem partition size (in MB)”
改成其它的大值,默认是160,改成1024,否则的话因为选择安装app占用空间太大必然会导致编译失败。

base 中关闭dsnmasq,因为启用了full,冲突


第一次编译可以不选其他的,也可以选了,报错再说。
推荐passwall

更换模板

注:此操作请在编译前执行,设置 ar­gon 为默认主题,以此为例举一反三


cd package
git clone https://github.com/jerrykuku/luci-theme-argon.git
cd ..
make menuconfig 
#choose LUCI->Theme->Luci-theme-argon
# 还要选择luci-app-argon-config*.ipk


make download -j4
make V=s -j$(nproc)
# 如果编译报错了,尝试单线程编译
make V=s -j1
# 用screen来操作
# 退出screen方法 Ctrl + a+d

编译完成后输出路径:bin/targets

root:$1$mQZj9/P9$T24MTX7ZDV5C7lZBMa2my/:19787:0:99999:7:::

passwall报错

方案一、在 ./scripts/feeds install -a 操作之后替换 golang 为 1.22.x 版本
rm -rf feeds/packages/lang/golang
git clone https://github.com/sbwml/packages_lang_golang -b 22.x feeds/packages/lang/golang

方案二、Patch xray-core & xray-plugin 使其兼容 golang 1.21
具体参考: https://github.com/sbwml/openwrt_helloworld/commits/go1.21
xray-core: sbwml/openwrt_helloworld@71ba9a7
xray-plugin: sbwml/openwrt_helloworld@0389f82