#!/bin/sh 

cd "${INSTALL_PATH}"

# Stop runtime service. 
# Ex: /etc/systemd/system/sage_x3_runtime_SQLLINUX01.service
if [ -f /etc/systemd/system/sage_x3_runtime_${component.node.name}.service ]; then 
	systemctl stop sage_x3_runtime_${component.node.name}.service; 
fi

pwsh -Executionpolicy remotesigned -File  "${BEFORE_UPDATE_SCRIPT_PS_PATH}" -InstallPath  "${INSTALL_PATH}"


# X3-284613 - Update from R095.002 : previous powershell file structure changed
if [ -d ebin/common_modules ]; then rm -rf ebin/common_modules; fi

if [ -f sem\semaphore.dat ]; then rm -f sem\semaphore.dat; fi
if [ -f "SAGE ERP X3 EULA FR".txt ]; then rm -f "SAGE ERP"*.txt; fi
if [ -f "SAGE ERP X3 EULA FR".htm ]; then rm -f "SAGE ERP"*.htm; fi

exit 0