summaryrefslogtreecommitdiff
path: root/bin/dotfiles-sync
blob: 503a1ed248df511f0af93283e8f2a78e5443446e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

# Transitional, added 2026-09-17: the sync job moved to cloud-setup, whose
# svc/setup.sh points each host's unit at its own copy. A host whose unit still
# runs this path -- one that was offline when the units were regenerated --
# lands here: bring its cloud-setup clone up to date and hand over, so it keeps
# receiving until someone runs `dotfiles-sync-enable` there. Remove once no unit
# points at this file.

set -euo pipefail

cloud_setup="$HOME/src/soarez/cloud-setup"
target="$cloud_setup/bin/dotfiles-sync"

if [[ ! -x "$target" && -d "$cloud_setup/.git" ]]
then
  umask 022
  git -C "$cloud_setup" fetch --prune origin && git -C "$cloud_setup" merge --ff-only --quiet origin/master || true
fi

if [[ -x "$target" ]]
then
  exec "$target" "$@"
fi

>&2 cat <<MSG
dotfiles-sync has moved to cloud-setup, and this host has no usable copy at
$target. To recover:

  git -C $cloud_setup pull --ff-only
  $(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)/link.sh yes
  dotfiles-sync-enable
MSG
exit 1