Skip to content

Instantly share code, notes, and snippets.

@jaddek
Created March 11, 2021 17:12
Show Gist options
  • Save jaddek/1858d3508d078f3bd71b3fce3dcffc6b to your computer and use it in GitHub Desktop.
Save jaddek/1858d3508d078f3bd71b3fce3dcffc6b to your computer and use it in GitHub Desktop.

Revisions

  1. jaddek created this gist Mar 11, 2021.
    32 changes: 32 additions & 0 deletions install-certs.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/usr/bin/env bash

    CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

    if ! command -v mkcert &>/dev/null; then
    echo "\033[41mUtil mkcert should be installed to configure the certificate\033[0m"
    echo "\033[31mYou can find it here: https://github.com/FiloSottile/mkcert\033[0m"
    exit
    fi

    check_mkcert

    while getopts h: flag; do
    case "${flag}" in
    h) hosts=$2 ;;
    esac
    done

    echo "Are you sure? The command would be is: mkcert ${hosts};"
    echo "\033[1;32mExample: mkcert example.com '*.example.org' myapp.dev localhost 127.0.0.1 ::1 \033[0m"

    echo "Continue? (y/n)"
    read sure

    if [ "${sure}" != 'y' ]; then
    exit
    fi

    DEST="${CURRENT_DIR}/../docker/container/nginx/certs/"
    #
    mkcert -install
    mkcert -cert-file "${DEST}devcert.pem" -key-file "${DEST}devcert-key.pem" "${hosts}"