tripleo-image-elements/elements/os-refresh-config/install.d/01-os-refresh-config

48 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# We need to install this early in install.d because other elements will
# need to use os-refresh-config --print-base to know where to put files
set -eux
install-packages git-core python-pip
pip install /opt/stack/os-refresh-config
for d in pre-configure.d configure.d migration.d post-configure.d; do
install -m 0755 -o root -g root -d /opt/stack/os-config-refresh/$d
done
# Upstart
if [ -d /etc/init ] ; then
cat > /etc/init/os-refresh-config.conf <<eof
start on runlevel [2345]
task
exec os-refresh-config
eof
# Systemd
elif [ -d /lib/systemd/system ] ; then
cat > /lib/systemd/system/os-refresh-config.service <<eof
[Unit]
Description=Refresh Config on state change
After=cloud-final.service
Before=crond.service
[Service]
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
fi