#!/usr/bin/env bash #DESC This function updates the custom fields in datto. XMLPath=$(find /root/.mono/registry -path '*/software/centrastage/values.xml' | head -1) POSDIR="/usr2/bbx" POS="RTI" # Dove ID / Shopcode if [[ -f "$POSDIR/config/dove.ini" ]]; then shopcode=$(sed -n 's/^[[:space:]]*DOVE_USERNAME[[:space:]]*=[[:space:]]*\(.*[[:print:]]\)$/\1/p' \ "$POSDIR/config/dove.ini" | tail -n 1) fi sed -i "/<\/values>/i\ $shopcode" "$XMLPath" echo "Shopcode: $shopcode" # POS sed -i "/<\/values>/i\ $POS" "$XMLPath" echo "POS: $POS" # Build / CurrentVersion if [[ -f "$POSDIR/bbxd/RTI.ini" ]]; then buildnum="Unknown" patchlev="" while IFS= read -r line; do if [[ "$line" =~ ^VERSION[[:space:]]*=[[:space:]]*(.*[[:print:]]) ]]; then buildnum="${BASH_REMATCH[1]}" fi if [[ "$line" =~ ^PATCH[[:space:]]*=[[:space:]]*(.*[[:print:]]) ]]; then patchlev="${BASH_REMATCH[1]}" break fi done < "$POSDIR/bbxd/RTI.ini" buildnum="${buildnum}${patchlev}" else buildnum="No .INI File" fi sed -i "/<\/values>/i\ $buildnum" "$XMLPath" echo "Version: $buildnum" # Install Type [ "`grep 'release 7' /etc/redhat-release`" != "" ] && installtype="RHEL7" [ "`grep 'release 8' /etc/redhat-release`" != "" ] && installtype="RHEL8" [ "`grep 'release 9' /etc/redhat-release`" != "" ] && installtype="RHEL9" [ "`grep 'release 10' /etc/redhat-release`" != "" ] && installtype="RHEL10" sed -i "/<\/values>/i\ $installtype" "$XMLPath" echo "OS Version: $installtype" # Install Date installdate="Unknown" filename=$(ls -tr /root/rti_install*.log 2>/dev/null | tail -n 1) if [[ -n "$filename" && -f "$filename" ]]; then while IFS= read -r line; do if [[ "$line" =~ Install\ Started\ ([0-9]+)-([0-9]+)-([0-9]+) ]]; then installdate="${BASH_REMATCH[1]}${BASH_REMATCH[2]}${BASH_REMATCH[3]}" fi done < "$filename" fi sed -i "/<\/values>/i\ $installdate" "$XMLPath" echo "Install Date: $installdate" # eDirectory Version if [[ -f "$POSDIR/bbxd/ONRO01" ]]; then file="$POSDIR/bbxd/ONRO01" # Read 5 bytes starting at offset 60 string=$(dd if="$file" bs=1 skip=60 count=5 2>/dev/null) # Read 2 bytes starting at offset 422 string2=$(dd if="$file" bs=1 skip=422 count=2 2>/dev/null) # Expected format: YY.MM IFS='.' read -r year month <<< "$string" # Force base-10 interpretation so values like 08 and 09 # are not treated as octal. year_num=$((10#$year)) month_num=$((10#$month)) case "$month_num" in 2|3|4) edirectory="FMA$((2000 + year_num))" ;; 5|6|7) edirectory="MJJ$((2000 + year_num))" ;; 8|9|10) edirectory="ASO$((2000 + year_num))" ;; 11|12|1) edirectory="NDJ$((2000 + year_num))" ;; *) edirectory="$string" ;; esac if [[ "$string2" == "CB" ]]; then edirectory="${edirectory}CMB" else edirectory="${edirectory}TEL" fi fi sed -i "/<\/values>/i\ $edirectory" "$XMLPath" echo "Edition: $edirectory" # Get RTI Build build="Unknown" patchlvl="" if [[ -f "$POSDIR/bbxd/RTI.ini" ]]; then while IFS= read -r line; do if [[ "$line" =~ ^VERSION[[:space:]]*=[[:space:]]*(.*[[:print:]]) ]]; then build="${BASH_REMATCH[1]}" fi if [[ "$line" =~ ^PATCH[[:space:]]*=[[:space:]]*(.*[[:print:]]) ]]; then patchlvl="${BASH_REMATCH[1]}" break fi done < "$POSDIR/bbxd/RTI.ini" build="${build}${patchlvl}" else build="$POSDIR/config/RTI.ini file not found" fi sed -i "/<\/values>/i\ $build" "$XMLPath" echo "Build: $build" echo "Patch Level: $patchlvl" exit $?