From 6b016ebfd7d0e499eb48c961b4254e24b6e8f3e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lais=20Frig=C3=A9rio?= <lfs@inf.ufpr.br>
Date: Wed, 7 Dec 2016 10:09:57 -0200
Subject: [PATCH] Issue #10: Parse config and proxy file

---
 update/agent/CMakeLists.txt                   |   2 +-
 .../agent/include/agent/linux/datasid-agent.h |  28 +--
 .../agent/include/agent/linux/datasid-check.h |   0
 .../include/agent/linux/datasid-client.h      |   0
 .../include/agent/linux/datasid-common.h      |  12 +-
 .../agent/include/agent/linux/datasid-conf.h  |  70 ++++----
 .../agent/include/agent/linux/datasid-curl.h  |   0
 .../include/agent/linux/datasid-netmon.h      |   0
 .../agent/linux/datasid-network-usage.h       |   0
 .../agent/include/agent/linux/datasid-proxy.h |  28 +--
 .../include/agent/linux/datasid-uninstall.h   |   0
 update/agent/src/client.cpp                   |   0
 update/agent/src/client.h                     |   0
 update/agent/src/linux/datasid-agent.cpp      |  62 +++----
 update/agent/src/linux/datasid-check.cpp      |   0
 update/agent/src/linux/datasid-client.cpp     |   0
 update/agent/src/linux/datasid-common.cpp     |  93 +++-------
 update/agent/src/linux/datasid-conf.cpp       | 163 +++++++++---------
 update/agent/src/linux/datasid-curl.cpp       |   0
 update/agent/src/linux/datasid-netmon.cpp     |   0
 .../agent/src/linux/datasid-network-usage.cpp |   0
 update/agent/src/linux/datasid-parse.cpp      |   6 +-
 update/agent/src/linux/datasid-proxy.cpp      |  65 ++++---
 update/agent/src/linux/datasid-uninstall.cpp  |   0
 24 files changed, 242 insertions(+), 287 deletions(-)
 delete mode 100644 update/agent/include/agent/linux/datasid-check.h
 delete mode 100644 update/agent/include/agent/linux/datasid-client.h
 delete mode 100644 update/agent/include/agent/linux/datasid-curl.h
 delete mode 100644 update/agent/include/agent/linux/datasid-netmon.h
 delete mode 100644 update/agent/include/agent/linux/datasid-network-usage.h
 delete mode 100644 update/agent/include/agent/linux/datasid-uninstall.h
 delete mode 100644 update/agent/src/client.cpp
 delete mode 100644 update/agent/src/client.h
 delete mode 100644 update/agent/src/linux/datasid-check.cpp
 delete mode 100644 update/agent/src/linux/datasid-client.cpp
 delete mode 100644 update/agent/src/linux/datasid-curl.cpp
 delete mode 100644 update/agent/src/linux/datasid-netmon.cpp
 delete mode 100644 update/agent/src/linux/datasid-network-usage.cpp
 delete mode 100644 update/agent/src/linux/datasid-uninstall.cpp

diff --git a/update/agent/CMakeLists.txt b/update/agent/CMakeLists.txt
index 00495959..c8f56b35 100644
--- a/update/agent/CMakeLists.txt
+++ b/update/agent/CMakeLists.txt
@@ -10,7 +10,7 @@ set ( VERSION_MINOR 0 )
 set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
 
 # src : main
