Skip to content

Commit 9fa6ba1

Browse files
authored
Merge pull request #55 from dafyddj/refactor/bash-2-sh
refactor: make `cert-gen.sh` POSIX-compatible
2 parents 89500a2 + 860f1ba commit 9fa6ba1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

vault/files/cert-gen.sh.j2

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{% from "vault/map.jinja" import vault with context -%}
22
{% set vssc = vault.self_signed_cert -%}
3-
#!/usr/bin/env bash
3+
#!/usr/bin/env sh
44

55
###
66
# Check for root name.
77
##
88
root=$1
99
shift
10-
if [[ -z "$root" ]]; then
10+
if [ -z "$root" ]; then
1111
echo "you must pass 2 arguments; first for root name, second for child name"
1212
exit
1313
fi
@@ -16,7 +16,7 @@ fi
1616
# Check for child name
1717
##
1818
child=$1
19-
if [[ -z "$child" ]]; then
19+
if [ -z "$child" ]; then
2020
echo "you must pass 2 arguments; first for root name ($root), second for child name"
2121
exit
2222
fi
@@ -38,7 +38,7 @@ root_p12="$root.p12"
3838
###
3939
# Generate the root private key
4040
##
41-
if [[ -e "$root_key" ]]; then
41+
if [ -e "$root_key" ]; then
4242
echo "$root_key already exits"
4343
else
4444
echo "generate $root_key"
@@ -48,7 +48,7 @@ fi
4848
###
4949
# Genereate the the root privacy enhanced email (PEM)
5050
##
51-
if [[ -e "$root_pem" ]]; then
51+
if [ -e "$root_pem" ]; then
5252
echo "$root_pem already exits"
5353
else
5454
echo "generate $root_pem"
@@ -58,7 +58,7 @@ fi
5858
###
5959
# Generate the root public key (P12)
6060
##
61-
if [[ -e "$root_p12" ]]; then
61+
if [ -e "$root_p12" ]; then
6262
echo "$root_p12 already exits"
6363
else
6464
echo "generate $root_p12"
@@ -80,17 +80,17 @@ child_jks="$child_name.jks"
8080
###
8181
# Generate the child private key
8282
##
83-
if [[ -e "$child_key" ]]; then
83+
if [ -e "$child_key" ]; then
8484
echo "$child_key already exits"
8585
else
8686
echo "generate $child_key"
8787
openssl genrsa -aes256 -passout pass:"$pw" -out "$child_key" 4096
8888
fi
8989

9090
###
91-
# Genereate the the child privacy enhanced email (PEM)
91+
# Generate the the child privacy enhanced email (PEM)
9292
##
93-
if [[ -e "$child_pem" ]]; then
93+
if [ -e "$child_pem" ]; then
9494
echo "$child_pem already exits"
9595
else
9696
echo "generate $child_csr"
@@ -103,7 +103,7 @@ fi
103103
###
104104
# Generate the child public key (P12)
105105
##
106-
if [[ -e "$child_p12" ]]; then
106+
if [ -e "$child_p12" ]; then
107107
echo "$child_p12 already exits"
108108
else
109109
echo "generate $child_p12"
@@ -114,11 +114,11 @@ fi
114114
###
115115
# Generate the Java Keystore (JKS)
116116
##
117-
if [[ -e "$child_jks" ]]; then
117+
if [ -e "$child_jks" ]; then
118118
echo "$child_jks already exits"
119119
else
120120
keytool="keytool"
121-
if [[ -n $(command -v $keytool) ]]; then
121+
if [ -n "$(command -v $keytool)" ]; then
122122
echo "generate $child_jks with $root trustedCertEntry"
123123
$keytool -importcert -trustcacerts -noprompt -file "$root_pem" -destkeystore "$child_jks" -storepass "$pw" \
124124
-alias "$root" -v

0 commit comments

Comments
 (0)