From f33ecb8a38ad8c391bc8e9b289bf1bcf7243651e Mon Sep 17 00:00:00 2001 From: nzrst <52141515+nzrst@users.noreply.github.com> Date: Mon, 1 Jul 2019 19:29:09 -0400 Subject: [PATCH 1/2] Makefile installs systemd service file --- Makefile | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0e7374f..5e4b6fd 100644 --- a/Makefile +++ b/Makefile @@ -61,15 +61,38 @@ install: @install -v -o root -g root -m 644 -p fw1-loggrabber.conf ${INSTALL_ETC_DIR}/fw1-loggrabber.conf-sample @install -v -o root -g root -m 644 -p lea.conf ${INSTALL_ETC_DIR}/lea.conf-sample @install -v -o root -g root -m 644 -t ${INSTALL_LIB_DIR} ${OPSEC_LIB_DIR}/*.so +ifeq ($(shell test -d /etc/ld.so.conf.d && echo -n yes),yes) + @echo + @echo "** ldconfig detected, adding ${INSTALL_LIB_DIR}." + @install -v -o root -g root -m 644 -p install/ldconfig/fw1-loggrabber.conf /etc/ld.so.conf.d/fw1-loggrabber.conf + rm /etc/ld.so.cache + ldconfig + @echo +endif +ifeq ($(shell test -d /etc/systemd/system && echo -n yes),yes) + @install -v -o root -g root -m 644 -p install/systemd/fw1-loggrabber.service /etc/systemd/system/fw1-loggrabber.service + systemctl daemon-reload + systemctl enable fw1-loggrabber + @echo + @echo + @echo "Installation complete! After configuration files are set you may start the service with the following command;" + @echo + @echo " systemctl start fw1-loggrabber" +else + @echo @echo @echo "Installation complete! Please declare the following environment variables in your shell configuration file:" @echo - @echo " LD_LIBRARY_PATH=\$$LD_LIBRARY_PATH:${INSTALL_LIB_DIR}" - @echo " export LD_LIBRARY_PATH" @echo " LOGGRABBER_CONFIG_PATH=${INSTALL_ETC_DIR}" @echo " export LOGGRABBER_CONFIG_PATH" @echo " LOGGRABBER_TEMP_PATH=${TEMP_DIR}" @echo " export LOGGRABBER_TEMP_PATH" +endif +ifneq ($(shell test -d /etc/ld.so.conf.d && echo -n yes),yes) + @echo " LD_LIBRARY_PATH=\$$LD_LIBRARY_PATH:${INSTALL_LIB_DIR}" + @echo " export LD_LIBRARY_PATH" +endif + @echo @echo clean: From 380e5c25f19f1df9fd6a3feb8abc07697b22f37f Mon Sep 17 00:00:00 2001 From: nzrst <52141515+nzrst@users.noreply.github.com> Date: Mon, 1 Jul 2019 19:29:27 -0400 Subject: [PATCH 2/2] Makefile installs systemd service file --- install/ldconfig/fw1-loggrabber.conf | 1 + install/systemd/fw1-loggrabber.service | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 install/ldconfig/fw1-loggrabber.conf create mode 100755 install/systemd/fw1-loggrabber.service diff --git a/install/ldconfig/fw1-loggrabber.conf b/install/ldconfig/fw1-loggrabber.conf new file mode 100755 index 0000000..19a0d82 --- /dev/null +++ b/install/ldconfig/fw1-loggrabber.conf @@ -0,0 +1 @@ +/usr/local/fw1-loggrabber/lib \ No newline at end of file diff --git a/install/systemd/fw1-loggrabber.service b/install/systemd/fw1-loggrabber.service new file mode 100755 index 0000000..afd0ac6 --- /dev/null +++ b/install/systemd/fw1-loggrabber.service @@ -0,0 +1,16 @@ +[Unit] +Description=fw1-loggrabber +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +Environment=LOGGRABBER_CONFIG_PATH=/usr/local/fw1-loggrabber/etc +WorkingDirectory=/usr/local/fw1-loggrabber +ExecStart=/usr/local/fw1-loggrabber/bin/fw1-loggrabber +Restart=always +RestartSec=5 +TimeoutSec=5min + +[Install] +WantedBy=multi-user.target \ No newline at end of file