From aaa7b73d5318f6cbea2f2d04d59cf864fdaa366e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20unbrot=20P=C3=A4tzold?= Date: Fri, 8 May 2026 12:40:08 +0200 Subject: [PATCH] sync_client_software: fix permissions and parameter check --- system_setup/sync_client_software.sh | 46 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/system_setup/sync_client_software.sh b/system_setup/sync_client_software.sh index 5bb4327..84c5fdc 100755 --- a/system_setup/sync_client_software.sh +++ b/system_setup/sync_client_software.sh @@ -73,6 +73,27 @@ else fi echo "" +# Repository must always be set to the right path (but maybe empty, which is fine) +if [ "${CLIENT_SOFTWARE_CUST_DST}" != "${SYSCONFIGPATH}/client_software_cust" ]; then + echo "Error in config: Required parameter CLIENT_SOFTWARE_CUST_DST is missing or set wrong." + echo "Please relog and if the problem reoccures, contact your system admins to correct the Values." + read -n 1 -s -r -p "Press any key to continue" + echo "" + exit 1 +fi + +# Before running sync or software installs, restore the rights to all filles. +# They must be owned by root, changeable by admingroup and readable by otherusers (we are root, so we can change!) +# user_run.sh must also be executable by users +chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} +chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} + +#Make all install.sh executable +find ${SYSCONFIGPATH}/client_software} -type f -name install.sh -exec chmod ug+x,o-x {} \; +find ${SYSCONFIGPATH}/client_software} -type f -name user_run.sh -exec chmod ugo+x {} \; +find ${CLIENT_SOFTWARE_CUST_DST} -type f -name install.sh -exec chmod ug+x,o-x {} \; +find ${CLIENT_SOFTWARE_CUST_DST} -type f -name user_run.sh -exec chmod ugo+x {} \; + # At first, sync central configs if they are configured to be synced if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then echo "Synced config path was found, doing remote sync." @@ -135,9 +156,9 @@ echo "Running all software scripts in admin- context." echo "Running pre installed scripts first." for DIR in $(ls -d ${SYSCONFIGPATH}/client_software/*/ | sort); do DIR=${DIR%*/} # remove the trailing "/" - if [[ "$1." != "." ]] && [[ "${DIR}" != *"$1"* ]]; then + if [[ "$2." != "." ]] && [[ "${DIR}" != *"$2"* ]]; then #search for string in dir - echo "Skipping ${DIR} while not in search parameter ( $1 )." + echo "Skipping ${DIR} while not in search parameter ( $2 )." continue fi if [ -f "${DIR}/install.sh" ]; then @@ -158,19 +179,11 @@ done echo "Sucessfully installed pre-defined software." echo -# Repository must be the right path (but maybe empty, which is fine) -if [ "${CLIENT_SOFTWARE_CUST_DST}" != "${SYSCONFIGPATH}/client_software_cust" ]; then - echo "Error in config: Required parameter CLIENT_SOFTWARE_CUST_DST is missing or set wrong." - echo "Please relog and if the problem reoccures, contact your system admins to correct the Values." - read -n 1 -s -r -p "Press any key to continue" - echo "" - exit 1 -else - # Then, sync all client_software-files - if [[ -z "${CLIENT_SOFTWARE_CUST_SRC}" ]]; then +# Then, sync all client_software-files +if [[ -z "${CLIENT_SOFTWARE_CUST_SRC}" ]]; then echo "No customer software sync is defined, skipping sync" echo "${CLIENT_SOFTWARE_CUST_DST} with ${CLIENT_SOFTWARE_CUST_SRC}" - else +else echo "Syncing customer software repository ${CLIENT_SOFTWARE_CUST_DST}" # Create Directory if not existent mkdir -p ${CLIENT_SOFTWARE_CUST_DST} @@ -190,19 +203,12 @@ else exit 1 fi echo "Sucessfully synced." - - # After sync again, restore the rights to all filles. They must be owned by root, changeable by admingroup and readable by otherusers (we are root, so we can change!) - chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} - chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} - fi fi echo #Run customer setup if [ ! -z "${CLIENT_SOFTWARE_CUST_DST}" ]; then echo "Running all software scripts in admin- context." - #Make all install.sh executable - find ${CLIENT_SOFTWARE_CUST_DST} -type f -name install.sh -exec chmod ugo+x {} \; for DIR in $(ls -d ${CLIENT_SOFTWARE_CUST_DST}/*/ | sort); do DIR=${DIR%*/} # remove the trailing "/" if [[ "$1." != "." ]] && [[ "${DIR}" != *"$1"* ]]; then