blob: f59947aaf89cb1edea1155a618757d25de8b56dc [file] [log] [blame]
Mohammed Naserf3f59a72023-01-15 21:02:04 -05001#!/bin/bash
2
3{{/*
4Copyright 2019 Intel Corporation.
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17*/}}
18
19set -ex
20COMMAND="${@:-start}"
21
22function start () {
Mohammed Naser7d1623e2024-06-17 09:12:39 -040023{{- if .Values.manifests.certificates }}
24 cp -a $(type -p placement-api) /var/www/cgi-bin/placement/
25 if [ -f /etc/apache2/envvars ]; then
26 # Loading Apache2 ENV variables
27 source /etc/apache2/envvars
28 # The directory below has to be created due to the fact that
29 # libapache2-mod-wsgi-py3 doesn't create it in contrary by libapache2-mod-wsgi
30 mkdir -p ${APACHE_RUN_DIR}
31 fi
32
33 # Get rid of stale pid file if present.
34 rm -f /var/run/apache2/*.pid
35
36 # Start Apache2
37 {{- if .Values.conf.software.apache2.a2enmod }}
38 {{- range .Values.conf.software.apache2.a2enmod }}
39 a2enmod {{ . }}
40 {{- end }}
41 {{- end }}
42 {{- if .Values.conf.software.apache2.a2dismod }}
43 {{- range .Values.conf.software.apache2.a2dismod }}
44 a2dismod {{ . }}
45 {{- end }}
46 {{- end }}
47 exec {{ .Values.conf.software.apache2.binary }} {{ .Values.conf.software.apache2.start_parameters }}
48{{- else }}
Oleksandr Kozachenko57dcd1e2023-10-04 17:34:56 +020049 exec uwsgi --ini /etc/placement/placement-api-uwsgi.ini
Mohammed Naser7d1623e2024-06-17 09:12:39 -040050{{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050051}
52
53function stop () {
Mohammed Naser7d1623e2024-06-17 09:12:39 -040054{{- if .Values.manifests.certificates }}
55 if [ -f /etc/apache2/envvars ]; then
56 source /etc/apache2/envvars
57 fi
58 {{ .Values.conf.software.apache2.binary }} -k graceful-stop
59{{- else }}
Oleksandr Kozachenko57dcd1e2023-10-04 17:34:56 +020060 kill -TERM 1
Mohammed Naser7d1623e2024-06-17 09:12:39 -040061{{- end }}
Mohammed Naserf3f59a72023-01-15 21:02:04 -050062}
63
64$COMMAND