[Unit]
Description=OpenNebula Cloud Controller Daemon
After=syslog.target
After=network.target
After=remote-fs.target
Before=one_scheduler.service
# Do not start if the scheduler does not exist
ConditionFileIsExecutable=/usr/bin/mm_sched
# Directory lock and run directories must exist
ConditionPathIsDirectory=/var/lock/one
ConditionPathIsDirectory=/var/run/one
# The PID file for the process should not exist, we either have a
# running process or the previous run did not exit cleanly
!ConditionPathExists=/var/run/one/oned.pid

[Service]
# Start daemon in forground mode, when starting as forking process the
# daemon shuts down without obvious reason.
ExecStart=/usr/bin/oned -f
# Log file location must exist
ExecStartPre=/bin/mkdir -p /var/log/one
ExecStartPre=/bin/chown oneadmin:cloud /var/log/one
ExecStop=/bin/kill -TERM $MAINPID
PIDFile=/var/run/one/oned.pid
Type=simple
Group=cloud
User=oneadmin

[Install]
WantedBy=multi-user.target
