# -------------------------------------------------------------------------------
# Copyright 2024 - 2026 Open Text.
#
# The only warranties for products and services of Open Text and its
# affiliates and licensors (“Open Text”) are as may be set forth in the
# express warranty statements accompanying such products and services.
# Nothing herein should be construed as constituting an additional
# warranty. Open Text shall not be liable for technical or editorial
# errors or omissions contained herein. The information contained herein
# is subject to change without notice.
#
# Except as specifically indicated otherwise, this document contains
# confidential information and a valid license is required for possession,
# use or copying. If this work is provided to the U.S. Government,
# consistent with FAR 12.211 and 12.212, Commercial Computer Software,
# Computer Software Documentation, and Technical Data for Commercial Items
# are licensed to the U.S. Government under vendor's standard commercial
# license.
# -------------------------------------------------------------------------------

#!/bin/sh

current_release=$(grep "DISPLAY_RELEASE" /etc/novell-release | cut -d ' ' -f 3)
FILES=("/etc/novell-release" "/usr/lib/issue.d/10-OES")
DIST="OES 26.2"

for FILE in "${FILES[@]}"; do
  if [ -e "$FILE" ]; then
    if [[ "$FILE" == "/etc/novell-release" ]]; then
      sed -i "/PATCHLEVEL/d" "$FILE"
    fi
    sed -i "s/$current_release/26.2/" "$FILE"
  fi
done

if [ -e "/etc/default/grub" ]; then
  sed -i 's/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR="'"$DIST"'"/g' /etc/default/grub
  grub2-mkconfig -o /boot/grub2/grub.cfg
fi

# Fix the Version in OES-brand file
if [ -e "/etc/OES-brand" ]; then
  oes_version=$(grep "VERSION" /etc/OES-brand | cut -d ' ' -f 3)
  sed -i "s/$oes_version/26.2/" "/etc/OES-brand"
fi

exit 0
