From f7b5f773b15460377617865fdc88f9b7e7ab6132 Mon Sep 17 00:00:00 2001 From: Maxime Menault Date: Mon, 16 Sep 2024 20:36:19 +0200 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"/"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 29 ++++++++++++++ README.md | 31 +++++++++++++++ exemple_1.c | 25 ++++++++++++ exemple_2.c | 41 +++++++++++++++++++ install-ping-report.sh | 90 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 216 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 exemple_1.c create mode 100644 exemple_2.c create mode 100644 install-ping-report.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f5086ee --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..f13c785 --- /dev/null +++ b/README.md @@ -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 diff --git a/exemple_1.c b/exemple_1.c new file mode 100644 index 0000000..88d6256 --- /dev/null +++ b/exemple_1.c @@ -0,0 +1,25 @@ +#include +#include +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; +} + diff --git a/exemple_2.c b/exemple_2.c new file mode 100644 index 0000000..4a1f8f1 --- /dev/null +++ b/exemple_2.c @@ -0,0 +1,41 @@ +#include +#include +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; +} diff --git a/install-ping-report.sh b/install-ping-report.sh new file mode 100644 index 0000000..087491c --- /dev/null +++ b/install-ping-report.sh @@ -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