mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
Merge pull request #1317 from robindirksen1/patch-4
Create v-update-host-certificate
This commit is contained in:
commit
9decddd657
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