fix: support legacy systemd path parsing

This commit is contained in:
Qiufeng
2026-08-04 10:03:18 +08:00
parent b792f3f21b
commit 4d6a9307e5
2 changed files with 17 additions and 3 deletions
+7 -3
View File
@@ -442,8 +442,8 @@ User=$ERP_USER
Group=$ERP_GROUP Group=$ERP_GROUP
Environment="ERP_INSTALL_ROOT=$INSTALL_ROOT" Environment="ERP_INSTALL_ROOT=$INSTALL_ROOT"
Environment="ERP_CONFIG_FILE=$CONFIG_FILE" Environment="ERP_CONFIG_FILE=$CONFIG_FILE"
WorkingDirectory="$INSTALL_ROOT" WorkingDirectory=$INSTALL_ROOT
ExecStart="$INSTALL_ROOT/current/bin/erp-run" ExecStart=$INSTALL_ROOT/current/bin/erp-run
Restart=always Restart=always
RestartSec=3 RestartSec=3
TimeoutStopSec=90 TimeoutStopSec=90
@@ -453,12 +453,16 @@ NoNewPrivileges=true
PrivateTmp=true PrivateTmp=true
ProtectSystem=full ProtectSystem=full
ProtectHome=true ProtectHome=true
ReadWritePaths="$INSTALL_ROOT" "$CONFIG_ROOT" "$STATE_ROOT" "$LOG_ROOT" ReadWritePaths=$INSTALL_ROOT $CONFIG_ROOT $STATE_ROOT $LOG_ROOT
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl daemon-reload systemctl daemon-reload
if command -v systemd-analyze >/dev/null 2>&1; then
systemd-analyze verify /etc/systemd/system/kaidi-erp.service \
|| fail 'generated systemd unit is invalid; run systemd-analyze verify /etc/systemd/system/kaidi-erp.service'
fi
systemctl enable kaidi-erp.service systemctl enable kaidi-erp.service
systemctl restart kaidi-erp.service systemctl restart kaidi-erp.service
else else
+10
View File
@@ -474,6 +474,15 @@ test_systemd_unit_uses_compatible_protection() (
! grep -Fq 'ProtectSystem=strict' "$PROJECT_ROOT/install.sh" ! grep -Fq 'ProtectSystem=strict' "$PROJECT_ROOT/install.sh"
) )
test_systemd_unit_uses_unquoted_legacy_paths() (
local unit
unit="$(sed -n '/^ cat > \/etc\/systemd\/system\/kaidi-erp.service/,/^ systemctl daemon-reload/p' "$PROJECT_ROOT/install.sh")"
grep -Fqx 'WorkingDirectory=$INSTALL_ROOT' <<< "$unit"
grep -Fqx 'ExecStart=$INSTALL_ROOT/current/bin/erp-run' <<< "$unit"
grep -Fqx 'ReadWritePaths=$INSTALL_ROOT $CONFIG_ROOT $STATE_ROOT $LOG_ROOT' <<< "$unit"
! grep -Fq 'WorkingDirectory="$INSTALL_ROOT"' <<< "$unit"
)
test_no_service_install_disables_online_update() ( test_no_service_install_disables_online_update() (
local tmp local tmp
tmp="$(mktemp -d "${TMPDIR:-/tmp}/erp-no-service-test.XXXXXX")" || return 1 tmp="$(mktemp -d "${TMPDIR:-/tmp}/erp-no-service-test.XXXXXX")" || return 1
@@ -526,6 +535,7 @@ run_test 'installer moves database setup to the web wizard' test_installer_moves
run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url
run_test 'Linux production install requires systemd' test_linux_service_preflight_requires_systemd run_test 'Linux production install requires systemd' test_linux_service_preflight_requires_systemd
run_test 'systemd unit uses compatible protection' test_systemd_unit_uses_compatible_protection run_test 'systemd unit uses compatible protection' test_systemd_unit_uses_compatible_protection
run_test 'systemd unit uses unquoted legacy paths' test_systemd_unit_uses_unquoted_legacy_paths
run_test 'no-service install disables online update' test_no_service_install_disables_online_update run_test 'no-service install disables online update' test_no_service_install_disables_online_update
run_test 'release workflow uses the scoped Gitea job token' test_release_workflow_uses_scoped_job_token run_test 'release workflow uses the scoped Gitea job token' test_release_workflow_uses_scoped_job_token
run_test 'installer starts correctly when piped to bash' test_installer_runs_when_piped_to_bash run_test 'installer starts correctly when piped to bash' test_installer_runs_when_piped_to_bash