aboutsummaryrefslogtreecommitdiff
path: root/openstack-venvs/setup.sh.tmpl
blob: 18cdb96cd362373cd4ee2ceb0f06377cac3730a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/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 <<EOF
$SERVICE ALL=(ALL) NOPASSWD:ALL
Defaults:$SERVICE  !requiretty
EOF