Files
gaming-image-files/usr/local/bin/live-update.sh
T
2025-10-10 22:49:32 -04:00

43 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Stop the screen reader if this closes for any reason
trap 'sudo -n /usr/bin/systemctl stop fenrirscreenreader.service' SIGINT SIGTERM SIGHUP EXIT
# Start Fenrir for interaction with the terminal
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
gitUrl="https://git.stormux.org/storm/gaming-image-files"
gitPath="${gitUrl##*/}"
pushd /tmp || exit
git config --global credential.helper store
git clone "${gitUrl}"
pushd "${gitPath}" || exit
git checkout master
git lfs pull
# Files and directories to ignore when copying
ignoreFiles=(".git" "./image" ".git*" "/home/stormux/.w3m" "/home/stormux/.irssi")
# Build find command with ignore patterns
findArgs=()
for ignore in "${ignoreFiles[@]}"; do
if [[ "$ignore" == .* && "$ignore" != ./* ]]; then
findArgs+=(-name "$ignore" -prune -o)
else
findArgs+=(-path "$ignore" -prune -o)
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' _ "{}" \;
# Fix ownership of home directory files
chown -R stormux:users /home/stormux
popd || exit
rm -rf "${gitPath}"
popd || exit
exit 0