Téléverser les fichiers vers "/"

This commit is contained in:
Maxime Menault 2024-09-16 20:36:19 +02:00
commit f7b5f773b1
5 changed files with 216 additions and 0 deletions

29
Makefile Normal file
View File

@ -0,0 +1,29 @@
CC=gcc
CFLAGS=-W -Wall -pedantic
LDFLAGS=-lsqlite3
EXEC=ping-report
SRC=$(wildcard src/*.c)
OBJ=$(SRC:.c=.o)
all : $(EXEC)
ping-report : $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
rm -f src/*.o
ping-report.o : include/daemon.h
daemon.o : include/stats.h include/utils.h
stats.o : include/utils.h
%.o : src/%.c
$(CC) -o $@ -c $< $(CFLAGS) -lsqlite
.PHONY: clean mrproper
clean :
rm -f src/*.o
mrproper : clean
rm -f ping-report

31
README.md Normal file
View File

@ -0,0 +1,31 @@
# ping-report
## Installation
Lancer la commande suivante pour installer ping-report :
> sudo ./install-ping-report.sh
## Utilisation
Lancer la commande **ping-report start** afin de lancer le daemon :
> ping-report start
Lancer la commande **ping-report end** afin d'arreter le daemon :
> ping-report end
Lancer la commande **ping-report restart** afin de relancer le daemon :
> ping-report restart
Lancer la commande **ping-report status** afin de voir le status du daemon :
> ping-report status
## Arborescence fichier
### src
dossier contenant les fichiers sources du programme
### include
dossier contenant les fichiers d'en-tête du programme
### res
dossier contenant les fichiers ressources du programme
## Descriptions fonctions

25
exemple_1.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
int a = 12;
int b = 34;
int c = 56;
int d = 29;
if(a < 10){
b = a+c;
}
else{
c = a*a;
if(b > c){
b++;
}
else{
a = b + c;
}
}
return a;
}

41
exemple_2.c Normal file
View File

@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
char* lotid = "XL012770XA";
char* operid = "PPHHXGNA";
char* toolid = "DD99";
switch(lotid[5]){
case '4':
if(operid[1] == 'P' && operid[2] == 'H') printf("Start Lithography process for monitor lot\n");
else printf("Not a right operation ...\n");
break;
case '7':
if(toolid[0] != 'W'){
if(operid[1] == 'C'){
if(lotid[0] == 'X' && lotid[1] =='A') printf("Start Polishing process for priority lot\n");
else switch(lotid[9])
{
case 'A':
printf("Wrong lot, must not use Copper layers\n");
break;
case 'B':
printf("Warning, will not start Aluminum lot on Polishing process\n");
break;
default:
printf("Unknown lot !\n");
}
}
else printf("Wrong operation type !\n");
}
else{
if(lotid[9] == 'A') printf("Start Etch process ofor priority lot\n");
else printf("Can't start process, must be a Copper lot\n");
}
break;
default:
printf("Unknown lot type !\n");
break;
}
return 0;
}

90
install-ping-report.sh Normal file
View File

@ -0,0 +1,90 @@
#!/bin/bash
#Variables
CUR_DIR=`pwd`
OPT_DIR=/opt/ping-report
BIN_OPT_DIR=/opt/ping-report/bin
BIN_DIR=/bin
LOG_DIR=/var/log/ping-report
STATUS_LOG=/var/log/ping-report/status.log
DB_SCRIPT=./res/ping-report-db.sql
DB_DIR=/srv/ping-report
DB=/srv/ping-report/ping-report.db
BIN=ping-report
SCRIPT=./res/ping-report.sh
SCRIPT_DIR=/opt/ping-report/ping-report.sh
DYN_LINK=/bin/ping-report
#Start install script
#Check 1st arg
case $1 in
--full-install) rm $DB;
echo "full install of ping-report ...";;
-f) rm $DB;
echo "full install of ping-report ...";;
*) echo "default install of ping-report ...";;
esac
#Create OPT_DIR
if test -d "$OPT_DIR"; then
echo "opt dir already exists, no actions needed."
else
mkdir $OPT_DIR
fi
#Create BIN_OPT_DIR
if test -d "$BIN_OPT_DIR"; then
echo "bin opt dir already exists, no actions needed."
else
mkdir $BIN_OPT_DIR
fi
#Create LOG_DIR
if test -d "$LOG_DIR"; then
echo "log dir already exists, no actions needed"
else
mkdir $LOG_DIR
fi
#Create / Erase STATUS_LOG
touch $STATUS_LOG
chmod 666 $STATUS_LOG
#Create DB_DIR
if test -d "$DB_DIR"; then
echo "database dir already exists, no actions needed"
else
mkdir $DB_DIR
fi
#Compile ping-report
make
#Move ping-report bin to BIN_OPT_DIR
mv $BIN $BIN_OPT_DIR
#Copy launch script to OPT_DIR
cp $SCRIPT $OPT_DIR
#Create DYN_LINK
if test -f "$DYN_LINK"; then
echo "dynamic link already exists, no actions needed."
else
#Change current directory to /bin to create dynamic link
cd $BIN_DIR
#Create the dynamic link to SCRIPT
ln -s $SCRIPT_DIR $BIN
#Change directory to the previous one
cd $CUR_DIR
fi
#Create SQLITE DB
if test -f "$DB"; then
echo "db already exists, no actions needed"
else
cd $DB_DIR
sqlite3 ping-report.db < $CUR_DIR/$DB_SCRIPT
cd $CUR_DIR
fi