Skip to content

Commit b2b148e

Browse files
committed
systemd: ocp-userpasswords: syntax improvements
1 parent 08eca41 commit b2b148e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

systemd/ocp-userpasswords.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ export KUBECONFIG="/opt/kubeconfig"
1111

1212
function 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-
2321
if [ ! -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
3129
fi
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

3736
dev_pass=$(gen_htpasswd developer "$(cat /opt/crc/pass_developer)")
3837
adm_pass=$(gen_htpasswd kubeadmin "$(cat /opt/crc/pass_kubeadmin)")
3938

4039
echo "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)
4341
oc 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

Comments
 (0)