Introducing: v-install-unsigned-ssl DOMAIN

This commit is contained in:
myvesta 2020-06-27 02:25:56 +02:00 committed by GitHub
commit b93623e865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,59 @@
#!/bin/bash
# Script will install unsigned SSL to desired domain
if [ $# -lt 1 ]; then
echo "usage: v-install-unsigned-ssl DOMAIN"
exit 1
fi
domain=$1
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
if [ ! -d "/home/$user" ]; then
echo "User doesn't exist";
exit 1;
fi
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
echo "Domain doesn't exist";
exit 1;
fi
email="info@$domain"
TMPLOC="/home/$user/tmp/$domain"
mkdir $TMPLOC
# Generating SSL certificate
/usr/local/vesta/bin/v-generate-ssl-cert $domain $email 'US' 'California' 'San Francisco' 'myVesta Control Panel' 'IT' "www.$domain" > $TMPLOC/vst.pem
# Parsing certificate file
crt_end=$(grep -n "END CERTIFICATE-" $TMPLOC/vst.pem |cut -f 1 -d:)
key_start=$(grep -n "BEGIN RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
key_end=$(grep -n "END RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
# Adding SSL certificate
cd $TMPLOC
sed -n "1,${crt_end}p" $TMPLOC/vst.pem > $TMPLOC/$domain.crt
sed -n "$key_start,${key_end}p" $TMPLOC/vst.pem > $TMPLOC/$domain.key
chmod 666 $TMPLOC/*
source /usr/local/vesta/func/domain.sh
USER_DATA="/usr/local/vesta/data/users/$user";
get_domain_values 'web'
if [[ $SSL == 'no' ]]
then
#Configure SSL and install the cert
/usr/local/vesta/bin/v-add-web-domain-ssl $user $domain $TMPLOC
else
#Replace the existing cert with the new one
/usr/local/vesta/bin/v-change-web-domain-sslcert $user $domain $TMPLOC
fi
rm -rf $TMPLOC
exit 0