From 92757061a739261ecd6a825bd8680a9fe135cebd Mon Sep 17 00:00:00 2001 From: ralphanthony-reyes Date: Wed, 17 Dec 2025 19:59:35 +0800 Subject: [PATCH] CF232 DXClient Wrapper Scripts Update --- CHANGELOG.md | 18 +++++++++++++ bin/dxclient | 68 ++++++++++++++++++++++++++++++------------------ bin/dxclient.bat | 37 ++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1d396..e049c60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,3 +78,21 @@ All notable changes to this project will be documented in this file. ### Changes - Updated Dependencies + +## [[230.0.0](https://help.hcl-software.com/digital-experience/9.5/CF230/whatsnew/cf20/newcf230/)] - HCL DX 9.5 CF230 + +### Changes + + - New xmlAccessOutputFileName parameter added: You can now use the new xmlAccessOutputFileName parameter to specify the name of an output XML file. For more information, refer to XMLAccess + +## [[231.0.0](https://help.hcl-software.com/digital-experience/9.5/CF231/whatsnew/cf20/newcf231/)] - HCL DX 9.5 CF231 + +### Changes + + - No Changes + +## [[232.0.0](https://help.hcl-software.com/digital-experience/9.5/CF231/whatsnew/cf20/newcf231/)] - HCL DX 9.5 CF231 + +### Changes + + - Updated DXClient Container Wrapper Scripts. diff --git a/bin/dxclient b/bin/dxclient index 0ab7bf0..0afca30 100755 --- a/bin/dxclient +++ b/bin/dxclient @@ -19,7 +19,7 @@ IMAGE_TAG="v95_CF231_20251024-1354" DXCLIENT="dxclient" DATA_DIR="store" MOUNT_LIST= -regEx="[[:space:]]+" # matches a string with atleast one space character in it. +regEx="[[:space:]]|\." # matches a string with a space character or dot in it. # provides users option to set Volume directory if [ ! "$VOLUME_DIR" ] @@ -86,8 +86,17 @@ fi containerFolder=/$DXCLIENT/$VOLUME_DIR volumeParams="-v \"$(pwd)/$VOLUME_DIR:/${containerFolder}\":Z" -if [ $NODE_EXTRA_CA_CERTS ]; then - volumeParams="${volumeParams} -v \"${NODE_EXTRA_CA_CERTS}:/etc/ssl/certs/$(basename "${NODE_EXTRA_CA_CERTS}")\":Z" +# Initialize environment variables similar to batch script +environmentVars="-e VOLUME_DIR=\"$VOLUME_DIR\" -e TZ=$Timezone" + +# Add NODE_TLS_REJECT_UNAUTHORIZED if set +if [ -n "$NODE_TLS_REJECT_UNAUTHORIZED" ]; then + environmentVars="$environmentVars -e NODE_TLS_REJECT_UNAUTHORIZED=$NODE_TLS_REJECT_UNAUTHORIZED" +fi + +# Add NODE_EXTRA_CA_CERTS if set +if [ -n "$NODE_EXTRA_CA_CERTS" ]; then + volumeParams="$volumeParams -v \"$NODE_EXTRA_CA_CERTS:/etc/ssl/certs/$(basename "$NODE_EXTRA_CA_CERTS")\":Z" fi # Generate a separate volume for each folder or file in the parameter @@ -95,33 +104,42 @@ fi for i in "${!execCmd[@]}"; do # Check if -exportPath exist if [[ "${execCmd[$i]}" == "-exportPath" || "${execCmd[$i]}" == "-themePath" || "${execCmd[$i]}" == "-wcmLibraryPath" ]]; then - # then pass the value of exportPath, themePath to hostPath variable that is passed also as env - hostPath=${execCmd[$i+1]} + # then pass the value of exportPath, themePath to hostPath variable that is passed also as env + hostPath=${execCmd[$i+1]} fi if [[ "${execCmd[$i]}" == "--importPath" || "${execCmd[$i]}" == "-importPath" ]]; then - # then pass the value of importPath to hostPath variable that is passed also as env - hostImportPath=${execCmd[$i+1]} - fi - if [[ -e ${execCmd[$i]} ]] && [[ "${execCmd[$i]}" == *"/"* ]]; then - # Check if relative path and convert to absolute - localPath=${execCmd[$i]} - localPath=$(getAbsolutePath "${localPath}") - - # Add input to the mount list - MOUNT_LIST+=$localPath - - # add this folder/filepath to volume parameter - volumeParams="${volumeParams} -v \"${localPath}\":\"${containerFolder}/$(basename "${localPath}")\":Z" - - # Replace parameter with the folder known to the container - execCmd[$i]=\"${containerFolder}/$(basename "${localPath}")\" - # the following else condition checks if space is present and enclose the string within quotes - elif [[ ${execCmd[$i]} =~ $regEx ]]; then - execCmd[$i]=\"${execCmd[$i]}\" + # then pass the value of importPath to hostPath variable that is passed also as env + hostImportPath=${execCmd[$i+1]} fi + + # Check for livesync command to set CHOKIDAR_USEPOLLING + if [[ "${execCmd[$i]}" == "livesync" ]]; then + environmentVars="$environmentVars -e CHOKIDAR_USEPOLLING=true" + fi + if [[ -e ${execCmd[$i]} ]] && [[ "${execCmd[$i]}" == *"/"* ]]; then + # Check if relative path and convert to absolute + localPath=${execCmd[$i]} + localPath=$(getAbsolutePath "${localPath}") + + # Add input to the mount list + MOUNT_LIST+=$localPath + + # add this folder/filepath to volume parameter + volumeParams="${volumeParams} -v \"${localPath}\":\"${containerFolder}/$(basename "${localPath}")\":Z" + + # Replace parameter with the folder known to the container + execCmd[$i]=\"${containerFolder}/$(basename "${localPath}")\" + # the following else condition checks if space is present and enclose the string within quotes + elif [[ ${execCmd[$i]} =~ $regEx ]]; then + execCmd[$i]=\"${execCmd[$i]}\" + fi done -eval $CONTAINER_RUNTIME run -e DXCLIENT_RUNTIME=\"$CONTAINER_RUNTIME\" -e HOST_PATH=\"$hostPath\" -e HOST_IMPORT_PATH=\"$hostImportPath\" -e VOLUME_DIR=\"$VOLUME_DIR\" -u="$(echo $UID)" $TTY_FLAG -e TZ=$Timezone $volumeParams --network="host" --platform linux/amd64 --name $DXCLIENT --rm ${IMAGE_NAME:?'Please set dxclient image name.'}:${IMAGE_TAG:?'Please set dxclient image tag.'} "./bin/dxclient" "${execCmd[@]}" +# Add host path and runtime environment variables +environmentVars="$environmentVars -e HOST_PATH=\"$hostPath\" -e HOST_IMPORT_PATH=\"$hostImportPath\" -e DXCLIENT_RUNTIME=\"$CONTAINER_RUNTIME\"" + +eval $CONTAINER_RUNTIME run -u="$(echo $UID)" $TTY_FLAG $environmentVars \ +$volumeParams --network="host" --platform linux/amd64 --name $DXCLIENT --rm ${IMAGE_NAME:?'Please set dxclient image name.'}:${IMAGE_TAG:?'Please set dxclient image tag.'} "./bin/dxclient" "${execCmd[@]}" # Cleanup the files created in local volume/mount point if the command is livesync or export-assets diff --git a/bin/dxclient.bat b/bin/dxclient.bat index 03eaab1..3312102 100644 --- a/bin/dxclient.bat +++ b/bin/dxclient.bat @@ -47,6 +47,18 @@ CALL :check_cmd_in_path !CONTAINER_RUNTIME! :: extract execution command arguments into a variable CALL SET execCmd=%* +:: clean up \ in the end of inputs +FOR %%i IN (!execCmd!) DO ( + SET "currentItem=%%i" + IF "!currentItem:~-1!"=="\" ( + CALL SET "cleanedItem=!currentItem:~0,-1!" + ) ELSE ( + CALL SET "cleanedItem=!currentItem!" + ) + CALL SET cleanCMD=!cleanCMD! !cleanedItem! +) +CALL SET execCmd=!cleanCMD! + :: creates volume directory if not present if NOT EXIST "%cd%"/!VOLUME_DIR! ( mkdir "!VOLUME_DIR!" @@ -60,6 +72,11 @@ CALL SET "newCmd=" :: curated set of environmental variables CALL SET environmentVars= -e TZ=!Timezone! -e VOLUME_DIR="!VOLUME_DIR!" +:: Check if NODE_TLS_REJECT_UNAUTHORIZED is set to 0 and display security warning +IF "!NODE_TLS_REJECT_UNAUTHORIZED!"=="0" ( + CALL SET environmentVars=!environmentVars! -e NODE_TLS_REJECT_UNAUTHORIZED=0 +) + :: Check if the environment variable NODE_EXTRA_CA_CERTS is set if defined NODE_EXTRA_CA_CERTS ( for %%F in ("!NODE_EXTRA_CA_CERTS!") do ( @@ -69,7 +86,8 @@ if defined NODE_EXTRA_CA_CERTS ( ) :: Setting search value "\" for validating filepath -CALL SET searchVal=\ +CALL SET "searchVals=\ . ./ /" + SET hostPath=%CD% SET hostImportPath="" set exportPathExists=0 @@ -108,13 +126,19 @@ if /I "%~1"=="-exportPath" ( set hostPath="%~2" shift ) +) else if /I "%~1"=="--wcmLibraryPath" ( + set exportPathExists=1 + if not "%~2"=="" ( + set hostPath="%~2" + shift + ) ) else if /I "%~1"=="--libraryPath" ( set exportPathExists=1 if not "%~2"=="" ( set hostPath="%~2" shift ) -)else if /I "%~1"=="-importPath" ( +) else if /I "%~1"=="-importPath" ( set exportPathExists=1 if not "%~2"=="" ( set hostImportPath="%~2" @@ -127,12 +151,21 @@ if /I "%~1"=="-exportPath" ( shift ) ) + if "%~1"=="" goto :done set /A count+=1 shift goto :loop :done +:: Clean up the \ in the end of host path +CALL SET searchSlash=\" +IF "!hostPath:~-2!"=="!searchSlash!" ( + CALL SET hostPath=!hostPath:~0,-2!" +) ELSE ( + CALL SET hostPath=!hostPath! +) + :: Generate a separate volume point for each folder or file in the parameter :: Replace the folders in the parameter with the assigned container folder in volume parameter FOR %%i IN (!execCmd!) DO (