Systemd state to remain active on failed ExecStop

When an error occurs with the ExecStop=/usr/lib/pick/d3shutdown_custom pick0 script, I want systemd to abort the shutdown process and return to the active state.

At the moment when the script exits with code 4 (the user has insufficient privileges), systemd is stuck in the deactivating state.

Here’s my systemd service file

[Unit]
Description=D3 multivalue database
After=d3_sn.service rslm.service
Requires=rslm.service
Wants=d3_sn.service

[Service]
Type=forking
ExecStart=/usr/bin/d3 -n pick0 -s -a x
ExecStop=/usr/lib/pick/d3shutdown_custom pick0
TimeoutSec=0
RemainAfterExit=true
SuccessExitStatus=11

[Install]
WantedBy=multi-user.target

Here’s a snippet of the d3shutdown_custom script


log_error() {
	echo -e "Error: $1"
	echo "Aborting program ... "
	echo " "
}

if [ ! -f "$D3_PROPERTIES_FILE" ]; then log_error "File $D3_PROPERTIES_FILE not found."; exit 2; fi
source $D3_PROPERTIES_FILE
export PICKUSER
export PICKUPASS

if d3 -q | grep -q 'not running'; then
        exit 11
fi

D3TCL=$(/usr/bin/d3tcl 'listu')
if echo $D3TCL | grep -q 'Bad User or User Password'; then log_error "Bad password"; exit 4; fi