#
# Copyright (C) 2013-2023 Bareos GmbH & Co. KG
# Copyright (c) 2011 Free Software Foundation Europe e.V., Author: Bruno Friedmann
#
[Unit]
Description=Bareos Director Daemon service
Documentation=man:bareos-dir(8)
Requires=network.target nss-lookup.target time-sync.target
After=network-online.target nss-lookup.target local-fs.target remote-fs.target time-sync.target postgresql.service
# Dependency about the database
# We let administrators decide if they need it (if local db instance)
# Wants=@DEFAULT_DB_TYPE@.service
# Check if working dir exist
ConditionPathExists=@working_dir@
# Limit the number of restart per day
StartLimitIntervalSec=1d

[Service]
Type=simple
User=@dir_user@
Group=@dir_group@
WorkingDirectory=@working_dir@
ExecStart=@sbindir@/bareos-dir -f
SuccessExitStatus=0 15
ExecReload=@sbindir@/bareos-dir -t -f
ExecReload=/bin/kill -HUP $MAINPID
# Increase the maximum number of open file descriptors
LimitNOFILE=8192:524288
# Restart on failure, wait 30 seconds
Restart=on-failure
RestartSec=30
# Limit the number of restart to 10. to reset counter use systemctl reset-failed bareos-dir
StartLimitBurst=10
# Don't restart on wrong exec arguments and configuration errors.
RestartPreventExitStatus=41 42


[Install]
Alias=bareos-director.service
WantedBy=multi-user.target
