From b4c4f2de49fa2ac59ec932e65668d979b4f7a415 Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Mon, 28 Sep 2020 20:39:11 +0200 Subject: [PATCH] Fixed some open points --- pve-snapshots | 2 +- update_certificate | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pve-snapshots b/pve-snapshots index e383e5e..ce5beec 100755 --- a/pve-snapshots +++ b/pve-snapshots @@ -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" diff --git a/update_certificate b/update_certificate index f30f2c8..a05f571 100755 --- a/update_certificate +++ b/update_certificate @@ -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 "" -- 2.47.3