Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit e37652f

Browse files
cockermacockerma
authored andcommitted
Add checks for file
1 parent 9a0722c commit e37652f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ucdtemplates/setpasswordstodefault

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@
1616
FILE="${1}"
1717
TEMP=$(mktemp)
1818

19+
show_usage () {
20+
echo -e "Usage:\t"$(basename "$0") "FILE"
21+
}
22+
23+
# Validate FILE
24+
if [[ -z "${FILE}" ]] ; then
25+
echo "FILE was not specified"
26+
show_usage
27+
exit 1
28+
elif [[ ! -f "${FILE}" ]] ; then
29+
echo "${FILE} does not exist or is not a file "
30+
show_usage
31+
exit 1
32+
fi
33+
1934
jq -a '(.. | .password? | strings | select( . = startswith("crypt_v1"))) |= "${p?:cics.password}" | (.. | .ks_password? | strings | select( . = startswith("crypt_v1"))) |= "${p?:cics.kspassword}" | (.. | .ts_password? | strings | select( . = startswith("crypt_v1"))) |= "${p?:cics.tspassword}"' "${FILE}" > "${TEMP}"
2035

36+
RC=$?
37+
if [[ $RC -gt 0 ]] ; then
38+
echo "Failed with RC = $RC"
39+
rm "${TEMP}"
40+
exit $RC
41+
fi
42+
2143
mv "${TEMP}" "${FILE}"
44+
45+
echo "Done"

0 commit comments

Comments
 (0)