From b66f97c100fe5f8355ba9f2e80a06640b3999334 Mon Sep 17 00:00:00 2001 From: shaw Date: Thu, 18 Dec 2025 19:27:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20install.sh=20?= =?UTF-8?q?=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E6=97=A7=20sudoers=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因: - install.sh 优先从 tar.gz 复制 sudoers 文件 - 旧版 Release 中的 sudoers 文件没有 /usr/bin/systemctl 路径 - 即使脚本更新了,仍然会使用旧的配置 修复内容: - 移除对 tar.gz 中 sudoers 文件的依赖 - 总是使用脚本中内嵌的最新配置 - 确保新版脚本立即生效,无需等待新 Release --- deploy/install.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/deploy/install.sh b/deploy/install.sh index 94fc7849..45bfe464 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -525,13 +525,10 @@ setup_directories() { setup_sudoers() { print_info "$(msg 'setting_up_sudoers')" - # Check if sudoers file exists in install dir - if [ -f "$INSTALL_DIR/sub2api-sudoers" ]; then - cp "$INSTALL_DIR/sub2api-sudoers" /etc/sudoers.d/sub2api - else - # Create sudoers file - # Support both /bin/systemctl and /usr/bin/systemctl for different distros - cat > /etc/sudoers.d/sub2api << 'EOF' + # Always generate sudoers file from script (not from tar.gz) + # This ensures the latest configuration is used even with older releases + # Support both /bin/systemctl and /usr/bin/systemctl for different distros + cat > /etc/sudoers.d/sub2api << 'EOF' # Sudoers configuration for Sub2API sub2api ALL=(ALL) NOPASSWD: /bin/systemctl restart sub2api sub2api ALL=(ALL) NOPASSWD: /bin/systemctl stop sub2api @@ -540,7 +537,6 @@ sub2api ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart sub2api sub2api ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop sub2api sub2api ALL=(ALL) NOPASSWD: /usr/bin/systemctl start sub2api EOF - fi # Set correct permissions (required for sudoers files) chmod 440 /etc/sudoers.d/sub2api