mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-06-02 08:25:51 +02:00
Restore 3/dev soup and add postgres users to post_to_3.1.0
feature/postgres had rewritten the 3.1.0 upgrade block, dropping the elastic upgrade work 3/dev landed for 9.0.8→9.3.3: elasticsearch_backup_index_templates, the component template state cleanup, and the /usr/sbin/so-kibana-space-defaults post-upgrade call. It also carried an older ES upgrade mapping (8.18.8→9.0.8) that was superseded on 3/dev (9.0.8→9.3.3 for 3.0.0-20260331), and a handful of latent shell-quoting regressions in verify_es_version_compatibility and the intermediate-upgrade helpers. Adopt the 3/dev soup verbatim and only add the new Telegraf Postgres provisioning to post_to_3.1.0 on top of so-kibana-space-defaults.
This commit is contained in:
@@ -363,8 +363,7 @@ preupgrade_changes() {
|
|||||||
echo "Checking to see if changes are needed."
|
echo "Checking to see if changes are needed."
|
||||||
|
|
||||||
[[ "$INSTALLEDVERSION" =~ ^2\.4\.21[0-9]+$ ]] && up_to_3.0.0
|
[[ "$INSTALLEDVERSION" =~ ^2\.4\.21[0-9]+$ ]] && up_to_3.0.0
|
||||||
[[ "$INSTALLEDVERSION" == 3.0.0 ]] && up_to_3.1.0
|
[[ "$INSTALLEDVERSION" == "3.0.0" ]] && up_to_3.1.0
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +372,7 @@ postupgrade_changes() {
|
|||||||
echo "Running post upgrade processes."
|
echo "Running post upgrade processes."
|
||||||
|
|
||||||
[[ "$POSTVERSION" =~ ^2\.4\.21[0-9]+$ ]] && post_to_3.0.0
|
[[ "$POSTVERSION" =~ ^2\.4\.21[0-9]+$ ]] && post_to_3.0.0
|
||||||
[[ "$POSTVERSION" =~ 3.0.0 ]] && post_to_3.1.0
|
[[ "$POSTVERSION" == "3.0.0" ]] && post_to_3.1.0
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +383,7 @@ check_minimum_version() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
### 3.0.0 Start ###
|
### 3.0.0 Scripts ###
|
||||||
|
|
||||||
convert_suricata_yes_no() {
|
convert_suricata_yes_no() {
|
||||||
echo "Starting suricata yes/no values to true/false conversion."
|
echo "Starting suricata yes/no values to true/false conversion."
|
||||||
@@ -449,7 +447,6 @@ migrate_pcap_to_suricata() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
up_to_3.0.0() {
|
up_to_3.0.0() {
|
||||||
determine_elastic_agent_upgrade
|
|
||||||
migrate_pcap_to_suricata
|
migrate_pcap_to_suricata
|
||||||
|
|
||||||
INSTALLEDVERSION=3.0.0
|
INSTALLEDVERSION=3.0.0
|
||||||
@@ -473,13 +470,26 @@ post_to_3.0.0() {
|
|||||||
|
|
||||||
### 3.0.0 End ###
|
### 3.0.0 End ###
|
||||||
|
|
||||||
### 3.1.0 Start ###
|
### 3.1.0 Scripts ###
|
||||||
|
|
||||||
|
elasticsearch_backup_index_templates() {
|
||||||
|
echo "Backing up current elasticsearch index templates in /opt/so/conf/elasticsearch/templates/index/ to /nsm/backup/3.0.0_elasticsearch_index_templates.tar.gz"
|
||||||
|
tar -czf /nsm/backup/3.0.0_elasticsearch_index_templates.tar.gz -C /opt/so/conf/elasticsearch/templates/index/ .
|
||||||
|
}
|
||||||
|
|
||||||
up_to_3.1.0() {
|
up_to_3.1.0() {
|
||||||
echo "Nothing to do"
|
determine_elastic_agent_upgrade
|
||||||
|
elasticsearch_backup_index_templates
|
||||||
|
# Clear existing component template state file.
|
||||||
|
rm -f /opt/so/state/esfleet_component_templates.json
|
||||||
|
|
||||||
|
|
||||||
INSTALLEDVERSION=3.1.0
|
INSTALLEDVERSION=3.1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
post_to_3.1.0() {
|
post_to_3.1.0() {
|
||||||
|
/usr/sbin/so-kibana-space-defaults
|
||||||
|
|
||||||
# Provision per-minion Telegraf Postgres users for every minion known to the
|
# Provision per-minion Telegraf Postgres users for every minion known to the
|
||||||
# manager. postgres.auth iterates manage.up to generate any missing passwords;
|
# manager. postgres.auth iterates manage.up to generate any missing passwords;
|
||||||
# postgres.telegraf_users reconciles the roles and schemas inside the so-postgres
|
# postgres.telegraf_users reconciles the roles and schemas inside the so-postgres
|
||||||
@@ -493,6 +503,7 @@ post_to_3.1.0() {
|
|||||||
|
|
||||||
### 3.1.0 End ###
|
### 3.1.0 End ###
|
||||||
|
|
||||||
|
|
||||||
repo_sync() {
|
repo_sync() {
|
||||||
echo "Sync the local repo."
|
echo "Sync the local repo."
|
||||||
su socore -c '/usr/sbin/so-repo-sync' || fail "Unable to complete so-repo-sync."
|
su socore -c '/usr/sbin/so-repo-sync' || fail "Unable to complete so-repo-sync."
|
||||||
@@ -752,12 +763,12 @@ verify_es_version_compatibility() {
|
|||||||
local is_active_intermediate_upgrade=1
|
local is_active_intermediate_upgrade=1
|
||||||
# supported upgrade paths for SO-ES versions
|
# supported upgrade paths for SO-ES versions
|
||||||
declare -A es_upgrade_map=(
|
declare -A es_upgrade_map=(
|
||||||
["8.18.8"]="9.0.8"
|
["9.0.8"]="9.3.3"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Elasticsearch MUST upgrade through these versions
|
# Elasticsearch MUST upgrade through these versions
|
||||||
declare -A es_to_so_version=(
|
declare -A es_to_so_version=(
|
||||||
["8.18.8"]="2.4.190-20251024"
|
["9.0.8"]="3.0.0-20260331"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get current Elasticsearch version
|
# Get current Elasticsearch version
|
||||||
@@ -769,26 +780,17 @@ verify_es_version_compatibility() {
|
|||||||
exit 160
|
exit 160
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! target_es_version_raw=$(so-yaml.py get $UPDATE_DIR/salt/elasticsearch/defaults.yaml elasticsearch.version); then
|
if ! target_es_version=$(so-yaml.py get -r $UPDATE_DIR/salt/elasticsearch/defaults.yaml elasticsearch.version); then
|
||||||
# so-yaml.py failed to get the ES version from upgrade versions elasticsearch/defaults.yaml file. Likely they are upgrading to an SO version older than 2.4.110 prior to the ES version pinning and should be OKAY to continue with the upgrade.
|
echo "Couldn't determine the target Elasticsearch version (post soup version) to ensure compatibility with current Elasticsearch version. Exiting"
|
||||||
|
|
||||||
# if so-yaml.py failed to get the ES version AND the version we are upgrading to is newer than 2.4.110 then we should bail
|
exit 160
|
||||||
if [[ $(cat $UPDATE_DIR/VERSION | cut -d'.' -f3) > 110 ]]; then
|
|
||||||
echo "Couldn't determine the target Elasticsearch version (post soup version) to ensure compatibility with current Elasticsearch version. Exiting"
|
|
||||||
|
|
||||||
exit 160
|
|
||||||
fi
|
|
||||||
|
|
||||||
# allow upgrade to version < 2.4.110 without checking ES version compatibility
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
target_es_version=$(sed -n '1p' <<< "$target_es_version_raw")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for statefile in "${es_required_version_statefile_base}"-*; do
|
for statefile in "${es_required_version_statefile_base}"-*; do
|
||||||
[[ -f $statefile ]] || continue
|
[[ -f $statefile ]] || continue
|
||||||
|
|
||||||
local es_required_version_statefile_value=$(cat "$statefile")
|
local es_required_version_statefile_value
|
||||||
|
es_required_version_statefile_value=$(cat "$statefile")
|
||||||
|
|
||||||
if [[ "$es_required_version_statefile_value" == "$target_es_version" ]]; then
|
if [[ "$es_required_version_statefile_value" == "$target_es_version" ]]; then
|
||||||
echo "Intermediate upgrade to ES $target_es_version is in progress. Skipping Elasticsearch version compatibility check."
|
echo "Intermediate upgrade to ES $target_es_version is in progress. Skipping Elasticsearch version compatibility check."
|
||||||
@@ -797,7 +799,7 @@ verify_es_version_compatibility() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# use sort to check if es_required_statefile_value is < the current es_version.
|
# use sort to check if es_required_statefile_value is < the current es_version.
|
||||||
if [[ "$(printf '%s\n' $es_required_version_statefile_value $es_version | sort -V | head -n1)" == "$es_required_version_statefile_value" ]]; then
|
if [[ "$(printf '%s\n' "$es_required_version_statefile_value" "$es_version" | sort -V | head -n1)" == "$es_required_version_statefile_value" ]]; then
|
||||||
rm -f "$statefile"
|
rm -f "$statefile"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -808,8 +810,7 @@ verify_es_version_compatibility() {
|
|||||||
|
|
||||||
echo -e "\n##############################################################################################################################\n"
|
echo -e "\n##############################################################################################################################\n"
|
||||||
echo "A previously required intermediate Elasticsearch upgrade was detected. Verifying that all Searchnodes/Heavynodes have successfully upgraded Elasticsearch to $es_required_version_statefile_value before proceeding with soup to avoid potential data loss! This command can take up to an hour to complete."
|
echo "A previously required intermediate Elasticsearch upgrade was detected. Verifying that all Searchnodes/Heavynodes have successfully upgraded Elasticsearch to $es_required_version_statefile_value before proceeding with soup to avoid potential data loss! This command can take up to an hour to complete."
|
||||||
timeout --foreground 4000 bash "$es_verification_script" "$es_required_version_statefile_value" "$statefile"
|
if ! timeout --foreground 4000 bash "$es_verification_script" "$es_required_version_statefile_value" "$statefile"; then
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
echo -e "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
echo -e "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
||||||
|
|
||||||
echo "A previous required intermediate Elasticsearch upgrade to $es_required_version_statefile_value has yet to successfully complete across the grid. Please allow time for all Searchnodes/Heavynodes to have upgraded Elasticsearch to $es_required_version_statefile_value before running soup again to avoid potential data loss!"
|
echo "A previous required intermediate Elasticsearch upgrade to $es_required_version_statefile_value has yet to successfully complete across the grid. Please allow time for all Searchnodes/Heavynodes to have upgraded Elasticsearch to $es_required_version_statefile_value before running soup again to avoid potential data loss!"
|
||||||
@@ -826,6 +827,7 @@ verify_es_version_compatibility() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2076 # Do not want a regex here eg usage " 8.18.8 9.0.8 " =~ " 9.0.8 "
|
||||||
if [[ " ${es_upgrade_map[$es_version]} " =~ " $target_es_version " || "$es_version" == "$target_es_version" ]]; then
|
if [[ " ${es_upgrade_map[$es_version]} " =~ " $target_es_version " || "$es_version" == "$target_es_version" ]]; then
|
||||||
# supported upgrade
|
# supported upgrade
|
||||||
return 0
|
return 0
|
||||||
@@ -834,7 +836,7 @@ verify_es_version_compatibility() {
|
|||||||
if [[ -z "$compatible_versions" ]]; then
|
if [[ -z "$compatible_versions" ]]; then
|
||||||
# If current ES version is not explicitly defined in the upgrade map, we know they have an intermediate upgrade to do.
|
# If current ES version is not explicitly defined in the upgrade map, we know they have an intermediate upgrade to do.
|
||||||
# We default to the lowest ES version defined in es_to_so_version as $first_es_required_version
|
# We default to the lowest ES version defined in es_to_so_version as $first_es_required_version
|
||||||
local first_es_required_version=$(printf '%s\n' "${!es_to_so_version[@]}" | sort -V | head -n1)
|
first_es_required_version=$(printf '%s\n' "${!es_to_so_version[@]}" | sort -V | head -n1)
|
||||||
next_step_so_version=${es_to_so_version[$first_es_required_version]}
|
next_step_so_version=${es_to_so_version[$first_es_required_version]}
|
||||||
required_es_upgrade_version="$first_es_required_version"
|
required_es_upgrade_version="$first_es_required_version"
|
||||||
else
|
else
|
||||||
@@ -853,7 +855,7 @@ verify_es_version_compatibility() {
|
|||||||
if [[ $is_airgap -eq 0 ]]; then
|
if [[ $is_airgap -eq 0 ]]; then
|
||||||
run_airgap_intermediate_upgrade
|
run_airgap_intermediate_upgrade
|
||||||
else
|
else
|
||||||
if [[ ! -z $ISOLOC ]]; then
|
if [[ -n $ISOLOC ]]; then
|
||||||
originally_requested_iso_location="$ISOLOC"
|
originally_requested_iso_location="$ISOLOC"
|
||||||
fi
|
fi
|
||||||
# Make sure ISOLOC is not set. Network installs that used soup -f would have ISOLOC set.
|
# Make sure ISOLOC is not set. Network installs that used soup -f would have ISOLOC set.
|
||||||
@@ -885,7 +887,8 @@ wait_for_salt_minion_with_restart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_airgap_intermediate_upgrade() {
|
run_airgap_intermediate_upgrade() {
|
||||||
local originally_requested_so_version=$(cat $UPDATE_DIR/VERSION)
|
local originally_requested_so_version
|
||||||
|
originally_requested_so_version=$(cat "$UPDATE_DIR/VERSION")
|
||||||
# preserve ISOLOC value, so we can try to use it post intermediate upgrade
|
# preserve ISOLOC value, so we can try to use it post intermediate upgrade
|
||||||
local originally_requested_iso_location="$ISOLOC"
|
local originally_requested_iso_location="$ISOLOC"
|
||||||
|
|
||||||
@@ -897,7 +900,8 @@ run_airgap_intermediate_upgrade() {
|
|||||||
|
|
||||||
while [[ -z "$next_iso_location" ]] || [[ ! -f "$next_iso_location" && ! -b "$next_iso_location" ]]; do
|
while [[ -z "$next_iso_location" ]] || [[ ! -f "$next_iso_location" && ! -b "$next_iso_location" ]]; do
|
||||||
# List removable devices if any are present
|
# List removable devices if any are present
|
||||||
local removable_devices=$(lsblk -no PATH,SIZE,TYPE,MOUNTPOINTS,RM | awk '$NF==1')
|
local removable_devices
|
||||||
|
removable_devices=$(lsblk -no PATH,SIZE,TYPE,MOUNTPOINTS,RM | awk '$NF==1')
|
||||||
if [[ -n "$removable_devices" ]]; then
|
if [[ -n "$removable_devices" ]]; then
|
||||||
echo "PATH SIZE TYPE MOUNTPOINTS RM"
|
echo "PATH SIZE TYPE MOUNTPOINTS RM"
|
||||||
echo "$removable_devices"
|
echo "$removable_devices"
|
||||||
@@ -918,21 +922,21 @@ run_airgap_intermediate_upgrade() {
|
|||||||
|
|
||||||
echo "Using $next_iso_location for required intermediary upgrade."
|
echo "Using $next_iso_location for required intermediary upgrade."
|
||||||
exec bash <<EOF
|
exec bash <<EOF
|
||||||
ISOLOC=$next_iso_location soup -y && \
|
ISOLOC="$next_iso_location" soup -y && \
|
||||||
ISOLOC=$next_iso_location soup -y && \
|
ISOLOC="$next_iso_location" soup -y && \
|
||||||
|
|
||||||
echo -e "\n##############################################################################################################################\n" && \
|
echo -e "\n##############################################################################################################################\n" && \
|
||||||
echo -e "Verifying Elasticsearch was successfully upgraded to $required_es_upgrade_version across the grid. This part can take a while as Searchnodes/Heavynodes sync up with the Manager! \n\nOnce verification completes the next soup will begin automatically. If verification takes longer than 1 hour it will stop waiting and your grid will remain at $next_step_so_version. Allowing for all Searchnodes/Heavynodes to upgrade Elasticsearch to the required version on their own time.\n" && \
|
echo -e "Verifying Elasticsearch was successfully upgraded to $required_es_upgrade_version across the grid. This part can take a while as Searchnodes/Heavynodes sync up with the Manager! \n\nOnce verification completes the next soup will begin automatically. If verification takes longer than 1 hour it will stop waiting and your grid will remain at $next_step_so_version. Allowing for all Searchnodes/Heavynodes to upgrade Elasticsearch to the required version on their own time.\n" && \
|
||||||
|
|
||||||
timeout --foreground 4000 bash /tmp/so_intermediate_upgrade_verification.sh $required_es_upgrade_version $es_required_version_statefile && \
|
timeout --foreground 4000 bash /tmp/so_intermediate_upgrade_verification.sh "$required_es_upgrade_version" "$es_required_version_statefile" && \
|
||||||
|
|
||||||
echo -e "\n##############################################################################################################################\n" && \
|
echo -e "\n##############################################################################################################################\n" && \
|
||||||
|
|
||||||
# automatically start the next soup if the original ISO isn't using the same block device we just used
|
# automatically start the next soup if the original ISO isn't using the same block device we just used
|
||||||
if [[ -n "$originally_requested_iso_location" ]] && [[ "$originally_requested_iso_location" != "$next_iso_location" ]]; then
|
if [[ -n "$originally_requested_iso_location" ]] && [[ "$originally_requested_iso_location" != "$next_iso_location" ]]; then
|
||||||
umount /tmp/soagupdate
|
umount /tmp/soagupdate
|
||||||
ISOLOC=$originally_requested_iso_location soup -y && \
|
ISOLOC="$originally_requested_iso_location" soup -y && \
|
||||||
ISOLOC=$originally_requested_iso_location soup -y
|
ISOLOC="$originally_requested_iso_location" soup -y
|
||||||
else
|
else
|
||||||
echo "Could not automatically start next soup to $originally_requested_so_version. Soup will now exit here at $(cat /etc/soversion)" && \
|
echo "Could not automatically start next soup to $originally_requested_so_version. Soup will now exit here at $(cat /etc/soversion)" && \
|
||||||
|
|
||||||
@@ -948,29 +952,29 @@ run_network_intermediate_upgrade() {
|
|||||||
if [[ -n "$BRANCH" ]]; then
|
if [[ -n "$BRANCH" ]]; then
|
||||||
local originally_requested_so_branch="$BRANCH"
|
local originally_requested_so_branch="$BRANCH"
|
||||||
else
|
else
|
||||||
local originally_requested_so_branch="2.4/main"
|
local originally_requested_so_branch="3/main"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting automated intermediate upgrade to $next_step_so_version."
|
echo "Starting automated intermediate upgrade to $next_step_so_version."
|
||||||
echo "After completion, the system will automatically attempt to upgrade to the latest version."
|
echo "After completion, the system will automatically attempt to upgrade to the latest version."
|
||||||
echo -e "\n##############################################################################################################################\n"
|
echo -e "\n##############################################################################################################################\n"
|
||||||
exec bash << EOF
|
exec bash << EOF
|
||||||
BRANCH=$next_step_so_version soup -y && \
|
BRANCH="$next_step_so_version" soup -y && \
|
||||||
BRANCH=$next_step_so_version soup -y && \
|
BRANCH="$next_step_so_version" soup -y && \
|
||||||
|
|
||||||
echo -e "\n##############################################################################################################################\n" && \
|
echo -e "\n##############################################################################################################################\n" && \
|
||||||
echo -e "Verifying Elasticsearch was successfully upgraded to $required_es_upgrade_version across the grid. This part can take a while as Searchnodes/Heavynodes sync up with the Manager! \n\nOnce verification completes the next soup will begin automatically. If verification takes longer than 1 hour it will stop waiting and your grid will remain at $next_step_so_version. Allowing for all Searchnodes/Heavynodes to upgrade Elasticsearch to the required version on their own time.\n" && \
|
echo -e "Verifying Elasticsearch was successfully upgraded to $required_es_upgrade_version across the grid. This part can take a while as Searchnodes/Heavynodes sync up with the Manager! \n\nOnce verification completes the next soup will begin automatically. If verification takes longer than 1 hour it will stop waiting and your grid will remain at $next_step_so_version. Allowing for all Searchnodes/Heavynodes to upgrade Elasticsearch to the required version on their own time.\n" && \
|
||||||
|
|
||||||
timeout --foreground 4000 bash /tmp/so_intermediate_upgrade_verification.sh $required_es_upgrade_version $es_required_version_statefile && \
|
timeout --foreground 4000 bash /tmp/so_intermediate_upgrade_verification.sh "$required_es_upgrade_version" "$es_required_version_statefile" && \
|
||||||
|
|
||||||
echo -e "\n##############################################################################################################################\n" && \
|
echo -e "\n##############################################################################################################################\n" && \
|
||||||
if [[ -n "$originally_requested_iso_location" ]]; then
|
if [[ -n "$originally_requested_iso_location" ]]; then
|
||||||
# nonairgap soup that used -f originally, runs intermediate upgrade using network + BRANCH, later coming back to the original ISO for the last soup
|
# nonairgap soup that used -f originally, runs intermediate upgrade using network + BRANCH, later coming back to the original ISO for the last soup
|
||||||
ISOLOC=$originally_requested_iso_location soup -y && \
|
ISOLOC="$originally_requested_iso_location" soup -y && \
|
||||||
ISOLOC=$originally_requested_iso_location soup -y
|
ISOLOC="$originally_requested_iso_location" soup -y
|
||||||
else
|
else
|
||||||
BRANCH=$originally_requested_so_branch soup -y && \
|
BRANCH="$originally_requested_so_branch" soup -y && \
|
||||||
BRANCH=$originally_requested_so_branch soup -y
|
BRANCH="$originally_requested_so_branch" soup -y
|
||||||
fi
|
fi
|
||||||
echo -e "\n##############################################################################################################################\n"
|
echo -e "\n##############################################################################################################################\n"
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user