Added logging for updates. Updated documentation.
This commit is contained in:
@@ -9,17 +9,50 @@ sudo -n /usr/bin/systemctl start fenrirscreenreader.service
|
||||
# Clear the screen before loading
|
||||
clear
|
||||
|
||||
# Update system packages (run as stormux user since yay shouldn't run as root)
|
||||
pacman -Syu --noconfirm
|
||||
# Setup logging
|
||||
logDir="/home/stormux/Logs"
|
||||
logFile="${logDir}/system-updates.log"
|
||||
mkdir -p "${logDir}"
|
||||
echo "=== System Update Started: $(date) ===" | tee "${logFile}"
|
||||
|
||||
# Track errors
|
||||
errorCount=0
|
||||
errorMessages=()
|
||||
|
||||
# Clean up old packages keeping currently installed versions only
|
||||
pacman -Sc --noconfirm 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Package cleaning failed")
|
||||
fi
|
||||
|
||||
# Upgrade the system
|
||||
pacman -Syu --noconfirm 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Package update failed")
|
||||
fi
|
||||
|
||||
gitUrl="https://git.stormux.org/storm/gaming-image-files"
|
||||
gitPath="${gitUrl##*/}"
|
||||
pushd /tmp || exit
|
||||
git config --global credential.helper store
|
||||
git clone "${gitUrl}"
|
||||
git clone "${gitUrl}" 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Git clone failed")
|
||||
fi
|
||||
pushd "${gitPath}" || exit
|
||||
git checkout master
|
||||
git lfs pull
|
||||
git checkout master 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Git checkout master failed")
|
||||
fi
|
||||
git lfs pull 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Git LFS pull failed")
|
||||
fi
|
||||
# Files and directories to ignore when copying
|
||||
ignoreFiles=(".git" "./image" ".git*" "/home/stormux/.w3m" "/home/stormux/.irssi")
|
||||
# Build find command with ignore patterns
|
||||
@@ -32,11 +65,35 @@ for ignore in "${ignoreFiles[@]}"; do
|
||||
fi
|
||||
done
|
||||
# Copy all files as root (preserves permissions properly)
|
||||
find . "${findArgs[@]}" -type f -exec bash -c 'for i ; do cp -av --preserve=all --parents "${i}" /;done' _ "{}" \;
|
||||
find . "${findArgs[@]}" -type f -exec bash -c 'for i ; do cp -av --preserve=all --parents "${i}" /;done' _ "{}" \; 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("File copy failed")
|
||||
fi
|
||||
# Fix ownership of home directory files
|
||||
chown -R stormux:users /home/stormux
|
||||
chown -R stormux:users /home/stormux 2>&1 | tee -a "${logFile}"
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
((errorCount++))
|
||||
errorMessages+=("Ownership fix failed")
|
||||
fi
|
||||
popd || exit
|
||||
rm -rf "${gitPath}"
|
||||
popd || exit
|
||||
|
||||
echo "=== System Update Completed: $(date) ===" | tee -a "${logFile}"
|
||||
echo | tee -a "${logFile}"
|
||||
|
||||
# Display summary
|
||||
if [[ $errorCount -eq 0 ]]; then
|
||||
echo "SUCCESS: All update operations completed successfully." | tee -a "${logFile}"
|
||||
else
|
||||
echo "ERRORS DETECTED: $errorCount error(s) occurred during update:" | tee -a "${logFile}"
|
||||
for error in "${errorMessages[@]}"; do
|
||||
echo " - $error" | tee -a "${logFile}"
|
||||
done
|
||||
fi
|
||||
echo | tee -a "${logFile}"
|
||||
|
||||
read -r -p "Press enter to continue."
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user