Commit 7b7db10e authored by Ophélie Gagnard's avatar Ophélie Gagnard

Add standalone-automatoin-script/

Add a standalone version of the automation script. Its main purpose is
to debug the Test Suite producing the reference scan for Wendelin.
(Project OCEAN/Ridge.)
parent 689a58ee
#!/bin/bash
# This script is used to produce a reference database of filesystem scans in Wendelin.
# It automates the process of installing MCA on a KVM.
# It then scans some desired directories. No need to reboot to get a scan.
LOG_FILE=/var/log/test-script-deployment.log
# redirect stdout and stderr to $LOG_FILE
exec >> $LOG_FILE 2>&1
echo DEBUG -------------------------
echo WENDELIN_URL = $WENDELIN_URL
echo WENDELIN_PWD = $WENDELIN_PWD
echo WENDELIN_REFERENCE = $WENDELIN_REFERENCE
echo -------------------------------
apt update --fix-missing
### INSTALL DEPENDENCIES
WENDELIN_REFERENCE=test-suite-002
WENDELIN_PWD=qxrfkwod
MCA_NAME_AND_VERSION=dep--mca--static_1-1
FLUENTBIT_NAME_AND_VERSION=dep--fluent-bit_1-1
URL_PATTERN="https://download.opensuse.org/repositories/home:/fg.nxd/Debian_11/amd64/"
APT_UTILITY_PACKAGES="sudo wget tree"
INSTALL_DEPENDENCIES_PACKAGES="dracut-core dracut dracut-network"
UEFI_KEYS_DEPENDENCIES_PACKAGES="sbsigntool efitools python3"
APT_SPECIFIC_PACKAGES="${INSTALL_DEPENDENCIES_PACKAGES} ${UEFI_KEYS_DEPENDENCIES_PACKAGES}"
MCA_PACKAGE_FILE="${MCA_NAME_AND_VERSION}_amd64.deb"
FLUENTBIT_PACKAGE_FILE="${FLUENTBIT_NAME_AND_VERSION}_amd64.deb"
MCA_PACKAGE_URL=${URL_PATTERN}${MCA_PACKAGE_FILE}
FLUENTBIT_PACKAGE_URL=${URL_PATTERN}${FLUENTBIT_PACKAGE_FILE}
FLB_PATH=/opt/${FLUENTBIT_NAME_AND_VERSION}
MCA_PATH=/opt/${MCA_NAME_AND_VERSION}
MCA_CONF_PATH=${MCA_PATH}/etc/
echo -e "\nInstalling packages from Debian repositories...\n"
# utility packages
apt -y install ${APT_UTILITY_PACKAGES}
# specific packages
apt -y install ${APT_SPECIFIC_PACKAGES}
# our own packages
echo -e "\nDownloading packages from OBS repositories...\n"
wget ${MCA_PACKAGE_URL}
wget ${FLUENTBIT_PACKAGE_URL}
echo -e "\nInstalling packages from OBS repositories...\n"
apt -y install ./${MCA_PACKAGE_FILE}
apt -y install ./${FLUENTBIT_PACKAGE_FILE}
# temporary: while the fluent-bit packages does not come with its own template file "etc/flb.conf.in"
cat > ${MCA_CONF_PATH}flb.conf.in << "EOF"
[SERVICE]
flush 5
[INPUT]
name tail
path /var/log/metadata_collect.log
refresh_interval 2
[output]
name fluentbit_wendelin
match *
streamtool_uri https://softinst157546.host.vifib.net/erp5/portal_ingestion_policies/metadata_upload
user zope
password %WENDELIN_PWD%
buffer_type memory
flush_interval 60s
disable_retry_limit true
reference %WENDELIN_REFERENCE%
EOF
CONF_REGEX="s|%WENDELIN_REFERENCE%|${WENDELIN_REFERENCE}|g;s|%WENDELIN_PWD%|${WENDELIN_PWD}|g"
sed "${CONF_REGEX}" ${MCA_CONF_PATH}/flb.conf.in > ${MCA_CONF_PATH}/flb.conf
echo DEBUG -------------------------
echo tree /opt:
tree /opt
echo -------------------------------
### SCAN THE DESIRED DIRECTORIES
BINARY=${MCA_PATH}/bin/metadata-collect-agent
FLB=${FLB_PATH}/bin/fluent-bit
FLB_PLUGIN=${MCA_PATH}/lib/libfluentbit_wendelin.so
FLB_CONF=${MCA_PATH}/etc/flb.conf
LOG=/var/log/metadata_collect.log
PATH_TO_SCAN=/bin
echo -e "\nScanning and sending content in $PATH_TO_SCAN ...\n"
${BINARY} ${PATH_TO_SCAN} ${FLB} ${FLB_PLUGIN} ${FLB_CONF} ${LOG}
PATH_TO_SCAN=/sbin
echo -e "\nScanning and sending content in $PATH_TO_SCAN ...\n"
${BINARY} ${PATH_TO_SCAN} ${FLB} ${FLB_PLUGIN} ${FLB_CONF} ${LOG}
echo -e "\nBuild successful, connect to:\n"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment