#!/bin/bash -e OS=unknown LIBVIRTGROUPS=libvirt if [ -f /etc/debian_version ]; then OS=debian LIBVIRTGROUPS=libvirt,libvirt-qemu fi if [ -f /etc/redhat-release ]; then OS=redhat fi SERVICE="#PROJECT_NAME#" SERVICE_DIR=$(dirname $(readlink -f $0)) getent passwd $SERVICE >/dev/null || \ useradd --home-dir $SERVICE_DIR --system --shell /bin/false $SERVICE [ -d /etc/$SERVICE ] || cp -r $SERVICE_DIR/src/etc /etc/$SERVICE mkdir -p /var/log/$SERVICE mkdir -p /var/lib/$SERVICE chown -R $SERVICE:$SERVICE /var/log/$SERVICE chown -R $SERVICE:$SERVICE /var/lib/$SERVICE chown $SERVICE:$SERVICE /etc/$SERVICE cat >> /etc/logrotate.d/$SERVICE << EOF /var/log/$SERVICE/*.log { daily missingok rotate 7 compress notifempty nocreate } EOF cd $SERVICE_DIR if [ "$SERVICE" == 'nova' ] ; then if which qemu-system-aarch64 ; then # we are configuring a compute node usermod -G $LIBVIRTGROUPS $SERVICE cp $SERVICE_DIR/systemd-services/erp-nova-compute.service $SERVICE_DIR/ else # we are configuring a controller for service in api cert conductor consoleauth scheduler do cp $SERVICE_DIR/systemd-services/erp-nova-${service}.service $SERVICE_DIR/ done fi mv /etc/nova/nova/* /etc/nova/ && rmdir /etc/nova/nova cp $SERVICE_DIR/bin/nova-rootwrap /usr/bin cp $SERVICE_DIR/bin/privsep-helper /usr/bin sudo -u nova mkdir -p /var/lib/nova/instances fi if [ "$SERVICE" == 'neutron' ] ; then if which qemu-system-aarch64 ; then # we are configuring a compute node cp $SERVICE_DIR/systemd-services/erp-neutron-openvswitch-agent.service $SERVICE_DIR/ else for service in dhcp-agent l3-agent metadata-agent server openvswitch-agent do cp $SERVICE_DIR/systemd-services/erp-neutron-${service}.service $SERVICE_DIR/ done fi mv /etc/neutron/neutron/* /etc/neutron/ && rmdir /etc/neutron/neutron cp $SERVICE_DIR/bin/neutron-rootwrap /usr/local/bin cp $SERVICE_DIR/bin/neutron-ns-metadata-proxy /usr/local/bin fi if [ "$SERVICE" == 'cinder' ] ; then if which qemu-system-aarch64 ; then # we are configuring a compute node cp $SERVICE_DIR/systemd-services/erp-cinder-volume.service $SERVICE_DIR/ else for service in api scheduler do cp $SERVICE_DIR/systemd-services/erp-cinder-${service}.service $SERVICE_DIR/ done fi mv /etc/cinder/cinder/* /etc/cinder/ && rmdir /etc/cinder/cinder fi if [ "$SERVICE" == 'heat' ] ; then for service in api-cfn api engine do cp $SERVICE_DIR/systemd-services/erp-heat-${service}.service $SERVICE_DIR/ done mv /etc/heat/heat/* /etc/heat/ && rmdir /etc/heat/heat fi if [ "$SERVICE" == 'glance' ] ; then for service in api registry do cp $SERVICE_DIR/systemd-services/erp-glance-${service}.service $SERVICE_DIR/ done mv /etc/glance/glance/* /etc/glance/ && rmdir /etc/glance/glance fi if [ "$SERVICE" == 'keystone' ] ; then exit 0 fi for service in *.service do mv $service /usr/lib/systemd/system/ systemctl enable $service done cat > /etc/sudoers.d/$SERVICE <