#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# #
#   @project        tvapp2
#   @usage          docker image which allows you to download a m3u playlist and EPG guide data for the
#                   IPTV service TheTvApp.
#   @file           nginx.conf.sample
#   @repo           https://github.com/Aetherinox/docker-base-alpine
#                   https://git.binaryninja.net/pub_projects/tvapp2
# #

SUBJECT="/C=NA/ST=NA/L=NA/O=BinaryNinja/OU=TVApp2 Docker Image/CN=*"
if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then
    echo -e " SSL          : Using existing keys found in /config/keys"
else
    echo -e " SSL          : Generating self-signed keys in folder/config/keys. Replace if needed."
    rm -f \
        /config/keys/cert.key \
        /config/keys/cert.crt || true
    openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT"
fi
