Add commit hash on banner

This commit is contained in:
Davidson Francis 2024-05-30 20:49:35 -03:00
parent 4760bd2fbe
commit 18efb5f77e
2 changed files with 13 additions and 4 deletions

View File

@ -7,6 +7,7 @@ CC ?= cc
CFLAGS += -Wall -Wextra CFLAGS += -Wall -Wextra
LDLIBS += -pthread -lcurl LDLIBS += -pthread -lcurl
STRIP = strip STRIP = strip
VERSION = v0.1
ifeq ($(LOG_FILE),yes) ifeq ($(LOG_FILE),yes)
CFLAGS += -DUSE_FILE_AS_LOG CFLAGS += -DUSE_FILE_AS_LOG
@ -23,6 +24,11 @@ ifneq ($(CROSS),)
LDFLAGS += -no-pie --static LDFLAGS += -no-pie --static
endif endif
GIT_HASH=$(shell git rev-parse --short HEAD 2>/dev/null || echo '$(VERSION)')
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
.PHONY: all clean
all: alertik Makefile all: alertik Makefile
$(STRIP) --strip-all alertik $(STRIP) --strip-all alertik

View File

@ -449,14 +449,17 @@ int main(void)
"- TELEGRAM_NICKNAME\n"); "- TELEGRAM_NICKNAME\n");
} }
log_msg("Alertik v%s started...\n", ALERTIK_VERSION); log_msg(
"Alertik (" GIT_HASH ") (built at " __DATE__ " " __TIME__ ")\n");
log_msg(" (https://github.com/Theldus/alertik)\n");
log_msg("-------------------------------------------------\n");
fd = create_socket(); fd = create_socket();
if (pthread_create(&handler, NULL, handle_messages, NULL)) if (pthread_create(&handler, NULL, handle_messages, NULL))
panic_errno("Unable to create hanler thread!"); panic_errno("Unable to create hanler thread!");
log_msg("Waiting for messages...\n"); log_msg("Waiting for messages at :%d (UDP)...\n", SYSLOG_PORT);
while (read_new_upd_msg(fd) >= 0); while (read_new_upd_msg(fd) >= 0);
return (EXIT_SUCCESS); return EXIT_SUCCESS;
} }