Compare commits
2 Commits
f303507dfe
...
c31fc58874
Author | SHA1 | Date | |
---|---|---|---|
|
c31fc58874 | ||
|
3ae1664737 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.o
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"iostream": "cpp"
|
||||
}
|
||||
}
|
6
Makefile
6
Makefile
@ -1,9 +1,9 @@
|
||||
ECHO = @echo
|
||||
GCC = gcc
|
||||
GCC = g++
|
||||
RM = @rm -f
|
||||
CCFLAGS = -c -g -ansi -pedantic -Wall #optimization?
|
||||
OBJETS = $(SRC:.c=.o)
|
||||
SRC = $(wildcard *.c)
|
||||
OBJETS = $(SRC:.cpp=.o)
|
||||
SRC = $(wildcard *.cpp)
|
||||
EXE = deployer
|
||||
LIBRARIES =
|
||||
|
||||
|
10
Module.cpp
Normal file
10
Module.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// deployer Module implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
Module::Module(char * serv):service(serv){}
|
||||
Module::~Module(){}
|
||||
|
||||
|
21
Module.h
Normal file
21
Module.h
Normal file
@ -0,0 +1,21 @@
|
||||
// deployer Module header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(MODULE_H)
|
||||
#define MODULE_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Module
|
||||
{
|
||||
protected:
|
||||
Module(char * serv);
|
||||
virtual ~Module();
|
||||
|
||||
private:
|
||||
bool activated; //true if the service requires this module
|
||||
char * service;
|
||||
|
||||
};
|
||||
#endif
|
45
Services.cpp
Normal file
45
Services.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
// deployer Services implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
#include <unistd.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include "Services.h"
|
||||
|
||||
Services::Services(const char *ServicesCSV)
|
||||
{
|
||||
services=readServicesFromCSV(ServicesCSV);
|
||||
}
|
||||
Services::~Services(){}
|
||||
|
||||
|
||||
vector <serviceData> Services::readServicesFromCSV (const char *CSV) const {
|
||||
vector <serviceData> result;
|
||||
FILE *streamServices=fopen(CSV,"r");
|
||||
if (streamServices==NULL){
|
||||
cout << "Invalid services.csv file." << endl;
|
||||
}else{
|
||||
char line [1000];
|
||||
int userID;
|
||||
string username;
|
||||
string serveur;
|
||||
list <string> serveurs;
|
||||
while(fgets(line,sizeof(line),streamServices)!=NULL){
|
||||
userID=atoi(strtok(line,";"));
|
||||
username=strtok(NULL,";");
|
||||
//while loop
|
||||
serveur=strtok(NULL,";");
|
||||
cout << serveur << " ";
|
||||
while(!serveur.empty()){
|
||||
serveur=strtok(NULL,";");
|
||||
//serveurs.push_back(serveur);
|
||||
cout << serveur << " ";
|
||||
}
|
||||
//serviceData entry = {userID,username,serveurs};
|
||||
//cout << entry.userID <<entry.username << entry.serveurs.front() << endl;
|
||||
//result.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
32
Services.h
Normal file
32
Services.h
Normal file
@ -0,0 +1,32 @@
|
||||
// deployer Services header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(SERVICES_H)
|
||||
#define SERVICES_H
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct serviceData {
|
||||
int userID;
|
||||
string username;
|
||||
list <string> serveurs;
|
||||
};
|
||||
|
||||
class Services
|
||||
//extracts the list of uid|username|service from the services.csv file
|
||||
{
|
||||
public:
|
||||
Services(const char * servicesCSV="services.csv");
|
||||
~Services();
|
||||
private:
|
||||
vector <serviceData> readServicesFromCSV (const char *CSV) const;
|
||||
vector <serviceData> services;
|
||||
|
||||
};
|
||||
#endif
|
BIN
Services.o
Normal file
BIN
Services.o
Normal file
Binary file not shown.
36
main.c
36
main.c
@ -1,36 +0,0 @@
|
||||
// deployer main programm
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int DEPLOY=false;
|
||||
int REMOVE=false;
|
||||
|
||||
void help()
|
||||
{
|
||||
printf("usage: ./deployer action file \n with action=deploy or remove and file=path to a file or all. \n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3){
|
||||
printf("Invalid number of arguments. \n");
|
||||
help();
|
||||
exit(1);
|
||||
} else {
|
||||
if (strcmp(argv[1], "deploy")==0){
|
||||
DEPLOY=true;
|
||||
} else if (strcmp(argv[1], "remove")==0){
|
||||
REMOVE=true;
|
||||
} else {
|
||||
printf("Invalid argument. \n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
46
main.cpp
Normal file
46
main.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// deployer main programm
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include "Services.h"
|
||||
#include "Module.h"
|
||||
using namespace std;
|
||||
|
||||
bool action_deploy=false;
|
||||
bool action_remove=false;
|
||||
bool all=false;
|
||||
|
||||
void help()
|
||||
{
|
||||
//temporary
|
||||
cout << "usage: ./deployer action file \n with action=deploy or remove and file=path to a file or all. \n" << endl;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3){
|
||||
cout << "Invalid number of arguments. \n" << endl;
|
||||
help();
|
||||
exit(1);
|
||||
} else {
|
||||
if (strcmp(argv[1],"deploy")==0){
|
||||
action_deploy=true;
|
||||
} else if (strcmp(argv[1],"remove")==0){
|
||||
action_remove=true;
|
||||
} else {
|
||||
cout << "Invalid argument. \n" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Services myServices=Services("services.csv");
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
112
services.csv
112
services.csv
@ -1,57 +1,55 @@
|
||||
# This is not real CSV. Do not put separator in a field, even escaped
|
||||
# ID ; username ; service name ; server name
|
||||
1;sftp.jean-cloud.net;sftp.jean-cloud.net;raku.jean-cloud.org
|
||||
#2;benevoles31.karnaval.fr;benevoles31.karnaval.fr;max.jean-cloud.org
|
||||
3;builder.rimarima.fr;builder.rimarima.fr;raku.jean-cloud.org
|
||||
5;chiloe.eu;chiloe.eu;shlago.jean-cloud.org
|
||||
7;collectif-arthadie.fr;collectif-arthadie.fr;izzo.jean-cloud.org
|
||||
8;compagnienouvelle.fr;compagnienouvelle.fr;shlago.jean-cloud.org
|
||||
9;copaines.jean-cloud.net;copaines.jean-cloud.net;shlago.jean-cloud.org
|
||||
11;deployer.jean-cloud.org;deployer.jean-cloud.org;shlago.jean-cloud.org
|
||||
12;dnscerts.jean-cloud.org;dnscerts.jean-cloud.org;montbonnot.jean-cloud.org
|
||||
13;etrevivant.net;etrevivant.net;shlago.jean-cloud.org
|
||||
14;feministesucl34.communistesliber;feministesucl34.communisteslibertaires.org;none
|
||||
15;feteducourt.jean-cloud.net;feteducourt.jean-cloud.net;shlago.jean-cloud.org
|
||||
16;feteducourt2020.jean-cloud.net;feteducourt2020.jean-cloud.net;shlago.jean-cloud.org
|
||||
17;git.jean-cloud.net;git.jean-cloud.net;izzo.jean-cloud.org
|
||||
20;inurbe.fr;inurbe.fr;shlago.jean-cloud.org
|
||||
21;jean-cloud.net;jean-cloud.net;shlago.jean-cloud.org
|
||||
22;leida.fr;leida.fr;shlago.jean-cloud.org
|
||||
23;lexicographe.jean-cloud.net;lexicographe.jean-cloud.net;shlago.jean-cloud.org
|
||||
24;metamorphosemagazine.fr;metamorphosemagazine.fr;shlago.jean-cloud.org
|
||||
25;mux.radiodemo.oma-radio.fr;mux.radiodemo.oma-radio.fr;raku.jean-cloud.org
|
||||
26;nc-backup.jean-cloud.net;nc-backup.jean-cloud.net;raku.jean-cloud.org
|
||||
27;ns.jean-cloud.org;ns.jean-cloud.org;nowhere
|
||||
28;ns1.jean-cloud.org;ns1.jean-cloud.org;izzo.jean-cloud.org
|
||||
29;nuage.jean-cloud.net;nuage.jean-cloud.net;izzo.jean-cloud.org
|
||||
30;oma-radio.fr;oma-radio.fr;izzo.jean-cloud.org
|
||||
31;pa1.studios.oma-radio.fr;pa1.studios.oma-radio.fr;tetede.jean-cloud.org
|
||||
32;paj.oma-radio.fr;paj.oma-radio.fr;nougaro.jean-cloud.org
|
||||
33;quadrille-elsa.jean-cloud.net;quadrille-elsa.jean-cloud.net;shlago.jean-cloud.org
|
||||
34;radiodemo.oma-radio.fr;radiodemo.oma-radio.fr;raku.jean-cloud.org
|
||||
35;radionimaitre.oma-radio.fr;radionimaitre.oma-radio.fr;tetede.jean-cloud.org
|
||||
36;raplacgr.jean-cloud.net;raplacgr.jean-cloud.net;izzo.jean-cloud.org
|
||||
37;rimarima.fr;rimarima.fr;raku.jean-cloud.org
|
||||
38;rpnow.jean-cloud.net;rpnow.jean-cloud.net;izzo.jean-cloud.org
|
||||
39;soundbase.radiodemo.oma-radio.fr;soundbase.radiodemo.oma-radio.fr;montbonnot.jean-cloud.org
|
||||
40;static.jean-cloud.net;static.jean-cloud.net;izzo.jean-cloud.org
|
||||
41;velov.jean-cloud.net;velov.jean-cloud.net;shlago.jean-cloud.org
|
||||
42;wiki-cgr.jean-cloud.net;wiki-cgr.jean-cloud.net;izzo.jean-cloud.org
|
||||
43;radio.karnaval.fr;radio.karnaval.fr;tetede.jean-cloud.org
|
||||
44;wordpress.abc.jean-cloud.net;wordpress.abc.jean-cloud.net;raku.jean-cloud.org
|
||||
45;jean-cloud.org;jean-cloud.org;shlago.jean-cloud.org
|
||||
46;soundbase.paj.oma-radio.fr;soundbase.paj.oma-radio.fr;montbonnot.jean-cloud.org
|
||||
47;backup-borg-server;backup-borg-server;montbonnot.jean-cloud.org
|
||||
48;backup-borg-client;backup-borg-client;raku.jean-cloud.org
|
||||
49;soundbase.radionimaitre.oma;soundbase.radionimaitre.oma-radio.fr;montbonnot.jean-cloud.org
|
||||
50;monitoring.jean-cloud.net;monitoring.jean-cloud.net;montbonnot.jean-cloud.org
|
||||
51;benevoles32.karnaval.fr;benevoles32.karnaval.fr;izzo.jean-cloud.org
|
||||
52;nginx_exporter;nginx_exporter;shlago.jean-cloud.org
|
||||
#54;accent.jean-cloud.net;accent.jean-cloud.net;raku.jean-cloud.org
|
||||
55;gaia.jean-cloud.net;gaia.jean-cloud.net;shlago.jean-cloud.org
|
||||
56;association-chahut.fr;association-chahut.fr;izzo.jean-cloud.org
|
||||
57;mutubot.jean-cloud.net;mutubot.jean-cloud.net;izzo.jean-cloud.org
|
||||
59;lyon1.studios.oma-radio.fr;lyon1.studios.oma-radio.fr;izzo.jean-cloud.org
|
||||
60;soundbase.radiokipik.org;soundbase.radiokipik.org;montbonnot.jean-cloud.org
|
||||
61;radiokipik.org;radiokipik.org;izzo.jean-cloud.org
|
||||
62;mux.radiokipik.org;mux.radiokipik.org;izzo.jean-cloud.org
|
||||
1;sftp.jean-cloud.net;raku.jean-cloud.org;pourdefaux
|
||||
#2;benevoles31.karnaval.fr;max.jean-cloud.org
|
||||
3;builder.rimarima.fr;raku.jean-cloud.org
|
||||
5;chiloe.eu;shlago.jean-cloud.org
|
||||
7;collectif-arthadie.fr;izzo.jean-cloud.org
|
||||
8;compagnienouvelle.fr;shlago.jean-cloud.org
|
||||
9;copaines.jean-cloud.net;shlago.jean-cloud.org
|
||||
11;deployer.jean-cloud.org;shlago.jean-cloud.org
|
||||
12;dnscerts.jean-cloud.org;montbonnot.jean-cloud.org
|
||||
13;etrevivant.net;shlago.jean-cloud.org
|
||||
14;feministesucl34.communistesliber;none
|
||||
15;feteducourt.jean-cloud.net;shlago.jean-cloud.org
|
||||
16;feteducourt2020.jean-cloud.net;shlago.jean-cloud.org
|
||||
17;git.jean-cloud.net;izzo.jean-cloud.org
|
||||
20;inurbe.fr;shlago.jean-cloud.org
|
||||
21;jean-cloud.net;shlago.jean-cloud.org
|
||||
22;leida.fr;shlago.jean-cloud.org
|
||||
23;lexicographe.jean-cloud.net;shlago.jean-cloud.org
|
||||
24;metamorphosemagazine.fr;shlago.jean-cloud.org
|
||||
25;mux.radiodemo.oma-radio.fr;raku.jean-cloud.org
|
||||
26;nc-backup.jean-cloud.net;raku.jean-cloud.org
|
||||
27;ns.jean-cloud.org;nowhere
|
||||
28;ns1.jean-cloud.org;izzo.jean-cloud.org
|
||||
29;nuage.jean-cloud.net;izzo.jean-cloud.org
|
||||
30;oma-radio.fr;izzo.jean-cloud.org
|
||||
31;pa1.studios.oma-radio.fr;tetede.jean-cloud.org
|
||||
32;paj.oma-radio.fr;nougaro.jean-cloud.org
|
||||
33;quadrille-elsa.jean-cloud.net;shlago.jean-cloud.org
|
||||
34;radiodemo.oma-radio.fr;raku.jean-cloud.org
|
||||
35;radionimaitre.oma-radio.fr;tetede.jean-cloud.org
|
||||
36;raplacgr.jean-cloud.net;izzo.jean-cloud.org
|
||||
37;rimarima.fr;raku.jean-cloud.org
|
||||
38;rpnow.jean-cloud.net;izzo.jean-cloud.org
|
||||
39;soundbase.radiodemo.oma-radio.fr;montbonnot.jean-cloud.org
|
||||
40;static.jean-cloud.net;izzo.jean-cloud.org
|
||||
41;velov.jean-cloud.net;shlago.jean-cloud.org
|
||||
42;wiki-cgr.jean-cloud.net;izzo.jean-cloud.org
|
||||
43;radio.karnaval.fr;tetede.jean-cloud.org
|
||||
44;wordpress.abc.jean-cloud.net;raku.jean-cloud.org
|
||||
45;jean-cloud.org;shlago.jean-cloud.org
|
||||
46;soundbase.paj.oma-radio.fr;montbonnot.jean-cloud.org
|
||||
47;backup-borg-server;montbonnot.jean-cloud.org
|
||||
48;backup-borg-client;raku.jean-cloud.org
|
||||
49;soundbase.radionimaitre.oma;montbonnot.jean-cloud.org
|
||||
50;monitoring.jean-cloud.net;montbonnot.jean-cloud.org
|
||||
51;benevoles32.karnaval.fr;izzo.jean-cloud.org
|
||||
52;nginx_exporter;shlago.jean-cloud.org
|
||||
#54;accent.jean-cloud.net;raku.jean-cloud.org
|
||||
55;gaia.jean-cloud.net;shlago.jean-cloud.org
|
||||
56;association-chahut.fr;izzo.jean-cloud.org
|
||||
57;mutubot.jean-cloud.net;izzo.jean-cloud.org
|
||||
59;lyon1.studios.oma-radio.fr;izzo.jean-cloud.org
|
||||
60;soundbase.radiokipik.org;montbonnot.jean-cloud.org
|
||||
61;radiokipik.org;izzo.jean-cloud.org
|
||||
62;mux.radiokipik.org;izzo.jean-cloud.org
|
||||
|
|
Loading…
Reference in New Issue
Block a user