From b93623e865a995a9eb096b79d77fdefb9a128eb4 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Sat, 27 Jun 2020 02:25:56 +0200 Subject: [PATCH] Introducing: v-install-unsigned-ssl DOMAIN --- bin/v-install-unsigned-ssl | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bin/v-install-unsigned-ssl diff --git a/bin/v-install-unsigned-ssl b/bin/v-install-unsigned-ssl new file mode 100644 index 00000000..e0fdd46d --- /dev/null +++ b/bin/v-install-unsigned-ssl @@ -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