#!/bin/bash # renew the lets encrypt ftp certificate # @author roland renew() { info "the folder is $folder" # remove the old certificate rm /etc/ssl/private/pure-ftpd.pem # create the new certificate cat /etc/letsencrypt/live/$folder/privkey.pem /etc/letsencrypt/live/$folder/fullchain.pem > /etc/ssl/private/pure-ftpd.pem # restart pureftp service pure-ftpd-mysql restart info "ftp certificate renewed" } # output help usage() { echo "usage: sh renew-ftp-cert.sh [-hw] [-c certs]"; echo "-h this help"; echo "-w output all warnings"; echo "-c certs choose the folder with certificates, for example: server1.example.com"; } # output warnings log() { if [ $LOGLEVEL -gt 0 ]; then echo "$@"; fi } # output additional messages info() { if [[ $LOGLEVEL == 2 ]]; then echo "$@"; fi } # options params="$(getopt -o hwfc: -l help --name "$cmdname" -- "$@")" if [ $? -ne 0 ]; then usage fi eval set -- "$params" unset params while true do case "$1" in -w) LOGLEVEL=2;; -c) folder="$2"; renew; shift;; -h|--help) usage exit;; --) shift break;; *) exit;; esac shift done