mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
Securing v-update-host-certificate and few small fixes
This commit is contained in:
parent
9decddd657
commit
38b7557beb
1 changed files with 23 additions and 4 deletions
27
bin/v-update-host-certificate
Normal file → Executable file
27
bin/v-update-host-certificate
Normal file → Executable file
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: update hosts certificates for exim, dovecot & vesta-web
|
# info: update hosts certificates for exim, dovecot & vesta-nginx
|
||||||
# options: user
|
# options: user
|
||||||
# options: hostname
|
# options: hostname
|
||||||
#
|
#
|
||||||
|
@ -10,6 +10,13 @@
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ] && [ "$whoami" != "admin" ] ; then
|
||||||
|
echo "You must be root or admin to execute this script";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Argument definition
|
# Argument definition
|
||||||
user=$1
|
user=$1
|
||||||
hostname=$2
|
hostname=$2
|
||||||
|
@ -33,6 +40,11 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_object_valid 'web' 'DOMAIN' "$hostname"
|
is_object_valid 'web' 'DOMAIN' "$hostname"
|
||||||
is_object_unsuspended 'web' 'DOMAIN' "$hostname"
|
is_object_unsuspended 'web' 'DOMAIN' "$hostname"
|
||||||
|
|
||||||
|
if [ ! -f "/home/$user/conf/web/ssl.$hostname.pem" ]; then
|
||||||
|
echo "This domain does not have certificate";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -48,9 +60,16 @@ backup_datetime=`date '+%Y-%m-%d_%H-%M-%S'`
|
||||||
cp /home/$user/conf/web/ssl.$hostname.pem $VESTA/ssl/certificate.crt
|
cp /home/$user/conf/web/ssl.$hostname.pem $VESTA/ssl/certificate.crt
|
||||||
cp /home/$user/conf/web/ssl.$hostname.key $VESTA/ssl/certificate.key
|
cp /home/$user/conf/web/ssl.$hostname.key $VESTA/ssl/certificate.key
|
||||||
|
|
||||||
|
# Checking exim username for later chowning
|
||||||
|
exim_user="exim";
|
||||||
|
check_exim_username=$(grep -c '^Debian-exim:' /etc/passwd)
|
||||||
|
if [ "$check_exim_username" -eq 1 ]; then
|
||||||
|
exim_user="Debian-exim"
|
||||||
|
fi
|
||||||
|
|
||||||
# Assign exim permissions
|
# Assign exim permissions
|
||||||
chown exim:mail $VESTA/ssl/certificate.crt
|
chown $exim_user:mail $VESTA/ssl/certificate.crt
|
||||||
chown exim:mail $VESTA/ssl/certificate.key
|
chown $exim_user:mail $VESTA/ssl/certificate.key
|
||||||
|
|
||||||
# Restart exim, dovecot & vesta
|
# Restart exim, dovecot & vesta
|
||||||
v-restart-mail
|
v-restart-mail
|
||||||
|
@ -64,4 +83,4 @@ v-restart-web-backend
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$ARGUMENTS"
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
exit
|
exit 0;
|
Loading…
Add table
Add a link
Reference in a new issue