bugs nginx prepare et bash scripts repares, debut deploy nginx marce

This commit is contained in:
eleonore12345 2024-08-15 16:00:02 +02:00
parent 59eb1768a1
commit 180561618b
3 changed files with 12 additions and 14 deletions

View File

@ -4,6 +4,7 @@
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include "BashManager.h"
#include "NginxModule.h" #include "NginxModule.h"
using namespace std; using namespace std;
namespace fs=filesystem; namespace fs=filesystem;
@ -62,21 +63,17 @@ int NginxModule::Deploy (string serviceUsername)
//copy the conf from the service directory to the nginx directory //copy the conf from the service directory to the nginx directory
string conf="./services/"+serviceUsername+"/nginx_server.conf"; string conf="./services/"+serviceUsername+"/nginx_server.conf";
string new_nginx_conf_path=getenv("NEW_NGINX_CONF_PATH"); string new_nginx_conf_path=getenv("NEW_NGINX_CONF_PATH");
//nginx dir
fs::create_directories(new_nginx_conf_path + "/" + serviceUsername);
fs::copy(conf,new_nginx_conf_path+"/"+serviceUsername);
string newConf=new_nginx_conf_path + "/" + serviceUsername + "/nginx_server.conf";
//replace the environment variables with their values //replace the environment variables with their values
//string cmd="set -a && envsubst "+conf; string cmd="envsubst < "+ conf + " > " + newConf;
BashManager::Execute(cmd);
/*
if [ -f "/docker/$service/nginx_server.conf" ] ; then
section "Copy nginx conf"
run cp "/docker/$service/nginx_server.conf" "$new_nginx_conf_path/$service"
section "Template nginx conf with vars from '.env' file"
run template.sh "/docker/$service/.env" < "/docker/$service/nginx_server.conf" > "$new_nginx_conf_path/
(template : bash -c 'set -a && . '"$1"' && envsubst "$(cat '"$1"' | grep -o ^.*= | sed "s/=//" | sed "s/^/$/")"')
$service"
fi*/
//test new conf
//cmd = "nginx -t -c /etc/nginx/new_nginx.conf && echo $?"
//string res = BashManager
return 0; return 0;
} }

View File

@ -2,5 +2,6 @@ FROM ubuntu:22.04
WORKDIR /usr/src/deployer_test WORKDIR /usr/src/deployer_test
RUN mkdir -p etc/nginx /etc/nginx/sites-enabled /etc/nginx/new-sites-enabled /data/dnscerts.jean-cloud.org/certs/live/ /etc/letsencrypt/live RUN mkdir -p etc/nginx /etc/nginx/sites-enabled /etc/nginx/new-sites-enabled /data/dnscerts.jean-cloud.org/certs/live/ /etc/letsencrypt/live
RUN touch /etc/letsencrypt/live/dummy RUN touch /etc/letsencrypt/live/dummy
#RUN apt-get install gettext-base
CMD ["sh"] CMD ["sh"]