Files
2025-12-19 08:04:19 +03:00

33 lines
757 B
Bash

#!/usr/bin/env bash
set -euo pipefail
REPO_DIR="$HOME/Documents/Github/nixos-config"
cd "$REPO_DIR" || { echo "Error: cannot change directory to $REPO_DIR" >&2; exit 1; }
echo "Fetching latest changes from git..."
if ! git fetch --all; then
echo "Error: git fetch failed" >&2
exit 2
fi
LOCAL_HASH=$(git rev-parse @)
REMOTE_HASH=$(git rev-parse @{u})
if [ "$LOCAL_HASH" = "$REMOTE_HASH" ]; then
echo "The repository is already up to date."
else
echo "Updates are available. Pulling latest changes..."
if ! git pull; then
echo "Error: git pull failed" >&2; exit 3
fi
echo "Repository updated successfully."
fi
chmod -R u+rwX "$REPO_DIR"
sudo ./update-nixos.sh
echo "System update from git completed successfully."