sync client: Fixed logging

This commit is contained in:
Daniel Pätzold
2026-04-24 12:42:51 +02:00
parent 15b15b90b0
commit 18382846a3
+26 -28
View File
@@ -3,8 +3,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# #
# Central sofwareinstallation script. Should be called from logon-script via sudo and prereserved env # Central sofwareinstallation script. Should be called from logon-script via sudo and prereserved env
#
source $(dirname "$0")/setup_system.inc.sh
#Check for root #Check for root
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
@@ -20,12 +18,6 @@ if [ "${DAVTOKEN_USER}." == "." ]; then
echo "Press any key to continue" && read -n 1 -s -r && exit 1 echo "Press any key to continue" && read -n 1 -s -r && exit 1
fi fi
#Check if Repository is defined
if [ "${CLIENT_SOFTWARE_DST}." == "." ]; then
echo "No central softwarerepository defined (CLIENT_SOFTWARE_DST). Skipping sync."
exit 0
fi
#Install or update Nextcloud com.nextcloud.desktopclient.nextcloud #Install or update Nextcloud com.nextcloud.desktopclient.nextcloud
echo "Update or install Nextcloud client" echo "Update or install Nextcloud client"
/usr/bin/flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo /usr/bin/flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
@@ -43,18 +35,25 @@ if [[ ! -z "${DISTCONFIGPATH_SRC}" ]]; then
echo "Sync Configuration" echo "Sync Configuration"
echo "====================" echo "===================="
echo "" echo ""
${SYNCCMD} >/dev/null | grep 'error\|warning' ${SYNCCMD} >${TEMPDIR}/synccmd_last.log 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Error in sync: Check Logfile ${LOGFILE}" echo "Error in sync:"
echo ""
cat ${TEMPDIR}/synccmd_last.log
echo "" echo ""
echo "Please check if your Token is setup right and for the above Output" echo "Please check if your Token is setup right and for the above Output"
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
echo "" echo ""
exit 1 exit 1
fi fi
echo "Sucessfully synced."
fi fi
# Then, sync all client_software-files #Check if Repository is defined
if [[ ! -z "${CLIENT_SOFTWARE_SRC}" ]]; then if [ "${CLIENT_SOFTWARE_DST}." == "." ]; then
echo "No central softwarerepository defined (CLIENT_SOFTWARE_DST). Skipping sync."
else
# Then, sync all client_software-files
if [[ ! -z "${CLIENT_SOFTWARE_SRC}" ]]; then
echo "Syncing central softwarerepository ${CLIENT_SOFTWARE_DST}" echo "Syncing central softwarerepository ${CLIENT_SOFTWARE_DST}"
# Create Directory if not existent # Create Directory if not existent
mkdir -p ${CLIENT_SOFTWARE_DST} mkdir -p ${CLIENT_SOFTWARE_DST}
@@ -64,32 +63,31 @@ if [[ ! -z "${CLIENT_SOFTWARE_SRC}" ]]; then
echo "Sync Client Software" echo "Sync Client Software"
echo "====================" echo "===================="
echo "" echo ""
${SYNCCMD} >/dev/null | grep 'error\|warning' ${SYNCCMD} >${TEMPDIR}/synccmd_last.log 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "Error in sync: Check Logfile ${LOGFILE}" echo "Error in sync:"
echo ""
cat ${TEMPDIR}/synccmd_last.log
echo "" echo ""
echo "Please check if your Token is setup right and for the above Output" echo "Please check if your Token is setup right and for the above Output"
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
echo "" echo ""
exit 1 exit 1
fi fi
fi echo "Sucessfully synced."
fi
# 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}
#Make all install.sh executable
find ${CLIENT_SOFTWARE_DST} -type f -name install.sh -exec chmod ugo+x {} \;
# After sync again, restore the right to all filles. They must be owned by root, changeable by admingroup and readable by otherusers (we are root, so we can change!) #Run Software setup
chown root:${CLIENTADMINGROUP} -R ${SYSCONFIGPATH} echo "Running Setup of Software"
chmod ug+rwX,o=rX -R ${SYSCONFIGPATH} if [ $1 == "install" ]; then
#Make all install.sh executable
find ${CLIENT_SOFTWARE_DST} -type f -name install.sh -exec chmod ug+x {} \;
if [ -f "${CLIENT_SOFTWARE_DST}/install.sh" ]; then
chmod u+x "${CLIENT_SOFTWARE_DST}/install.sh"
fi
echo "Sucessfully synced."
#Run Software setup
echo "Running Setup of Software"
if [ $1 == "install" ]; then
${CLIENT_SOFTWARE_DST}/install.sh $2 ${CLIENT_SOFTWARE_DST}/install.sh $2
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
fi
fi fi