From a6c4e91343577ae06cce0786938750300c5c7c8e Mon Sep 17 00:00:00 2001 From: 0x90-n Date: Tue, 30 Jan 2024 20:48:41 -0700 Subject: [PATCH] adding supporting scripts --- scripts/start_registration-tracker.sh | 23 +++++++++++++++++++++++ sysconfig/conjure-reg-tracker.service | 20 ++++++++++++++++++++ sysconfig/conjure_regtrack.conf | 19 +++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 scripts/start_registration-tracker.sh create mode 100644 sysconfig/conjure-reg-tracker.service create mode 100644 sysconfig/conjure_regtrack.conf diff --git a/scripts/start_registration-tracker.sh b/scripts/start_registration-tracker.sh new file mode 100755 index 00000000..d3d31f84 --- /dev/null +++ b/scripts/start_registration-tracker.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Run Conjure registration tracker process using configs in environment variables. + +if [ $(id -u) -ne 0 ]; then + echo "$0 must be run as sudo" + exit 1 +fi + +# load config. will access config in /var/lib/conjure for overrides +set -a +source /opt/conjure/sysconfig/conjure_regtrack.conf +set +a + +if [ ! -f $CJ_STATION_CONFIG ]; then + echo "Failed to open \$CJ_STATION_CONFIG=$CJ_STATION_CONFIG." + echo "You may want to set CJ_STATION_CONFIG in the conjure.conf file before running the script" + exit 1 +fi + +echo "station_config path: $CJ_STATION_CONFIG" + +/opt/conjure/bin/registration-tracker diff --git a/sysconfig/conjure-reg-tracker.service b/sysconfig/conjure-reg-tracker.service new file mode 100644 index 00000000..57bd3f96 --- /dev/null +++ b/sysconfig/conjure-reg-tracker.service @@ -0,0 +1,20 @@ +[Unit] +Description=Conjure Registration Tracker + +[Service] +Type=simple + +WorkingDirectory=/opt/conjure/ + +SyslogIdentifier=conjure + +ExecStart=/bin/bash /opt/conjure/scripts/start_registration-tracker.sh + +# send SIGHUP to the station process +ExecReload=/bin/kill -HUP $MAINPID + +# on stop processes will get SIGTERM, and after 10 secs - SIGKILL (default 90) +TimeoutStopSec=10 + +[Install] +WantedBy=multi-user.target diff --git a/sysconfig/conjure_regtrack.conf b/sysconfig/conjure_regtrack.conf new file mode 100644 index 00000000..8c2f13b3 --- /dev/null +++ b/sysconfig/conjure_regtrack.conf @@ -0,0 +1,19 @@ +#!/bin/bash + +# private key used by the detectors +CJ_PRIVKEY=/var/lib/conjure/regtracker_privkey + +# Path to the configuration file for the registratoin tracker +CJ_STATION_CONFIG=/var/lib/conjure/regtrack_config.toml + +# Path to the configuration file containing phantom subnets +PHANTOM_SUBNET_LOCATION=/var/lib/conjure/phantom_subnets.toml + +# Read local configs to allow for override of any of these settings +if [ -r /var/lib/conjure/conjure_regtrack.conf ] && [ -z "${CJ_STOP_RECURSE+x}" ]; then + echo "Applying local configs from /var/lib/conjure/conjure_regtrack.conf" + CJ_STOP_RECURSE="true" + . /var/lib/conjure/conjure_regtrack.conf +fi + +unset CJ_STOP_RECURSE