]> WPIA git - nre.git/blob - generateCRLs.sh
Adding crl generation to all.sh
[nre.git] / generateCRLs.sh
1 #!/bin/bash
2
3 set -e
4
5 [ "$1" == "" ] && echo "Usage: $0 <year>" && exit 1
6 year=$1
7
8 . structure
9 . commonFunctions
10
11 generateCRL() { # name, year, month
12     echo CRL $1 $2-$3
13     BASE="$PWD"
14     pushd $1.ca > /dev/null
15     TZ=UTC LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 FAKETIME="${year}-${month}-01 00:00:00" openssl ca -gencrl -config "$BASE/selfsign.config" -keyfile key.key -cert key.crt -crldays 35 -out $2_$3.crl
16     popd > /dev/null
17 }
18
19 generateCRLs (){ #name start
20     [[ "$2" == "" ]] && start=$(echo {01..12})
21     [[ "$2" == "07" ]] && start=$(echo {07..12})
22     for month in $start; do
23         generateCRL "$1" "$year" "$month"
24     done
25 }
26
27 generateYearCRLs (){ #name idx
28     [[ "$2" == "1" ]] && start=$(echo {01..12})
29     [[ "$2" == "2" ]] && start=$(echo {07..12})
30     for month in $start; do
31         generateCRL "$1" "$year" "$month"
32     done
33     [[ "$2" == "1" ]] && start=$(echo {01..12})
34     [[ "$2" == "2" ]] && start=$(echo {01..12})
35     for month in $start; do
36         generateCRL "$1" "$((year+1))" "$month"
37     done
38     [[ "$2" == "1" ]] && return
39     [[ "$2" == "2" ]] && start=$(echo {01..06})
40     for month in $start; do
41         generateCRL "$1" "$((year+2))" "$month"
42     done
43 }
44 generateCRLs root
45 for ca in $STRUCT_CAS; do
46     generateCRLs $ca
47 done
48
49 for i in ${TIME_IDX}; do
50 generateYearCRLs $year/ca/env_${year}_$i $i
51 generateYearCRLs $year/ca/env_${year}_$i $i
52
53 done