56 lines
2.6 KiB
Bash
56 lines
2.6 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Puts the private files of ChessPenguin in place on a new machine (README.md).
|
||
|
|
#
|
||
|
|
# ./restore.sh [path of the repository clone] # default: ~/services/chessBaseLinux
|
||
|
|
#
|
||
|
|
# Files already there are kept: a copy goes next to them as <name>.from-private.
|
||
|
|
set -euo pipefail
|
||
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
||
|
|
repo="$(cd "${1:-$HOME/services/chessBaseLinux}" && pwd)"
|
||
|
|
[[ -f "${repo}/Cargo.toml" ]] || { echo "restore.sh: ${repo} is not the ChessPenguin repository" >&2; exit 1; }
|
||
|
|
|
||
|
|
put() { # put SRC DST [mode]
|
||
|
|
local src="$1" dst="$2" mode="${3:-600}"
|
||
|
|
mkdir -p "$(dirname "${dst}")"
|
||
|
|
if [[ -e "${dst}" ]] && ! cmp -s "${src}" "${dst}"; then
|
||
|
|
dst="${dst}.from-private"
|
||
|
|
echo " kept the existing file, new one is ${dst}"
|
||
|
|
fi
|
||
|
|
install -m "${mode}" "${src}" "${dst}"
|
||
|
|
echo " ${dst}"
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "Android signing key and passwords (~/.config/chesspenguin/android):"
|
||
|
|
chmod 700 "$(mkdir -p ~/.config/chesspenguin/android && echo ~/.config/chesspenguin/android)"
|
||
|
|
for f in .env release.jks release.jks.base64; do put "${here}/secrets/android/${f}" ~/.config/chesspenguin/android/"${f}"; done
|
||
|
|
|
||
|
|
echo "Desktop app settings and ChatGPT tokens (~/.config/chesspenguin):"
|
||
|
|
put "${here}/secrets/chesspenguin/credentials.json" ~/.config/chesspenguin/credentials.json
|
||
|
|
put "${here}/secrets/chesspenguin/settings.json" ~/.config/chesspenguin/settings.json 644
|
||
|
|
put "${here}/secrets/chesspenguin/graphics" ~/.config/chesspenguin/graphics 644
|
||
|
|
|
||
|
|
echo "Website settings (website/.env):"
|
||
|
|
put "${here}/secrets/website.env" "${repo}/website/.env" 644
|
||
|
|
|
||
|
|
echo "Test databases (pgnFilesforExample/, never committed to main):"
|
||
|
|
mkdir -p "${repo}/pgnFilesforExample"
|
||
|
|
for f in "${here}"/test-data/*; do put "${f}" "${repo}/pgnFilesforExample/$(basename "${f}")" 644; done
|
||
|
|
|
||
|
|
echo "Claude Code: permissions of the project (.claude/settings.local.json):"
|
||
|
|
put "${here}/claude/settings.local.json" "${repo}/.claude/settings.local.json" 644
|
||
|
|
|
||
|
|
# Claude Code keeps a project's memory and sessions under a folder named after its path.
|
||
|
|
slug="$(printf '%s' "${repo}" | sed 's/[^A-Za-z0-9]/-/g')"
|
||
|
|
project=~/.claude/projects/"${slug}"
|
||
|
|
echo "Claude Code: memory and the past sessions (${project}):"
|
||
|
|
for f in "${here}"/claude/memory/*.md; do put "${f}" "${project}/memory/$(basename "${f}")" 644; done
|
||
|
|
for z in "${here}"/claude/transcripts/*.jsonl.zst; do
|
||
|
|
out="${project}/$(basename "${z}" .zst)"
|
||
|
|
if [[ -e "${out}" ]]; then echo " ${out} is there already"; else zstd -q -d "${z}" -o "${out}"; echo " ${out}"; fi
|
||
|
|
done
|
||
|
|
for z in "${here}"/claude/transcripts/*.dir.tar.zst; do
|
||
|
|
zstd -q -d -c "${z}" | tar -C "${project}" -xf - --skip-old-files
|
||
|
|
done
|
||
|
|
|
||
|
|
echo "Done. Next: docs/dev/handoff.md in the repository."
|