#!/bin/bash
#
# Copyright (c) 2023 Nutanix Inc. All rights reserved.
#

HOME="/home/nutanix"

# this is still not finalised: ENG-592066
VENV_DIR="$HOME/cluster/.venv/bin"
GENESIS_PY2_MARKER="/home/nutanix/.genesis_py2_marker"

USER_SCRIPTS="lcm_catalog_cleanup.py,lcm_image_cleanup.py,lcm_log_collect_task_cleanup.py,lcm_task_cleanup.py,lcm_upgrade_status.py,recover_lcm.py,lcm_trigger_inventory.py"

if [ -d "$VENV_DIR" ] && [ ! -f "$GENESIS_PY2_MARKER" ]; then
  python_path="$VENV_DIR/bin/python"
else
  python_path=`which python`
fi

python_version="$("$python_path" -V 2>&1)"

# Not printing anything for scripts that are called by lcm-framework.
# Only printing the python version for User scripts.
# Ticket: ENG-592833, HPDX-2961
if [[ "$USER_SCRIPTS" =~ (","|^)recover_lcm.py(","|$) ]]; then
  echo "Running python version - $python_version"
fi

$python_path "$HOME/cluster/bin/lcm/recover_lcm.py" "$@"
