Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | {{/* |
| 4 | Copyright 2019 Intel Corporation. |
| 5 | |
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | you may not use this file except in compliance with the License. |
| 8 | You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, software |
| 13 | distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | See the License for the specific language governing permissions and |
| 16 | limitations under the License. |
| 17 | */}} |
| 18 | |
| 19 | set -ex |
| 20 | COMMAND="${@:-start}" |
| 21 | |
| 22 | function start () { |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 23 | {{- 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 Kozachenko | 57dcd1e | 2023-10-04 17:34:56 +0200 | [diff] [blame] | 49 | exec uwsgi --ini /etc/placement/placement-api-uwsgi.ini |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 50 | {{- end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | function stop () { |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 54 | {{- 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 Kozachenko | 57dcd1e | 2023-10-04 17:34:56 +0200 | [diff] [blame] | 60 | kill -TERM 1 |
Mohammed Naser | 7d1623e | 2024-06-17 09:12:39 -0400 | [diff] [blame] | 61 | {{- end }} |
Mohammed Naser | f3f59a7 | 2023-01-15 21:02:04 -0500 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | $COMMAND |