diff --git a/src/BashModule.cpp b/src/BashModule.cpp index f2c1103..bb46602 100644 --- a/src/BashModule.cpp +++ b/src/BashModule.cpp @@ -22,6 +22,7 @@ BashModule::BashModule() //private methods int BashModule::executeScript(string serviceUsername, string script) { + cout << "debut execute script" < modules={&bashModule,&nginxModule,&wireguardModule, &encryptionModule}; //&dockerModule \ No newline at end of file +vector modules={&bashModule,&wireguardModule, &encryptionModule}; //&dockerModule,&nginxModule \ No newline at end of file diff --git a/src/SQLmanager.cpp b/src/SQLmanager.cpp new file mode 100644 index 0000000..fbc3212 --- /dev/null +++ b/src/SQLmanager.cpp @@ -0,0 +1,39 @@ +//deployer SLmanager implementation +// Copyright (C) 2024 Jean-Cloud +// GNU General Public License v3 + +#include +#include +#include +#include +#include "Service.h" + +using namespace std; + +//constructor and destructor inlin + +//services +vector GetServices() const; +const Service * FindServiceByUsername(string aUsername) const; +const Service * FindServiceByID(int aUserID) const; +//list FindServicesByServer(string aServer) const; +int isServiceOnServer(string serviceUsername); + +vector services; + + + +//int isServiceOnServer(string serviceUsername) +//this method tests if a certain service is on the current server +//it looks into the /etc/hosts file thanks to a pipe to a separate bash process +// { +// string cmd ="getent hosts " +serviceUsername; +// string result = BashManager::ExecuteAndReadResult(cmd); +// if(result.find("::1")!=string::npos){ //if result contains "::1" which is the notation for loopback in IpV6 +// cout << "service " << serviceUsername << " on server" << endl; +// return 0; +// } +// cout << "service" << serviceUsername << " not on server" << endl; +// return 1; +// return 0; +// } \ No newline at end of file diff --git a/src/SQLmanager.h b/src/SQLmanager.h new file mode 100644 index 0000000..ecf8f9f --- /dev/null +++ b/src/SQLmanager.h @@ -0,0 +1,30 @@ +//deployer SLmanager header +// Copyright (C) 2024 Jean-Cloud +// GNU General Public License v3 + +#if !defined(SQLMANAGER_H) +#define SQLMANAGER_H + +#include +#include +#include +#include +#include "Service.h" + +using namespace std; + +class SQLmanager { + public: + SQLmanager(){} + ~SQLmanager(){} + //services + vector GetServices() const; + const Service * FindServiceByUsername(string aUsername) const; + const Service * FindServiceByID(int aUserID) const; + //list FindServicesByServer(string aServer) const; + int isServiceOnServer(string serviceUsername); + + private: + vector services; +}; +#endif \ No newline at end of file diff --git a/src/deployer b/src/deployer new file mode 100755 index 0000000..80dca02 Binary files /dev/null and b/src/deployer differ diff --git a/src/general.db b/src/general.db new file mode 100644 index 0000000..115aba5 Binary files /dev/null and b/src/general.db differ diff --git a/src/main.cpp b/src/main.cpp index e524bc7..4d960e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,20 +21,7 @@ void help(char * argv0) cout << "usage: ./" << argv0 <<"action file \n with action=deploy or remove and file=path to a file or all. \n" << endl; } -int isServiceOnServer(string serviceUsername) -//this method tests if a certain service is on the current server -//it looks into the /etc/hosts file thanks to a pipe to a separate bash process -{ - string cmd ="getent hosts " +serviceUsername; - string result = BashManager::ExecuteAndReadResult(cmd); - if(result.find("::1")!=string::npos){ //if result contains "::1" which is the notation for loopback in IpV6 - cout << "service " << serviceUsername << " on server" << endl; - return 0; - } - cout << "service" << serviceUsername << " not on server" << endl; - return 1; - return 0; -} + int createUser(string serviceUsername) { @@ -44,6 +31,7 @@ int createUser(string serviceUsername) Services services = Services(); const Service * service = services.FindByUsername(serviceUsername); int uid = (*service).GetUserID()+uidStart; + cout << "uid vaut" << uid << endl; //test if user already exists string cmd = "id -u "+serviceUsername; string res = BashManager::ExecuteAndReadResult (cmd); @@ -60,6 +48,7 @@ int createUser(string serviceUsername) cerr << res2 << endl; return -1; } + cout << "user created " << endl; return 0; } @@ -255,14 +244,13 @@ int deployService(string serviceUsername){ for(Module * mod_ptr : modules){ int modResult = (*mod_ptr).Deploy(serviceUsername); + if (modResult!=0){ //cerr << "Error in " << (*mod_ptr) << " when deploying " << serviceUsername << endl; cerr << "Error in module " << endl; } } return 0; - cerr << "Error creating user and environment of "<