#!/usr/bin/bash
# Copyright (c) 2020 NEC Corporation.
# All rights reserved.
#
# Description:
# This wrapper scipt is responsible to execute the different
# version of ldconfig provided by different version glibc-ve.

VE1_CMD_PATH="/opt/nec/ve/glibc/sbin/ldconfig"
VE3_CMD_PATH="/opt/nec/ve3/glibc/sbin/ldconfig"

ldconfig_arg="$@"

arch=$(find /sys/devices -iname ve_arch_class | head -1 | xargs cat)
if test  "$arch" = "ve1"; then
  if [[ -x "$VE1_CMD_PATH" ]]; then
        $VE1_CMD_PATH $ldconfig_arg
  fi
else
  if [[ -x "$VE1_CMD_PATH" ]]; then
        $VE1_CMD_PATH $ldconfig_arg
  fi
  if [[ -x "$VE3_CMD_PATH" ]]; then
        $VE3_CMD_PATH $ldconfig_arg
  fi
fi
