style: format

This commit is contained in:
Malte Tammena 2023-11-30 18:23:43 +01:00
parent ab3f72ace2
commit f1b4e09a7a
3 changed files with 63 additions and 63 deletions

View file

@ -1,9 +1,9 @@
#/usr/bin/env bash
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
cat << EOF > openssl.cnf
cat <<EOF >openssl.cnf
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
@ -35,4 +35,4 @@ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out s
openssl verify -CAfile ca.crt server.crt
# Clean Up
rm openssl.cnf server.csr
rm openssl.cnf server.csr

View file

@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
@ -30,44 +30,44 @@ root="$(git rev-parse --show-toplevel)"
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
print_help_and_exit
;;
-H|--host)
shift # past argument
host=$1
shift # past value
;;
-p|--password-path)
shift # past argument
password_path=$1
shift # past value
;;
-r|--root)
shift # past argument
root=$1
shift # past value
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
domain_names+=("$1") # save domain name
shift # past argument
;;
-h | --help)
print_help_and_exit
;;
-H | --host)
shift # past argument
host=$1
shift # past value
;;
-p | --password-path)
shift # past argument
password_path=$1
shift # past value
;;
-r | --root)
shift # past argument
root=$1
shift # past value
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
domain_names+=("$1") # save domain name
shift # past argument
;;
esac
done
if [[ -z "$host" ]]; then
if [[ -z $host ]]; then
printf -- "--host required\n"
print_help_and_exit
elif [[ -z "$password_path" ]]; then
elif [[ -z $password_path ]]; then
printf -- "--password_path required\n"
print_help_and_exit
fi
if [[ "${#domain_names[@]}" -eq 0 ]]; then
if [[ ${#domain_names[@]} -eq 0 ]]; then
print_help_and_exit
fi
@ -75,7 +75,7 @@ first_safe=$(mk_safe "${domain_names[0]}")
pushd "$(mktemp -d)"
cat << EOF > openssl.cnf
cat <<EOF >openssl.cnf
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
@ -91,12 +91,12 @@ subjectAltName = @alt_names
EOF
for key in "${!domain_names[@]}"; do
echo "DNS.$((key+1)) = ${domain_names[$key]}" >> openssl.cnf
echo "DNS.$((key + 1)) = ${domain_names[$key]}" >>openssl.cnf
done
# Get ca.key and ca.crt from pass
pass "$password_path/ca.key" > ca.key
pass "$password_path/ca.crt" > ca.crt
pass "$password_path/ca.key" >ca.key
pass "$password_path/ca.crt" >ca.crt
# Generate private key for certificate
openssl ecparam -name prime256v1 -genkey -out server.key

View file

@ -23,26 +23,26 @@ BUILD_HOST=
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
print_help_and_exit
;;
-x|--external)
EXTERNAL=yes
shift # past argument
;;
-b|--build)
shift # past argument
BUILD_HOST=$1
shift # past value
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
-h | --help)
print_help_and_exit
;;
-x | --external)
EXTERNAL=yes
shift # past argument
;;
-b | --build)
shift # past argument
BUILD_HOST=$1
shift # past value
;;
-*)
echo "Unknown option $1"
print_help_and_exit
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
@ -54,12 +54,12 @@ fi
TARGET_HOST=${POSITIONAL_ARGS[1]:-}
case "$ACTION" in
"switch" | "boot" | "test")
SUDO=sudo
;;
*)
SUDO=
;;
"switch" | "boot" | "test")
SUDO=sudo
;;
*)
SUDO=
;;
esac
ARGS=("$ACTION")