aboutsummaryrefslogtreecommitdiff
path: root/scripts/deploy.sh
blob: 9be85321cddd25f954034b282ba925b58e2586e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Show what would change on this server when the repository is applied (dry run by default).
# buildbot runs the dry run; the real deployment is /opt/wiiu/bin/deploy-server (root-owned, own allow-list).
R=$(cd "$(dirname "$0")/.." && pwd); W=/opt/wiiu; APPLY=${1:-}
map() { # repo path -> live path
  case "$1" in
    etc/mrtg/mrtg.cfg|buildbot/master.cfg) return 1 ;;
    etc/*) echo "$W/$1" ;;
    bin/*) echo "$W/$1" ;;
    www/index.html) echo /srv/www/default/index.html ;;
    www/mefo/plugins/*) echo "/srv/www/mefo/plugins/${1##*/}" ;;
    rc.d/buildbot_dango) echo /usr/local/etc/rc.d/buildbot_dango ;;
    rc.d/*) echo "/etc/rc.d/${1##*/}" ;;
    *) return 1 ;;
  esac
}
cd "$R"; find . -type f -not -path './.git/*' | sed 's|^\./||' | while read f; do
  t=$(map "$f") || continue; [ -e "$t" ] || continue
  grep -qE '<REDACTED>|@@[A-Z_]+@@' "$f" && continue
  cmp -s "$f" "$t" && continue
  echo "differs: $f -> $t"; [ "$APPLY" = "--apply" ] && { cp -p "$t" "/var/tmp/$(basename "$t").deploy-bak"; cp "$f" "$t"; }
done
exit 0