36 lines
794 B
Bash
36 lines
794 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."
|
|
exit 0
|
|
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
|
|
|
|
./update-home-manager.sh
|
|
|
|
echo "System update from git completed successfully."
|
|
|