]> git.giorgioravera.it Git - scripts.git/commitdiff
Fixed some open points
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 28 Sep 2020 18:39:11 +0000 (20:39 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 28 Sep 2020 18:39:11 +0000 (20:39 +0200)
pve-snapshots
update_certificate

index e383e5e21c2a2fae6054fd7e920a9bcd038438a8..ce5beecb1d120c9fca415b16617c7e16d7d0fb9c 100755 (executable)
@@ -55,7 +55,7 @@ parse_options ()
 
        # Check Options
        OPT=$(getopt -o i:p:s:k: --long id:,prefix:,storage:,keep: -n "$NAME parse-error" -- "$@")i
-       if [ $? != 0 ]; then
+       if [ $? != 0 ] || [ $# -eq 0 ]; then
                usage
        fi
        eval set -- "$OPT"
index f30f2c87278eae056ec94b776443b5c24152ebdf..a05f571f8f205b4eb8bebb175bb14439148e534a 100755 (executable)
@@ -18,8 +18,9 @@ dst_tmp_key="$dst_tmp_folder/key.pem"
 dst_tmp_server="$dst_tmp_folder/server.pem"
 PATH="$PATH:/usr/local/bin"
 
-# Update Function
-function update_certificate () {
+# Copy Certificate
+# Copy Certificate in $dst folder
+function copy_certificate () {
        ALIVE=$(ping -c 1 $host |grep ttl)
        if [ ! -z "$ALIVE" ]; then
                ssh $user@$host mkdir -p $dst_folder
@@ -35,7 +36,9 @@ function update_certificate () {
        fi
 }
 
-function copy_certificate () {
+# Update Certificate
+# Create a temporary file to update the old one using $command
+function update_certificate () {
        ALIVE=$(ping -c 1 $host |grep ttl)
        if [ ! -z "$ALIVE" ]; then
                scp $src_cert $user@$host:$dst_tmp_cert
@@ -57,7 +60,7 @@ function copy_certificate () {
 #user="root"
 #command="/etc/init.d/apache2 restart"
 ##command="systemctl restart apache2.service"
-#update_certificate
+#copy_certificate
 #echo ""
 
 # Docker
@@ -67,7 +70,7 @@ echo " ------------------------------- "
 host="docker.giorgioravera.it"
 user="root"
 command="docker container restart traefik mosquitto"
-update_certificate
+copy_certificate
 echo ""
 
 # Asterisk
@@ -84,7 +87,7 @@ command="cat $dst_tmp_cert > /etc/asterisk/keys/Asterisk.crt &&
         fwconsole certificate --default=0 &&
         fwconsole reload &&
         systemctl reload httpd.service"
-copy_certificate
+update_certificate
 echo ""
 
 # NAS
@@ -95,7 +98,7 @@ host="nas.giorgioravera.it"
 user="admin"
 command="cat $dst_tmp_server > /etc/stunnel/stunnel.pem &&
        /etc/init.d/stunnel.sh restart"
-copy_certificate
+update_certificate
 echo ""
 
 # Firewall
@@ -120,5 +123,5 @@ host="xenserver.giorgioravera.it"
 user="root"
 command="cat $dst_tmp_server > /etc/xensource/xapi-ssl.pem &&
         systemctl restart xapi.service"
-copy_certificate
+update_certificate
 echo ""