Skip to content

Commit

Permalink
modify rename remote acion to generate cert
Browse files Browse the repository at this point in the history
  • Loading branch information
Hystepik committed Feb 7, 2024
1 parent a60242e commit 2fd3fe5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion myaccount/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@
if (!$error) {
//$object->context["options_websitename"] = $website->ref;
$object->array_options['options_custom_url'] = urlencode($custom_url);
$result = $sellyoursaasutils->sellyoursaasRemoteAction("deploycustomurl", $object);
$result = $sellyoursaasutils->sellyoursaasRemoteAction("rename", $object);
if ($result <= 0) {
$error++;
}
Expand Down
25 changes: 18 additions & 7 deletions scripts/action_suspend_unsuspend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ testorconfirm="confirm"

if [[ "$mode" == "rename" ]]; then

if [[ "$fqn" != "$fqnold" ]]; then
if [[ "$fqnold" !="-.-" ]] && [[ "$fqn" != "$fqnold" ]]; then
echo `date +'%Y-%m-%d %H:%M:%S'`" ***** For instance in $targetdir/$osusername/$dbname, check if new virtual host $fqn exists"

export apacheconf="/etc/apache2/sellyoursaas-online/$fqn.conf"
Expand Down Expand Up @@ -356,14 +356,25 @@ if [[ "$mode" == "rename" ]]; then
# because we added a custom url

# Generate the letsencrypt certificate
# @TODO

# certbot certonly --webroot -w $instancedir -d $customurl
# create links
echo "certbot certonly --webroot -w $instancedir -d $customurl"
certbot certonly --webroot -w $instancedir -d $customurl

# create links
if [[ -e /etc/letsencrypt/live/$customurl/cert.pem ]]; then
echo `date +'%Y-%m-%d %H:%M:%S'`" Link of generated cert file for custom url"
echo "Link certificate for virtualhost with
ln -fs /etc/letsencrypt/live/$customurl/privkey.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl.key
ln -fs /etc/letsencrypt/live/$customurl/cert.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl.crt
ln -fs /etc/letsencrypt/live/$customurl/fullchain.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl-intermediate.crt
"
ln -fs /etc/letsencrypt/live/$customurl/privkey.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl.key
ln -fs /etc/letsencrypt/live/$customurl/cert.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl.crt
ln -fs /etc/letsencrypt/live/$customurl/fullchain.pem /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-$customurl-intermediate.crt
fi
fi

# If custom cert not found, we fallback on the wildcard one for server (will generate a warning, but it will works !)
if [[ -e /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-custom.crt ]]; then
if [[ ! -e /home/admin/wwwroot/dolibarr_documents/sellyoursaas_local/crt/$fqn-custom.crt ]]; then
export webCustomSSLCertificateCRT=$webSSLCertificateCRT
export webCustomSSLCertificateKEY=$webSSLCertificateKEY
export webCustomSSLCertificateIntermediate=$webSSLCertificateIntermediate
Expand Down Expand Up @@ -473,7 +484,7 @@ if [[ "$mode" == "rename" ]]; then


# If we rename instance
if [[ "$fqn" != "$fqnold" ]]; then
if [[ "$fqnold" !="-.-" ]] && [[ "$fqn" != "$fqnold" ]]; then
echo `date +'%Y-%m-%d %H:%M:%S'`" ***** For instance in $targetdir/$osusername/$dbname, delete old virtual name $fqnold"

export apacheconf="/etc/apache2/sellyoursaas-online/$fqnold.conf"
Expand Down

0 comments on commit 2fd3fe5

Please sign in to comment.