-file ( GLOB SOURCES src/*.cpp 
+file ( GLOB SOURCES src/*.cpp )
 
 # src : collect functions - depend on OS
 if ( WIN32 )
diff --git a/update/agent/include/agent/linux/datasid-agent.h b/update/agent/include/agent/linux/datasid-agent.h
index 16325293..5dff862f 100644
--- a/update/agent/include/agent/linux/datasid-agent.h
+++ b/update/agent/include/agent/linux/datasid-agent.h
@@ -26,22 +26,22 @@
 using namespace std;
 
 class Agent{
-	private:
-		string confDir;
-		string logFile;
-		string prefix;
-		string version;
+    private:
+        string confDir;
+        string logFile;
+        string prefix;
+        string version;
 
-	public:
-		void setConfDir(string);
-		void setLogFile(string, string);
-		void setPrefix(string, int);
-		void setVersion(string);
+    public:
+        void setConfDir(string);
+        void setLogFile(string, string);
+        void setPrefix(string, int);
+        void setVersion(string);
 
-		string getConfDir() const;
-		string getLogFile() const;
-		string getPrefix() const;
-		string getVersion() const;
+        string getConfDir() const;
+        string getLogFile() const;
+        string getPrefix() const;
+        string getVersion() const;
 };
 
 string cutString( string str, int tot );
diff --git a/update/agent/include/agent/linux/datasid-check.h b/update/agent/include/agent/linux/datasid-check.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/include/agent/linux/datasid-client.h b/update/agent/include/agent/linux/datasid-client.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/include/agent/linux/datasid-common.h b/update/agent/include/agent/linux/datasid-common.h
index 3f884557..d3c69227 100644
--- a/update/agent/include/agent/linux/datasid-common.h
+++ b/update/agent/include/agent/linux/datasid-common.h
@@ -8,14 +8,14 @@
 using namespace std;
 
 class Common{
-	private:
-		string defaultConf;
+    private:
+        string defaultConf;
 
-	public:
-		void setDefaultConf(string, string);
+    public:
+        void setDefaultConf(string, string);
 
-		string getDefaultConf() const;
-	};
+        string getDefaultConf() const;
+    };
 
 void checkVersionFileExist(Agent& agent);
 void createDirectories(Agent agent, Conf conf);
diff --git a/update/agent/include/agent/linux/datasid-conf.h b/update/agent/include/agent/linux/datasid-conf.h
index f3564a7f..befda28e 100644
--- a/update/agent/include/agent/linux/datasid-conf.h
+++ b/update/agent/include/agent/linux/datasid-conf.h
@@ -32,48 +32,48 @@
 using namespace std;
 
 class Conf{
-	private:
-		string dataDir;
-		string logDir;
-		string proxyConf;
-		string webService;
+    private:
+        string dataDir;
+        string logDir;
+        string proxyConf;
+        string webService;
 
-		int delay;
-		int daysToExpireLog;
-		int updateTries;
-		int updateTimeOut;
+        int delay;
+        int daysToExpireLog;
+        int updateTries;
+        int updateTimeOut;
 
-	public:
-		void setDataDir(string);
-		void setLogDir(string);
-		void setProxyConf(string);
-		void setWebService(string);
+    public:
+        void setDataDir(string);
+        void setLogDir(string);
+        void setProxyConf(string);
+        void setWebService(string);
 
-		void setDelay(int);
-		void setDaysToExpireLog(int);
-		void setUpdateTries(int);
-		void setUpdatTimeOut(int);
+        void setDelay(int);
+        void setDaysToExpireLog(int);
+        void setUpdateTries(int);
+        void setUpdatTimeOut(int);
 
-		string getDataDir() const;
-		string getLogDir() const;
-		string getProxyConf() const;
-		string getWebService() const;
+        string getDataDir() const;
+        string getLogDir() const;
+        string getProxyConf() const;
+        string getWebService() const;
 
-		int getDelay() const;
-		int getDaysToExpireLog() const;
-		int getUpdateTries() const;
-		int getUpdateTimeOut() const;
+        int getDelay() const;
+        int getDaysToExpireLog() const;
+        int getUpdateTries() const;
+        int getUpdateTimeOut() const;
 
-		int sizeDataDir();
-		int sizeLogDir();
-		int sizeProxyConf();
-		int sizeWebService();
-		int sizeDelay();
-		int sizeDaysToExpireLOg();
-		int sizeUpdateTries();
-		int sizeUpdateTimeOut();
+        int sizeDataDir();
+        int sizeLogDir();
+        int sizeProxyConf();
+        int sizeWebService();
+        int sizeDelay();
+        int sizeDaysToExpireLOg();
+        int sizeUpdateTries();
+        int sizeUpdateTimeOut();
 
-	};
+    };
 
 bool checkFileConf(Conf& conf, Agent agent);
 Conf datasid_conf(Agent agent);
diff --git a/update/agent/include/agent/linux/datasid-curl.h b/update/agent/include/agent/linux/datasid-curl.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/include/agent/linux/datasid-netmon.h b/update/agent/include/agent/linux/datasid-netmon.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/include/agent/linux/datasid-network-usage.h b/update/agent/include/agent/linux/datasid-network-usage.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/include/agent/linux/datasid-proxy.h b/update/agent/include/agent/linux/datasid-proxy.h
index 95e971eb..fdd01ef3 100644
--- a/update/agent/include/agent/linux/datasid-proxy.h
+++ b/update/agent/include/agent/linux/datasid-proxy.h
@@ -29,22 +29,22 @@
 using namespace std;
 
 class Proxy{
-	private:
-		string host;
-		string port;
-		string user;
-		string password;
+    private:
+        string host;
+        string port;
+        string user;
+        string password;
 
-	public:
-		void setHost(string);
-		void setPort(string);
-		void setUser(string);
-		void setPassword(string);
+    public:
+        void setHost(string);
+        void setPort(string);
+        void setUser(string);
+        void setPassword(string);
 
-		string getHost() const;
-		string getPort() const;
-		string getUser() const;
-		string getPassword() const;
+        string getHost() const;
+        string getPort() const;
+        string getUser() const;
+        string getPassword() const;
 };
 
 Proxy datasid_proxy(Conf conf);
diff --git a/update/agent/include/agent/linux/datasid-uninstall.h b/update/agent/include/agent/linux/datasid-uninstall.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/client.cpp b/update/agent/src/client.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/client.h b/update/agent/src/client.h
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-agent.cpp b/update/agent/src/linux/datasid-agent.cpp
index db67ee6c..b59ad9a8 100644
--- a/update/agent/src/linux/datasid-agent.cpp
+++ b/update/agent/src/linux/datasid-agent.cpp
@@ -27,19 +27,19 @@ using namespace std;
  */
 
 void Agent::setConfDir(string dir){
-	this->confDir = this->prefix + dir;
+    this->confDir = this->prefix + dir;
 }
 
 void Agent::setLogFile(string logDir, string file){
-	this->logFile = logDir + file;
+    this->logFile = logDir + file;
 }
 
 void Agent::setPrefix(string p, int t){
-	this->prefix = cutString(p,t);
+    this->prefix = cutString(p,t);
 }
 
 void Agent::setVersion(string v){
-	this->version = v;
+    this->version = v;
 }
 
 /*
@@ -47,19 +47,19 @@ void Agent::setVersion(string v){
  */
 
 string Agent::getConfDir() const{
-	return this->confDir;
+    return this->confDir;
 }
 
 string Agent::getLogFile() const{
-	return this->logFile;
+    return this->logFile;
 }
 
 string Agent::getPrefix() const{
-	return this->prefix;
+    return this->prefix;
 }
 
 string Agent::getVersion() const{
-	return this->version;
+    return this->version;
 }
 
 /*
@@ -70,38 +70,30 @@ string Agent::getVersion() const{
 string cutString( string str, int tot){;
     int i=str.size(), count=0;
         while(i-->-1)
-    	if(str[i] == '/')
-    		if(++count == tot)
-    			break;
+        if(str[i] == '/')
+            if(++count == tot)
+                break;
     return str.substr(0,i);	
 }
 
 bool prefixIsSet(string prefix){
-	if(prefix.size() == 0)
-		throw " ERROR: Prefix not set. ";
-	return true;
+    if(prefix.size() == 0)
+        throw " ERROR: Prefix not set. ";
+    return true;
 }
 
 int datasid_agent(){
-	Agent agent;
-	Conf conf;
-	Proxy proxy;
-	Common common;
-
-	/* Set agent prefix */
-	agent.setPrefix(__FILE__, 3);
-
-	/* Run datasid-common.cpp */
-	if(!datasid_common(conf, proxy, agent, common))
-		exit(1);
-
-	/* Check if agent prefix was setted */
-	try{
-		prefixIsSet(agent.getPrefix());
-	}catch(const char* msg){
-		cout << __DATE__ << msg <<  "here" << endl;
-		exit(1);
-	}
-
-	return 1;
+    Agent agent;
+    Conf conf;
+    Proxy proxy;
+    Common common;
+
+    /* Set agent prefix */
+    agent.setPrefix(__FILE__, 3);
+
+    /* Run datasid-common.cpp */
+    if(!datasid_common(conf, proxy, agent, common))
+        exit(1);
+
+    return 1;
 }
