#!/bin/bash FILE_REGEXP='\(.*\)-\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\).crt' REPO="$1" if [[ -z "$REPO" || ! -d "$REPO/SSL/" || ! -d "$REPO/.git" ]]; then echo "Usage: $0 " >&2 exit 1 fi change=0 cd "$REPO" >/dev/null for cert in /var/cache/spline-ssl/* ; do if read host date ; then if [[ -n "$host" && -n "$date" ]]; then mkdir -p "SSL/$host/" mv "$cert" "SSL/$host/$host-$date.crt" git add "SSL/$host/$host-$date.crt" git commit --no-verify --quiet \ --author="SSL Cert Syncer " \ --message="SSL: Automatic ssl cert sync Add cert for $host." \ "SSL/$host/$host-$date.crt" ((change++)) fi fi < <(basename "$cert" | sed "s/$FILE_REGEXP/\1 \2/") done if [[ $change -gt 0 ]]; then echo "Moved $change certificates into repo, you may want to call $(tput bold)renew-config$(tput sgr0) now." fi