teddysun / across

Across the Great Wall we can reach every corner in the world
https://teddysun.com
Apache License 2.0
4.97k stars 2.22k forks source link

wireguard.sh检测核心版本返回值判断的问题 #63

Closed maxzh0916 closed 4 years ago

maxzh0916 commented 4 years ago

https://github.com/teddysun/across/blob/3d023e58b77e8da8f435d9d50d216ede6ac1aa5f/wireguard.sh#L805 https://github.com/teddysun/across/blob/3d023e58b77e8da8f435d9d50d216ede6ac1aa5f/wireguard.sh#L829 检查kernel正确会return 0, 条件等于2时才执行安装,会一直提示检查核心并终止安装。 修改后成功安装,暂未发现其他问题

teddysun commented 4 years ago

此处 rt 变量的值是在函数_is_installed执行完毕后获取到的。 检查内核版本是否大于等于 5.6 的函数check_kernel_version不会改写 rt 变量的值。 也就是说,当满足内核版本大于等于 5.6 时,脚本只会安装 wireguard tools

maxzh0916 commented 4 years ago
# uname -r
5.6.7-1.el7.elrepo.x86_64
# rpm -qa | grep kernel
kernel-ml-5.6.7-1.el7.elrepo.x86_64
kernel-ml-headers-5.6.7-1.el7.elrepo.x86_64
kernel-ml-devel-5.6.7-1.el7.elrepo.x86_64

新的主机,手动升级的内核,旧内核随手删了 除了/lib/modules/5.6.7-1.el7.elrepo.x86_64/kernel/drivers/net/wireguard/wireguard.ko存在,其他文件都没有。_is_installed()返回2。 我已经弄不清楚什么原因了。

teddysun commented 4 years ago

函数_is_installed如果返回2,则表示 wireguard tools 没有安装。 于是脚本就会开始执行 wireguard tools 安装步骤。 这是预想的功能。

maxzh0916 commented 4 years ago

如果_is_installed返回2的话,应该是调用install_wg_3或者install_wg_4吧。我这里直接报WireGuard module does not exists, please check your kernel

teddysun commented 4 years ago

经过测试发现变量 rt 被函数check_os中调用的子函数_exists改写了。 感谢!已经 Fix bug