fix: 修复 install.sh 优先使用旧 sudoers 文件的问题
问题原因: - install.sh 优先从 tar.gz 复制 sudoers 文件 - 旧版 Release 中的 sudoers 文件没有 /usr/bin/systemctl 路径 - 即使脚本更新了,仍然会使用旧的配置 修复内容: - 移除对 tar.gz 中 sudoers 文件的依赖 - 总是使用脚本中内嵌的最新配置 - 确保新版脚本立即生效,无需等待新 Release
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user