diff --git a/update/agent/src/linux/datasid-check.cpp b/update/agent/src/linux/datasid-check.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-client.cpp b/update/agent/src/linux/datasid-client.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-common.cpp b/update/agent/src/linux/datasid-common.cpp
index 839c735a..55be7f51 100644
--- a/update/agent/src/linux/datasid-common.cpp
+++ b/update/agent/src/linux/datasid-common.cpp
@@ -30,7 +30,7 @@ using namespace std;
  */
 
 void Common::setDefaultConf(string defaultConf, string prefix){
-	this->defaultConf = prefix + defaultConf;
+    this->defaultConf = prefix + defaultConf;
 }
 
 /*
@@ -38,7 +38,7 @@ void Common::setDefaultConf(string defaultConf, string prefix){
  */
 
 string Common::getDefaultConf() const{
-	return  this->defaultConf;
+    return  this->defaultConf;
 }
 
 /*
@@ -47,77 +47,40 @@ string Common::getDefaultConf() const{
  */
 
 bool fileExist(const string& file){
-	ifstream myFile (file.c_str(), ios::in);
-	if(myFile.is_open()){
-		myFile.close();
-		return true;
-	}
-	myFile.close();
-	return false;
+    ifstream myFile (file.c_str(), ios::in);
+    if(myFile.is_open()){
+        myFile.close();
+        return true;
+    }
+    myFile.close();
+    return false;
 }
 
