mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 02:28:05 -07:00
Introducing: v-install-unsigned-ssl DOMAIN
This commit is contained in:
parent
2108e0e32c
commit
b93623e865
1 changed files with 59 additions and 0 deletions
59
bin/v-install-unsigned-ssl
Normal file
59
bin/v-install-unsigned-ssl
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue