#!/bin/sh # SPDX-FileCopyrightText: 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # SPDX-License-Identifier: MIT-0 License set -e # first arg is `-f` or `--some-option` if [ "${1#-}" != "$1" ]; then set -- haproxy "$@" fi if [ "$1" = 'haproxy' ]; then shift # "haproxy" # if the user wants "haproxy", let's add a couple useful flags # -W -- "master-worker mode" (similar to the old "haproxy-systemd-wrapper"; allows for reload via "SIGUSR2") # -db -- disables background mode set -- haproxy -W -db "$@" fi # Copy all environment vars to /root/envs.sh so we can us them in our cron job env | sed 's/^\(.*\)$/export \1/g' > /root/envs.sh chmod +x /root/envs.sh # Generate the HAProxy config using the template. /bin/bash /generate-haproxy.sh # Restart cron service cron restart # Start HAProxy exec "$@"