-/* 
- * Create "data" and "log" directories if needed
- * c_str() - converte c++ string to c string 
- */
-
-void createDirectories(Agent agent, Conf conf){
-	mkdir(conf.getLogDir().c_str(), 0700);
-	mkdir(conf.getDataDir().c_str(), 0700);
-}
-
-/*
- * checkVersionFileExist Function
- * check if version file exist and set version variable.
- * Otherwise, setted 0.0.0
- */
-
-void checkVersionFileExist(Agent& agent){
-	string versionFile = agent.getConfDir() + "/version";
-	ifstream myFile (versionFile.c_str(), ios::in);
-
-	if(myFile.is_open()){
-		string cnt;
-		myFile >> cnt;
-		agent.setVersion(cnt);
-	}
-		
-	if(agent.getVersion().size() == 0)
-		agent.setVersion("0.0.0");
-
-	myFile.close();
-}
 
 bool datasid_common(Conf& conf, Proxy& proxy, Agent& agent, Common& common){
 
-	try{
-		prefixIsSet(agent.getPrefix());
-	}catch(const char* msg){
-		cout << __DATE__ << msg << endl;
-		return false;
-	}
-
-	/* Read config file and declare only valid variables */
-
-	common.setDefaultConf("/conf/datasid-conf.json", agent.getPrefix());
-	if(!fileExist(common.getDefaultConf())){
-		cout << __DATE__ << "- ERROR: Config file not found. " << endl;
-		return false;
-	} else 
-		conf = datasid_conf(agent);	
+    try{
+        prefixIsSet(agent.getPrefix());
+    }catch(const char* msg){
+        cout << __DATE__ << msg << endl;
+        return false;
+    }
 
-	/* Read proxy file and declare only valid variables */
+    /* Read config file and declare only valid variables */
 
-	if(!fileExist(conf.getProxyConf()))
-		cout << __DATE__ << "- WARNING: Proxy file not found. " << endl;
-	else
-		proxy = datasid_proxy(conf);
+    common.setDefaultConf("/conf/datasid-conf.json", agent.getPrefix());
+    if(!fileExist(common.getDefaultConf())){
+        cout << __DATE__ << "- ERROR: Config file not found. " << endl;
+        return false;
+    } else 
+        conf = datasid_conf(agent);	
 
-	createDirectories(agent, conf);
+    /* Read proxy file and declare only valid variables */
 
-	agent.setConfDir("/conf");
-	agent.setLogFile( conf.getLogDir(), "/datasid-agent.log" );
-	checkVersionFileExist(agent);
+    if(!fileExist(conf.getProxyConf()))
+        cout << __DATE__ << "- WARNING: Proxy file not found. " << endl;
+    else
+        proxy = datasid_proxy(conf);
 
-	return true;
+    return true;
 }
