Fix systemd services.

Systemd services should be created at /lib/systemd/system instead of
/etc/systemd/system, once the service is enabled systemd will create a
link from /lib/systemd... to /etc/systemd...

Also systemd services should contain the absolute path to the executables.

Change-Id: I741fe249de8ecc7b2af100ca6cf55c51f86f84b0
This commit is contained in:
Lucas Alvares Gomes 2013-06-17 12:25:55 +01:00
parent 7af93c6f31
commit 01061a1d7d
3 changed files with 45 additions and 11 deletions

View File

@ -31,16 +31,18 @@ eof
}
function install_dnsmasq_systemd {
cat > /etc/systemd/system/nova-bm-dnsmasq.conf << eof
cat > /lib/systemd/system/nova-bm-dnsmasq.service << eof
[Unit]
Description=Nova dnsmasq service
After=openvswitch.service
[Service]
Type=forking
ExecStartPre=mkdir -p /tftpboot
ExecStartPre=chown -R nova:nova /tftpboot
ExecStartPre=killall -9 dnsmasq || echo 'no dnsmasq running'
ExecStart=dnsmasq --conf-file= \\
ExecStartPre=/bin/mkdir -p /tftpboot
ExecStartPre=/bin/chown -R nova:nova /tftpboot
-ExecStartPre=/bin/killall -9 dnsmasq
ExecStartPre=/sbin/ifup br-ctlplane
ExecStart=/sbin/dnsmasq --conf-file= \\
--port=0 \\
--enable-tftp \\
--tftp-root=/tftpboot \\
@ -54,6 +56,13 @@ ExecStart=dnsmasq --conf-file= \\
WantedBy=multi-user.target
Alias=nova-bm-dnsmasq.service
eof
# Make systemd take notice of it
systemctl daemon-reload
# Enable the service
systemctl enable nova-bm-dnsmasq.service
}
# Used by all compute
@ -71,7 +80,7 @@ usermod -a -G libvirtd nova
if [ -d /etc/init ]; then
install_dnsmasq_upstart
elif [ -d /etc/systemd/system ]; then
elif [ -d /lib/systemd/system ]; then
install_dnsmasq_systemd
fi

View File

@ -19,18 +19,26 @@ start on runlevel [2345]
task
exec os-refresh-config
eof
# Systemd
elif [ -d /etc/systemd/system ] ; then
cat > /etc/systemd/system/os-refresh-config.service <<eof
elif [ -d /lib/systemd/system ] ; then
cat > /lib/systemd/system/os-refresh-config.service <<eof
[Unit]
Description=Refresh Config on state change
[Service]
ExecStart=os-refresh-config
ExecStart=/bin/os-refresh-config
[Install]
WantedBy=multi-user.target
eof
# Make systemd take notice of it
systemctl daemon-reload
# Enable the service
systemctl enable os-refresh-config.service
else
echo Only systems with systemd or upstart are supported.
exit 1

View File

@ -98,18 +98,35 @@ function install_systemd {
local cmd=$3
shift; shift; shift
local args=$*
$OUTPUT /etc/systemd/system/$name.service <<EOF
$OUTPUT /lib/systemd/system/$name.service <<EOF
[Unit]
Description=$name Service
After=os-refresh-config.service
Requires=$name-create-dir.service
[Service]
ExecStart=/opt/stack/venvs/$user/bin/$cmd -- $args
ExecStart=/opt/stack/venvs/$user/bin/$cmd $args
User=$user
[Install]
WantedBy=multi-user.target
Alias=$name.service
EOF
$OUTPUT /lib/systemd/system/$name-create-dir.service <<EOF
[Unit]
Description=Create /var/run/$name
[Service]
ExecStartPre=/bin/mkdir -p /var/run/$user
ExecStart=/bin/chown -R $user:$user /var/run/$user
EOF
# Make systemd take notice of it
systemctl daemon-reload
# Enable the service
systemctl enable $name.service
}
# TODO: SysV init fallback support