fixed - both systemd and tcpdump use the percent sign (%) for special formatting

This commit is contained in:
first 2025-07-07 19:21:28 +00:00
parent 2a86f703f0
commit 999657d3e5

View file

@ -61,7 +61,10 @@ Description=SYNterloper - TCP Port Connection Logger
After=network.target
[Service]
Type=simple
ExecStart=/bin/sh -c 'exec /usr/sbin/tcpdump -i \$(ip -4 route get 1.1.1.1 | grep -oP "dev \\K\\S+") -s ${SNAP_LEN} -w ${LOG_DIR}/capture-%Y-%m-%d_%H-%M.pcap -G ${ROTATE_SECONDS} "tcp port ${CAPTURE_PORT}"'
# =========================================================================================
# THE FIX IS HERE: All '%' are escaped as '%%' for systemd
# =========================================================================================
ExecStart=/bin/sh -c 'exec /usr/sbin/tcpdump -i \$(ip -4 route get 1.1.1.1 | grep -oP "dev \\K\\S+") -s ${SNAP_LEN} -w ${LOG_DIR}/capture-%%Y-%%m-%%d_%%H-%%M.pcap -G ${ROTATE_SECONDS} "tcp port ${CAPTURE_PORT}"'
Restart=on-failure
RestartSec=5
[Install]
@ -72,6 +75,7 @@ EOF
systemctl enable synterloper.service
systemctl start synterloper.service
elif [ "${OS_TYPE}" = "FreeBSD" ]; then
# FreeBSD's rc.d system does not have this issue, so no change is needed here.
echo "Creating rc.d script: /usr/local/etc/rc.d/synterloper"
cat > /usr/local/etc/rc.d/synterloper <<'EOF'
#!/bin/sh