Syntax fixes

This commit is contained in:
2025-01-10 12:00:37 +01:00
parent ed96958a3a
commit 6d456c5430

View File

@@ -18,18 +18,18 @@ set -ou pipefail
########################################################### ###########################################################
function INFO { function INFO {
echo "$1" echo "$1"
echo "$1" | systemd-cat -p info -t "$(basename "$0" .sh)" echo "$1" | systemd-cat -p info -t "$(basename "$0" .sh)"
} }
function WARNING { function WARNING {
echo "WARNING: $1" >&2 echo "WARNING: $1" >&2
echo "$1" | systemd-cat -p warning -t "$(basename "$0" .sh)" echo "$1" | systemd-cat -p warning -t "$(basename "$0" .sh)"
} }
function ERROR { function ERROR {
echo "ERROR: $1" >&2 echo "ERROR: $1" >&2
echo "$1" | systemd-cat -p err -t "$(basename "$0" .sh)" echo "$1" | systemd-cat -p err -t "$(basename "$0" .sh)"
} }
########################################################### ###########################################################
@@ -42,75 +42,75 @@ ERR=0
# Create directory if not exists # Create directory if not exists
if [[ ! -d $PATHCRL ]]; then if [[ ! -d $PATHCRL ]]; then
if ! mkdir -p $PATHCRL; then if ! mkdir -p $PATHCRL; then
ERROR "Could not create $PATHCRL!" ERROR "Could not create $PATHCRL!"
exit 2 exit 2
fi fi
fi fi
for CRL in "${CRL[@]}" for CRL in "${CRL[@]}"
do do
URLCRL=https://cacher.rz.uni-greifswald.de/$CRL.pem URLCRL=https://cacher.rz.uni-greifswald.de/$CRL.pem
# Download CRL # Download CRL
if ! /usr/bin/timeout 5s wget -q -O "/tmp/$CRL.pem" "$URLCRL"; then if ! /usr/bin/timeout 5s wget -q -O "/tmp/$CRL.pem" "$URLCRL"; then
ERROR "Could not download $CRL!" ERROR "Could not download $CRL!"
ERR=1 ERR=1
continue continue
fi fi
# Verify CRL # Verify CRL
if ! /usr/bin/openssl crl -CApath "$PATHSSL" -in "/tmp/$CRL.pem" -noout > /dev/null 2>&1; then if ! /usr/bin/openssl crl -CApath "$PATHSSL" -in "/tmp/$CRL.pem" -noout > /dev/null 2>&1; then
ERROR "Could not verify $CRL against $PATHSSL!" ERROR "Could not verify $CRL against $PATHSSL!"
ERR=1 ERR=1
rm -f "/tmp/$CRL.pem" rm -f "/tmp/$CRL.pem"
continue continue
fi fi
# Check CRL validity # Check CRL validity
CRLDATETIME=$(openssl crl -in "/tmp/$CRL.pem" -nextupdate -noout | sed 's/nextUpdate=//g') CRLDATETIME=$(openssl crl -in "/tmp/$CRL.pem" -nextupdate -noout | sed 's/nextUpdate=//g')
VALIDUNTIL=$(date -d "$CRLDATETIME" +%s) VALIDUNTIL=$(date -d "$CRLDATETIME" +%s)
if [[ "$VALIDUNTIL" -lt $(date +%s) ]]; then if [[ "$VALIDUNTIL" -lt $(date +%s) ]]; then
ERROR "$CRL is invalid!" ERROR "$CRL is invalid!"
ERR=1 ERR=1
rm -f "/tmp/$CRL.pem" rm -f "/tmp/$CRL.pem"
continue continue
fi fi
# Move CRL to final destination path # Move CRL to final destination path
if ! mv -f "/tmp/$CRL.pem" "$PATHCRL/$CRL.pem"; then if ! mv -f "/tmp/$CRL.pem" "$PATHCRL/$CRL.pem"; then
ERROR "Could not move CRL to $PATHCRL!" ERROR "Could not move CRL to $PATHCRL!"
ERR=1 ERR=1
rm -f "/tmp/$CRL.pem" rm -f "/tmp/$CRL.pem"
continue continue
fi fi
# Link CRL # Link CRL
if [[ ! -L "$PATHSSL"/"$CRL.pem" ]]; then if [[ ! -L "$PATHSSL"/"$CRL.pem" ]]; then
if ! ln -s "$PATHCRL"/"$CRL.pem" "$PATHSSL"/"$CRL.pem"; then if ! ln -s "$PATHCRL"/"$CRL.pem" "$PATHSSL"/"$CRL.pem"; then
ERROR "Could not create CRL link to $PATHSSL!" ERROR "Could not create CRL link to $PATHSSL!"
ERR=1 ERR=1
rm -f "$PATHCRL"/"$CRL.pem" "$PATHSSL"/"$CRL.pem" rm -f "$PATHCRL"/"$CRL.pem" "$PATHSSL"/"$CRL.pem"
continue continue
fi
fi fi
fi
INFO "$CRL successfully updated" INFO "$CRL successfully updated"
done done
# Rehash # Rehash
if /usr/bin/c_rehash -n > /dev/null 2>&1; then if /usr/bin/c_rehash -n > /dev/null 2>&1; then
INFO "Rehash successful" INFO "Rehash successful"
else else
ERROR "Could not rehash $PATHSSL!" ERROR "Could not rehash $PATHSSL!"
exit 2 exit 2
fi fi
# Set runtime information # Set runtime information
if [[ "$ERR" -eq 0 ]]; then if [[ "$ERR" -eq 0 ]]; then
date +%s > "$LASTRUN" date +%s > "$LASTRUN"
fi fi
exit 0 exit 0