/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/renew_certs/cpterenacerts.sh
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/renew_certs/cpterenacerts.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2488 - (show annotations) (download) (as text)
Tue Feb 14 15:02:31 2012 UTC (9 years, 11 months ago) by fbernabe
File MIME type: application/x-shellscript
File size: 2812 byte(s)
.

1 #!/bin/bash
2
3 basedir="/export/perm/share/grid-security" #Root directory: Certs, keys, scripts are under it.
4 year=$(( `date +%Y` )) #Current year: Used to create dirs with the certs and keys of the current year.
5 pyear=$(( `date +%Y` - 1)) #Previous year: Used to indicate the dir with the certs and keys of the previous year.
6 certdir="$basedir/terena-certs/$year" #Directory where the certs to install are.
7 terenayear=$pyear"_terena" #Custom name for cert and key directory. Example: 2011_terena
8 tcsyear=$pyear"-tcs" #Custom name for cert and key directory. Example: 2011-tcs
9 terenayearbis=$pyear"terena" #Custom name for cert and key directory. Example: 2011terena
10
11 #Copy the certs
12 certs=`ls -1 $certdir | grep cert`
13
14 echo "These are the certificates"
15 echo "$certs"
16
17 for cert in $certs
18 do
19 pyear=$(( `date +%Y` - 1)) #It needs to be initilizated for every host/cert,
20 # because it might get a custom dir name (_terena,-tcs,terena)
21
22 host=`echo $cert | cut -f 1 -d'.' | sed -e 's/cert-[0-9]*-//g'`
23
24 if [ ! -d "$basedir/$host/$year" ] && [ ! -f "$basedir/$host/$year/usercert.pem" ]
25 then
26 #What's the dir name where the certificate of the previous year are
27
28 if [ -d "$basedir/$host/$tcsyear" ] #Example of dir name = 2011-tcs
29 then
30 pyear=$tcsyear
31
32 elif [ -d "$basedir/$host/$terenayearbis" ] #Example of dir name = 2011terena
33 then
34 pyear=$terenayearbis
35
36 elif [ -d "$basedir/$host/$terenayear" ] #Example of dir name = 2011_terena
37 then
38 pyear=$terenayear
39
40 else
41 echo "No change is needed" #Example of dir name = 2011
42 fi
43
44 mkdir "$basedir/$host/$year"
45 cp "$certdir/$cert" "$basedir/$host/$year"
46 cd "$basedir/$host"
47 rm -f usercert.pem
48 mv "$basedir/$host/$year/$cert" "$basedir/$host/$year/usercert.pem"
49 ln -s "$year/usercert.pem"
50
51 if [ -f "$basedir/$host/$pyear/userkey.pem" ]
52 then
53 cp "$basedir/$host/$pyear/userkey.pem" "$basedir/$host/$year"
54 rm -f userkey.pem
55 ln -s "$year/userkey.pem"
56 touch release.state
57 chown apache:apache release.state
58 host=$host".nikhef.nl"
59 ssh root@$host "/bin/rm /etc/siteinfo/lcg-quattor-site-info.def ; ncm-ncd --configure --all"
60
61 else
62 echo "ERROR: There's no key from previous year, this means that the certificate and key couldn't be installed in $host"
63 fi
64
65 cd -
66 else
67 echo "WARNING: The directory or the certificate already exist. No action needed for $host"
68 fi
69 done

Properties

Name Value
svn:executable *

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28