sync_client_software: fix permissions and parameter check

This commit is contained in:
Daniel unbrot Pätzold
2026-05-08 12:40:08 +02:00
parent a237f58813
commit aaa7b73d53
+23 -17
View File
@@ -73,6 +73,27 @@ else
fi fi
echo "" 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 # At first, sync central configs if they are configured to be synced
if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then
echo "Synced config path was found, doing remote sync." 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." echo "Running pre installed scripts first."
for DIR in $(ls -d ${SYSCONFIGPATH}/client_software/*/ | sort); do for DIR in $(ls -d ${SYSCONFIGPATH}/client_software/*/ | sort); do
DIR=${DIR%*/} # remove the trailing "/" DIR=${DIR%*/} # remove the trailing "/"
if [[ "$1." != "." ]] && [[ "${DIR}" != *"$1"* ]]; then if [[ "$2." != "." ]] && [[ "${DIR}" != *"$2"* ]]; then
#search for string in dir #search for string in dir
echo "Skipping ${DIR} while not in search parameter ( $1 )." echo "Skipping ${DIR} while not in search parameter ( $2 )."
continue continue
fi fi
if [ -f "${DIR}/install.sh" ]; then if [ -f "${DIR}/install.sh" ]; then
@@ -158,14 +179,6 @@ done
echo "Sucessfully installed pre-defined software." echo "Sucessfully installed pre-defined software."
echo 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 # Then, sync all client_software-files
if [[ -z "${CLIENT_SOFTWARE_CUST_SRC}" ]]; then if [[ -z "${CLIENT_SOFTWARE_CUST_SRC}" ]]; then
echo "No customer software sync is defined, skipping sync" echo "No customer software sync is defined, skipping sync"
@@ -190,19 +203,12 @@ else
exit 1 exit 1
fi fi
echo "Sucessfully synced." 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 fi
echo echo
#Run customer setup #Run customer setup
if [ ! -z "${CLIENT_SOFTWARE_CUST_DST}" ]; then if [ ! -z "${CLIENT_SOFTWARE_CUST_DST}" ]; then
echo "Running all software scripts in admin- context." 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 for DIR in $(ls -d ${CLIENT_SOFTWARE_CUST_DST}/*/ | sort); do
DIR=${DIR%*/} # remove the trailing "/" DIR=${DIR%*/} # remove the trailing "/"
if [[ "$1." != "." ]] && [[ "${DIR}" != *"$1"* ]]; then if [[ "$1." != "." ]] && [[ "${DIR}" != *"$1"* ]]; then