how to create Systemd script to handle DLP services
search cancel

how to create Systemd script to handle DLP services

book

Article ID: 445709

calendar_today

Updated On:

Products

Data Loss Prevention

Issue/Introduction

creating a systemd script to handle the DLP services in newer versions of DLP.

Environment

rhel 8.x and above 

Cause

  1. If your goal is to restart all Symantec DLP services with a single systemd-managed service on Red Hat, create a wrapper script and a corresponding systemd unit.

Resolution

Create restart script 

vi /usr/local/bin/symantec-dlp-control.sh

#!/bin/bash

ACTION=$1

SERVICES=(
    SymantecDLPDetectionServerControllerService
    SymantecDLPIncidentPersisterService
    # Add additional DLP services here
)

case "$ACTION" in
    start)
        echo "Starting Symantec DLP services..."
        for svc in "${SERVICES[@]}"; do
            systemctl start "$svc"
        done
        ;;
    stop)
        echo "Stopping Symantec DLP services..."
        for svc in $(printf "%s\n" "${SERVICES[@]}" | tac); do
            systemctl stop "$svc"
        done
        ;;
    restart)
        echo "Restarting Symantec DLP services..."
        for svc in $(printf "%s\n" "${SERVICES[@]}" | tac); do
            systemctl stop "$svc"
        done

        sleep 10

        for svc in "${SERVICES[@]}"; do
            systemctl start "$svc"
        done
        ;;
    status)
        for svc in "${SERVICES[@]}"; do
            systemctl status "$svc" --no-pager
        done
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac

exit 0

Note: if you are doing the enforce services change the SERVICES=(

SymantecDLPDetectionServerControllerService

SymantecDLPIncidentPersisterService

SymantecDLPManagerService

SymantecDLPNotifierService

)

Make the script executable:

chmod +x /usr/local/bin/symantec-dlp-control.sh

Create Systemd service:

vi /etc/systemd/system/restart-dlp.service

[Unit]
Description=Restart Symantec DLP Services
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/restart-dlp.sh
RemainAfterExit=no

[Install]
WantedBy=multi-user.target

Reload systemd:

systemctl daemon-reload
systemctl enable symantec-dlp.service

Usage:

Start

systemctl start symantec-dlp

Stop

systemctl stop symantec-dlp

Restart

 

systemctl reload symantec-dlp
# or
/usr/local/bin/symantec-dlp-control.sh restart

Check Status:

systemctl status symantec-dlp

Additional Information

With different releases of DLP the service names has changed. Refer to the servicesnames and update the script as needed.