Skip to content

Instantly share code, notes, and snippets.

@raybird
Last active October 21, 2022 03:15
Show Gist options
  • Save raybird/f5b581d7c3bbdaaf49fdbdf37e675f01 to your computer and use it in GitHub Desktop.
Save raybird/f5b581d7c3bbdaaf49fdbdf37e675f01 to your computer and use it in GitHub Desktop.
ubuntu export pem from cli
#!/usr/bin/env bash
set -e
cd $(
cd $(dirname $0)
pwd -P
)
[ -f .env ] && export $(cat .env | xargs) || echo "there is no .env, skip"
function usage() {
cat <<EOS
To execute pre-defined commands with Docker.
Usage:
./$(basename $0) <Command> [args...]
Command:
EOS
egrep -o "^\s*function.*#cmd.*" $(basename $0) | sed "s/^[ \t]*function//" | sed "s/[ \t\(\)\{\}]*#cmd//" |
awk '{CMD=$1; $1=""; printf "\t%-16s%s\n", CMD, $0}'
}
function pem() { #cmd pem domain ./dev.sh pem google.com
openssl s_client -showcerts -connect $1:443 </dev/null | sed -n -e '/-.BEGIN/,/-.END/ p' > $1.pem
}
if [ $# -eq 0 ]; then
usage
else
export COMPOSE_HTTP_TIMEOUT=600
CMD=$1
shift
$CMD $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment