mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 13:24:24 -07:00
Create v-update-host-certificate
Add a file that's setting the hostname certificate for exim, dovecot & vesta-web so the email is always with a valid LE certificate. # Todo: - add to cronjobs (default every month) of adds to lets encrypt renewall/request when updating system hostname certificate
This commit is contained in:
parent
1b3a30d1ee
commit
593cd34e52
1 changed files with 67 additions and 0 deletions
67
bin/v-update-host-certificate
Normal file
67
bin/v-update-host-certificate
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: update hosts certificates for exim, dovecot & vesta-web
|
||||||
|
# options: user
|
||||||
|
# options: hostname
|
||||||
|
#
|
||||||
|
# Function updates certificates for vesta
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
user=$1
|
||||||
|
hostname=$2
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/ip.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" '[USER] [HOSTNAME]'
|
||||||
|
is_format_valid 'user'
|
||||||
|
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||||
|
is_system_enabled "$WEB_SSL" 'SSL_SUPPORT'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$hostname"
|
||||||
|
is_object_unsuspended 'web' 'DOMAIN' "$hostname"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Get current datetime for backup of old files
|
||||||
|
backup_datetime=`date '+%Y-%m-%d_%H-%M-%S'`
|
||||||
|
|
||||||
|
# Keep a backup of the old certificate - todo: remove in production
|
||||||
|
#mv $VESTA/ssl/certificate.crt $VESTA/ssl/certificate.crt_backup_$backup_datetime
|
||||||
|
#mv $VESTA/ssl/certificate.key $VESTA/ssl/certificate.key_backup_$backup_datetime
|
||||||
|
|
||||||
|
# Copy hostnames certificates from user dir
|
||||||
|
cp /home/$user/conf/web/ssl.$hostname.pem $VESTA/ssl/certificate.crt
|
||||||
|
cp /home/$user/conf/web/ssl.$hostname.key $VESTA/ssl/certificate.key
|
||||||
|
|
||||||
|
# Assign exim permissions
|
||||||
|
chown exim:mail $VESTA/ssl/certificate.crt
|
||||||
|
chown exim:mail $VESTA/ssl/certificate.key
|
||||||
|
|
||||||
|
# Restart exim, dovecot & vesta
|
||||||
|
v-restart-mail
|
||||||
|
v-restart-web-backend
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
Loading…
Add table
Add a link
Reference in a new issue