linux fixes
This commit is contained in:
parent
999657d3e5
commit
697b84b9b5
1 changed files with 10 additions and 12 deletions
|
@ -5,13 +5,6 @@
|
|||
# This is a self-contained script for installing and uninstalling the SYNterloper
|
||||
# connection logging service.
|
||||
#
|
||||
# Usage for installation:
|
||||
# sudo ./synterloper.sh
|
||||
# sudo ./synterloper.sh install
|
||||
#
|
||||
# Usage for uninstallation:
|
||||
# sudo /usr/local/sbin/synterloper uninstall
|
||||
#
|
||||
|
||||
# --- Configuration ---
|
||||
LOG_DIR="/var/log/synterloper"
|
||||
|
@ -54,6 +47,15 @@ install_synterloper() {
|
|||
|
||||
# Create the system service
|
||||
if [ "${OS_TYPE}" = "Linux" ]; then
|
||||
# Dynamically find command paths before creating the service.
|
||||
echo "Detecting required command paths..."
|
||||
if ! TCPDUMP_CMD_PATH=$(command -v tcpdump); then echo "Error: tcpdump not found in PATH."; exit 1; fi
|
||||
if ! IP_CMD_PATH=$(command -v ip); then echo "Error: ip not found in PATH."; exit 1; fi
|
||||
if ! GREP_CMD_PATH=$(command -v grep); then echo "Error: grep not found in PATH."; exit 1; fi
|
||||
echo " - tcpdump found at: ${TCPDUMP_CMD_PATH}"
|
||||
echo " - ip found at: ${IP_CMD_PATH}"
|
||||
echo " - grep found at: ${GREP_CMD_PATH}"
|
||||
|
||||
echo "Creating systemd service: synterloper.service"
|
||||
cat > /etc/systemd/system/synterloper.service <<EOF
|
||||
[Unit]
|
||||
|
@ -61,10 +63,7 @@ Description=SYNterloper - TCP Port Connection Logger
|
|||
After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
# =========================================================================================
|
||||
# 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}"'
|
||||
ExecStart=/bin/sh -c 'exec ${TCPDUMP_CMD_PATH} -i \$(${IP_CMD_PATH} -4 route get 1.1.1.1 | ${GREP_CMD_PATH} -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]
|
||||
|
@ -75,7 +74,6 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue