@@ -11,15 +11,13 @@ export KUBECONFIG="/opt/kubeconfig"
1111
1212function gen_htpasswd() {
1313 if [ -z " ${1:- } " ] || [ -z " ${2:- } " ]; then
14- echo " gen_htpasswd needs two arguments: username password" 1 >&2
14+ echo " gen_htpasswd needs to arguments: username password" >&2
1515 return 1
1616 fi
1717
18- podman run --rm docker.io/xmartlabs/ htpasswd " $1 " " $2 "
18+ podman run --rm registry.access.redhat.com/ubi10/httpd-24 htpasswd -nb " $1 " " $2 "
1919}
2020
21- wait_for_resource secret
22-
2321if [ ! -f /opt/crc/pass_developer ]; then
2422 echo " developer password does not exist"
2523 exit 1
@@ -30,20 +28,22 @@ if [ ! -f /opt/crc/pass_kubeadmin ]; then
3028 exit 1
3129fi
3230
33- echo " generating the kubeadmin and developer passwords ... "
31+ wait_for_resource_or_die secret
3432
35- set +x # /!\ disable the logging to avoid leaking the passwords
33+ echo " generating the kubeadmin and developer passwords ..."
34+ set +x # disable the logging to avoid leaking the passwords
3635
3736dev_pass=$( gen_htpasswd developer " $( cat /opt/crc/pass_developer) " )
3837adm_pass=$( gen_htpasswd kubeadmin " $( cat /opt/crc/pass_kubeadmin) " )
3938
4039echo " creating the password secret ..."
41- # use bash <() to use a temporary fd file
42- # use sed to remove the empty lines
40+ # use bash "<()" to use a temporary fd file (safer to handle secrets)
4341oc create secret generic htpass-secret \
4442 --from-file=htpasswd=<( printf ' %s\n%s\n' " $dev_pass " " $adm_pass " ) \
4543 -n openshift-config \
4644 --dry-run=client -oyaml \
4745 | oc apply -f-
4846
49- echo " all done"
47+ echo " All done"
48+
49+ exit 0
0 commit comments