\ No newline at end of file
diff --git a/update/agent/src/linux/datasid-conf.cpp b/update/agent/src/linux/datasid-conf.cpp
index 749c3394..ae42c29b 100644
--- a/update/agent/src/linux/datasid-conf.cpp
+++ b/update/agent/src/linux/datasid-conf.cpp
@@ -31,35 +31,35 @@ using namespace std;
  */
 
 void Conf::setDataDir(string data){
-	this->dataDir = data;
+    this->dataDir = data;
 }
 
 void Conf::setLogDir(string log){
-	this->logDir = log;
+    this->logDir = log;
 }
 
 void Conf::setProxyConf(string p){
-	this->proxyConf = p;
+    this->proxyConf = p;
 }
 
 void Conf::setWebService(string web){
-	this->webService = web;
+    this->webService = web;
 }
 
 void Conf::setDelay(int d){
-	this->delay = d;
+    this->delay = d;
 }
 
 void Conf::setDaysToExpireLog(int d){
-	this->daysToExpireLog = d;
+    this->daysToExpireLog = d;
 }
 
 void Conf::setUpdateTries(int u){
-	this->updateTries = u;
+    this->updateTries = u;
 }
 
 void Conf::setUpdatTimeOut(int u){
-	this->updateTimeOut = u;
+    this->updateTimeOut = u;
 }
 
 /*
@@ -67,35 +67,35 @@ void Conf::setUpdatTimeOut(int u){
  */
 
 string Conf::getDataDir() const{
-	return  this->dataDir;
+    return  this->dataDir;
 }
 
 string Conf::getLogDir() const{
-	return this->logDir;
+    return this->logDir;
 }
 
 string Conf::getProxyConf() const{
-	return this->proxyConf;
+    return this->proxyConf;
 }
 
 string Conf::getWebService() const{
-	return this->webService;
+    return this->webService;
 }
 
 int Conf::getDelay() const{
-	return this->delay;
+    return this->delay;
 }
 
 int Conf::getDaysToExpireLog() const{
-	return this->daysToExpireLog;
+    return this->daysToExpireLog;
 }
 
 int Conf::getUpdateTries() const{
-	return this->updateTries;
+    return this->updateTries;
 }
 
 int Conf::getUpdateTimeOut() const{
-	return this->updateTimeOut;
+    return this->updateTimeOut;
 }
 
 /*
@@ -104,43 +104,43 @@ int Conf::getUpdateTimeOut() const{
  */
 
 int Conf::sizeDataDir() {
-	return this->dataDir.size();
+    return this->dataDir.size();
 }
 
 int Conf::sizeLogDir() {
-	return this->logDir.size();
+    return this->logDir.size();
 }
 
 int Conf::sizeProxyConf() {
-	return this->proxyConf.size();
+    return this->proxyConf.size();
 }
 
 int Conf::sizeWebService() {
-	return this->webService.size();
+    return this->webService.size();
 }
 
 int Conf::sizeDelay() {
-	ostringstream convert; 
-	convert << this->delay;
-	return (convert.str()).size();
+    ostringstream convert; 
+    convert << this->delay;
+    return (convert.str()).size();
 }
 
 int Conf::sizeDaysToExpireLOg() {
-	ostringstream convert; 
-	convert << this->daysToExpireLog;
-	return (convert.str()).size();
+    ostringstream convert; 
+    convert << this->daysToExpireLog;
+    return (convert.str()).size();
 }
 
 int Conf::sizeUpdateTries() {
-	ostringstream convert; 
-	convert << this->updateTries;
-	return (convert.str()).size();
+    ostringstream convert; 
+    convert << this->updateTries;
+    return (convert.str()).size();
 }
 
 int Conf::sizeUpdateTimeOut() {
-	ostringstream convert; 
-	convert << this->updateTimeOut;
-	return (convert.str()).size();
+    ostringstream convert; 
+    convert << this->updateTimeOut;
+    return (convert.str()).size();
 }
 
 /*
@@ -150,56 +150,57 @@ int Conf::sizeUpdateTimeOut() {
  */
 
 bool setConf(Conf& conf, Agent agent, map<string,string>& content){
-	if(content.count("DATADIR") == 0 || 
-		content.count("LOGDIR") == 0 || 
-		content.count("PROXYCONF") == 0 ||
-		content.count("WEBSERVICE") == 0|| 
-		content.count("DELAY") == 0 ||
-		content.count("DAYSTOEXPIRELOG") == 0 ||
-		content.count("UPDATETRIES") == 0 ||
-		content.count("UPDATETIMEOUT") == 0 )
-			return false;
-
-	/* 
-	 * agent.getPrefix() contains the absolute path of the agent. 
-	 */
-
-	string dataDir = agent.getPrefix() + content["DATADIR"];
-	string dataLog = agent.getPrefix() + content["LOGDIR"];
-	string proxyConf = agent.getPrefix() + content["PROXYCONF"];
-	string webService = content["WEBSERVICE"];
-	int delay = atoi(content["DELAY"].c_str()); /* 24 hours */
-	int daysToExpireLog = atoi(content["DAYSTOEXPIRELOG"].c_str()); /* 1 month */
-	int updateTries = atoi(content["UPDATETRIES"].c_str());
-	int updateTimeOut = atoi(content["UPDATETIMEOUT"].c_str());
-
-	conf.setDataDir(dataDir);
-	conf.setLogDir(dataLog);
-	conf.setProxyConf(proxyConf);
-	conf.setWebService(webService);
-
-	conf.setDelay(delay);
-	conf.setDaysToExpireLog(daysToExpireLog);
-	conf.setUpdateTries(updateTries);
-	conf.setUpdatTimeOut(updateTimeOut);
-
-	return true;
+    if(content.count("DATADIR") == 0 || 
+        content.count("LOGDIR") == 0 || 
+        content.count("PROXYCONF") == 0 ||
+        content.count("WEBSERVICE") == 0|| 
+        content.count("DELAY") == 0 ||
+        content.count("DAYSTOEXPIRELOG") == 0 ||
+        content.count("UPDATETRIES") == 0 ||
+        content.count("UPDATETIMEOUT") == 0 )
+            return false;
+
+    /* 
+     * agent.getPrefix() contains the absolute path of the agent. 
+     */
+
+    string dataDir = agent.getPrefix() + content["DATADIR"];
+    string dataLog = agent.getPrefix() + content["LOGDIR"];
+    string proxyConf = agent.getPrefix() + content["PROXYCONF"];
+    string webService = content["WEBSERVICE"];
+	
+    int delay = atoi(content["DELAY"].c_str()); /* 24 hours */
+    int daysToExpireLog = atoi(content["DAYSTOEXPIRELOG"].c_str()); /* 1 month */
+    int updateTries = atoi(content["UPDATETRIES"].c_str());
+    int updateTimeOut = atoi(content["UPDATETIMEOUT"].c_str());
+
+    conf.setDataDir(dataDir);
+    conf.setLogDir(dataLog);
+    conf.setProxyConf(proxyConf);
+    conf.setWebService(webService);
+
+    conf.setDelay(delay);
+    conf.setDaysToExpireLog(daysToExpireLog);
+    conf.setUpdateTries(updateTries);
+    conf.setUpdatTimeOut(updateTimeOut);
+
+    return true;
 }
 
 Conf datasid_conf(Agent agent){
-	map<string, string> content;
-	string confFile = agent.getPrefix() + "/conf/datasid-conf.json";
-	Conf conf;
-
-	if(readfile(confFile, content)){
-		if(!setConf(conf, agent, content)){
-			cout << __DATE__ << " ERROR: to parse variables from config file." << endl;
-			exit(1);
-		}
-	}else {
-		cout << __DATE__ << " ERROR: config file not found." << endl;
-		exit(1);
-	}
-
-	return conf;
+    map<string, string> content;
+    string confFile = agent.getPrefix() + "/conf/datasid-conf.json";
+    Conf conf;
+
+    if(readfile(confFile, content)){
+        if(!setConf(conf, agent, content)){
+            cout << __DATE__ << " ERROR: to parse variables from config file." << endl;
+            exit(1);
+        }
+    }else {
+        cout << __DATE__ << " ERROR: config file not found." << endl;
+        exit(1);
+    }
+
+    return conf;
 }
