Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在OpenWrt中运行二进制文件会导致openwrt的reboot、poweroff命令无法使用 #688

Closed
LemonCrab666 opened this issue Oct 30, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@LemonCrab666
Copy link

在Immortalwrt 23.05.4中使用nginx-ui设置为开机运行nohup /opt/nginx-ui/nginx-ui -config /opt/nginx-ui/app.ini后会导致openwrt无法重启关机,并且没有系统日志,请重新测试下

@LemonCrab666 LemonCrab666 added the bug Something isn't working label Oct 30, 2024
@0xJacky
Copy link
Owner

0xJacky commented Oct 30, 2024

你好,以下的是我的操作步骤:

  1. 下载镜像文件 https://firmware-selector.immortalwrt.org/?version=23.05.4&target=x86%2F64&id=generic
  2. 创建虚拟机,使用 qcow2 作为硬盘
  3. 配置 Openwrt 网络 /etc/config/network 使得系统可以连接网络
  4. 下载 nginx-ui x86-64 linux 版本可执行文件(beta.39)到 /opt/nginx-ui 目录下
  5. 执行 opkg update 和 opkg install coreutils-nohup 安装 nohup
  6. 使用 nohup /opt/nginx-ui/nginx-ui -config /opt/nginx-ui/app.ini & 命令启动 nginx-ui
image
  1. 网页可以正常加载,Openwrt 终端工作正常,可以使用 reboot,poweroff 命令。

@0xJacky
Copy link
Owner

0xJacky commented Oct 30, 2024

推测是由于您配置错误,结尾漏了个 & 导致终端卡在了这条命令上,所有输入都无法生效,基于这个情况,你可以使用 Control+C 退出回到终端,这样应该可以正常执行命令。重新配置你的开机启动脚本,应该就能解决问题。

@LemonCrab666
Copy link
Author

推测是由于您配置错误,结尾漏了个 & 导致终端卡在了这条命令上,所有输入都无法生效,基于这个情况,你可以使用 Control+C 退出回到终端,这样应该可以正常执行命令。重新配置你的开机启动脚本,应该就能解决问题。

感谢,我再重新试下

@0xJacky
Copy link
Owner

0xJacky commented Oct 30, 2024

补充说明一下,应该不是这样配置开机启动脚本的,稍等我看看

@0xJacky
Copy link
Owner

0xJacky commented Oct 30, 2024

请尝试社区贡献的方法

cat > "/etc/init.d/nginxui" << EOF
#!/bin/sh /etc/rc.common

START=99
STOP=10

USE_PROCD=1
PROG="/usr/bin/nginx-ui"
ARGS="-config /etc/nginx-ui/app.ini"

start_service() {
    procd_open_instance
    procd_set_param command "$PROG" $ARGS
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_set_param respawn
    procd_close_instance
}

stop_service() {
    killall nginx-ui
}

restart() {
    stop
    start
}
EOF

chmod +x /etc/init.d/nginxui
  1. https://www.reddit.com/r/linux/comments/1bmcsz0/howto_nginxui_on_openwrt_without_building/
  2. Misleading Docs and Error Messages #335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants