]> WPIA git - infra.git/commitdiff
upd: rename certificate renewal commands + add force mode
authorFelix Dörre <felix@dogcraft.de>
Sat, 22 Apr 2017 20:39:33 +0000 (16:39 -0400)
committerFelix Dörre <felix@dogcraft.de>
Fri, 9 Jun 2017 17:11:10 +0000 (19:11 +0200)
Change-Id: Ia98af2321a0d676dc44f987f34262c66d72d7a55

commands
modules/hop/templates/commands.epp

index 0a6251443aad257108e76413af937c4d142a7c8e..4dd7f4d359c750410694ad7ac9b24544fc425586 100755 (executable)
--- a/commands
+++ b/commands
@@ -4,12 +4,16 @@ if [[ "$UID" == 0 ]]; then
     echo "Run script as non-root-user"
     exit
 fi
-if [[ "$com" == "ask quiz certs" ]]; then
+if [[ "$com" == "update certs" || "$com" == "force update certs" ]]; then
+    force=false
+    if [[ "$com" == "force update certs" ]]; then
+        force=true
+    fi
     folder=$(mktemp -d)
     # In argument 1 is the path of the certificates to update: $1.crt and $1.key
     function update_cert {
         name=$1
-        if [[ -f $name.crt ]] && openssl x509 -checkend $((365*24*60*60)) -in $name.crt > /dev/null; then
+        if [[ -f $name.crt ]] && openssl x509 -checkend $((365*24*60*60)) -in $name.crt > /dev/null && ! $force; then
             echo "SKIP $name"
         else
             echo "ISSUE $name"
@@ -51,7 +55,7 @@ if [[ "$com" == "ask quiz certs" ]]; then
     [[ -f $folder/web.req ]] && rm $folder/web.req
     [[ -f $folder/web.key ]] && rm $folder/web.key
     rmdir $folder
-elif [[ "$com" == "reload quiz certs" ]]; then
+elif [[ "$com" == "reload certs" ]]; then
     sudo puppet apply /etc/puppet/code/environments/production/manifests --verbose
     sudo lxc-attach -n front-nginx -- puppet agent --verbose --test
     sudo lxc-attach -n quiz -- puppet agent --verbose --test
index cb1720f8566d1fc1714482db8fb8b13b0e7d1872..8cedfd94055612c4bb4c0c054b0308ee502919d6 100755 (executable)
@@ -1,11 +1,11 @@
 #!/bin/bash
 
 com="$SSH_ORIGINAL_COMMAND"
-if [[ "$com" == "ask quiz certs" ]]; then
-    exec ssh <%=$administrativeUser%>@10.0.3.1 "ask quiz certs"
-elif [[ "$com" == "reload quiz certs" ]]; then
+if [[ "$com" == "update certs" || "$com" == "force update certs" ]]; then
+    exec ssh <%=$administrativeUser%>@10.0.3.1 "$com"
+elif [[ "$com" == "reload certs" ]]; then
     # requires sudo --> requires terminal
-    exec ssh -t <%=$administrativeUser%>@10.0.3.1 "reload quiz certs"
+    exec ssh -t <%=$administrativeUser%>@10.0.3.1 "reload certs"
 elif [[ "$com" == "update crls" ]]; then
     exec ssh  <%=$administrativeUser%>@10.0.3.1 "update crls"
 else