\ No newline at end of file
diff --git a/update/agent/src/linux/datasid-curl.cpp b/update/agent/src/linux/datasid-curl.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-netmon.cpp b/update/agent/src/linux/datasid-netmon.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-network-usage.cpp b/update/agent/src/linux/datasid-network-usage.cpp
deleted file mode 100644
index e69de29b..00000000
diff --git a/update/agent/src/linux/datasid-parse.cpp b/update/agent/src/linux/datasid-parse.cpp
index 5807c703..df75d1fe 100644
--- a/update/agent/src/linux/datasid-parse.cpp
+++ b/update/agent/src/linux/datasid-parse.cpp
@@ -116,15 +116,15 @@ bool isvalid (string& line) {
 }
 
 void parse ( string& line, map<string, string>& content){
-	locale loc;
+    locale loc;
     // if the line is a variable + value
     if (line[0] == '"') {
 
         string name = line.substr (1, line.find (':')-2);
         for(int i = 0; i < name.length(); i++)
-        	name[i] = toupper(name[i], loc);
+            name[i] = toupper(name[i], loc);
 
-		string value = line.substr (line.find (':')+2); 
+        string value = line.substr (line.find (':')+2); 
         value = value.substr(0,value.find ('"'));
 
         content[name] = value;
diff --git a/update/agent/src/linux/datasid-proxy.cpp b/update/agent/src/linux/datasid-proxy.cpp
index d18989b3..5a749db3 100644
--- a/update/agent/src/linux/datasid-proxy.cpp
+++ b/update/agent/src/linux/datasid-proxy.cpp
@@ -30,19 +30,19 @@ using namespace std;
  */
 
 void Proxy::setHost(string h){
-	this->host = h;
+    this->host = h;
 }
 
 void Proxy::setPort(string p){
-	this->port = p;
+    this->port = p;
 }
 
 void Proxy::setUser(string u){
-	this->user = u;
+    this->user = u;
 }
 
 void Proxy::setPassword(string p){
-	this->password = p;
+    this->password = p;
 }
 
 /*
@@ -50,36 +50,35 @@ void Proxy::setPassword(string p){
  */
 
 string Proxy::getHost() const{
-	return this->host;
+    return this->host;
 }
 
 string Proxy::getPort() const{
-	return this->port;
+    return this->port;
 }
 
 string Proxy::getUser() const{
-	return this->user;
+    return this->user;
 }
 
 string Proxy::getPassword() const{
-	return this->password;
+    return this->password;
 }
 
 
 bool setProxy(Proxy& proxy, map<string,string>& content){
-	if(content.count("PROXYHOST") == 0 || 
-		content.count("PROXYPORT") == 0 || 
-		content.count("PROXYUSER") == 0 ||
-		content.count("PROXYPASSWORD") == 0)
-			return false;
-
-	proxy.setHost(content["PROXYHOST"] );
-	proxy.setPort(content["PROXYPORT"]);
-	proxy.setUser(content["PROXYUSER"]);
-	proxy.setPassword(content["PROXYPASSWORD"]);
-
-
-	return true;
+    if(content.count("PROXYHOST") == 0 || 
+        content.count("PROXYPORT") == 0 || 
+        content.count("PROXYUSER") == 0 ||
+        content.count("PROXYPASSWORD") == 0)
+            return false;
+
+    proxy.setHost(content["PROXYHOST"] );
+    proxy.setPort(content["PROXYPORT"]);
+    proxy.setUser(content["PROXYUSER"]);
+    proxy.setPassword(content["PROXYPASSWORD"]);
+
+    return true;
 }
 
 /*
@@ -88,17 +87,17 @@ bool setProxy(Proxy& proxy, map<string,string>& content){
  */
 
 Proxy datasid_proxy(Conf conf){
-	Proxy proxy;
-	map<string,string> content;
-	string proxyFile = conf.getProxyConf();
-
-	if(readfile(proxyFile, content)){
-		if(!setProxy(proxy, content)){
-			cout << __DATE__ << " ERROR: to parse variables from proxy file." << endl;
-			exit(1);
-		}
-	} else
-		cout << __DATE__ << " WARNING: proxy file not found." << endl;
+    Proxy proxy;
+    map<string,string> content;
+    string proxyFile = conf.getProxyConf();
+
+    if(readfile(proxyFile, content)){
+        if(!setProxy(proxy, content)){
+            cout << __DATE__ << " ERROR: to parse variables from proxy file." << endl;
+            exit(1);
+        }
+    } else
+        cout << __DATE__ << " WARNING: proxy file not found." << endl;
 	
-	return proxy;
+    return proxy;
 }
\ No newline at end of file
diff --git a/update/agent/src/linux/datasid-uninstall.cpp b/update/agent/src/linux/datasid-uninstall.cpp
deleted file mode 100644
index e69de29b..00000000
-- 
GitLab