-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_workspace.bash
More file actions
executable file
·39 lines (31 loc) · 1.13 KB
/
Copy pathsync_workspace.bash
File metadata and controls
executable file
·39 lines (31 loc) · 1.13 KB
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
35
36
37
38
39
#!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
SSH_KEY="${JACKAL_AUTONOMY_SSH_KEY:-${HOME}/.ssh/id_ed25519_ankit}"
UPDATE_MODE="pinned"
if [ "${1:-}" = "--remote" ]; then
UPDATE_MODE="remote"
elif [ "$#" -ne 0 ]; then
echo "Usage: $0 [--remote]"
exit 2
fi
if [ ! -f "$SSH_KEY" ]; then
echo "ERROR: SSH key not found: $SSH_KEY"
echo "Set JACKAL_AUTONOMY_SSH_KEY to override the key path."
exit 1
fi
key_mode="$(stat -c '%a' "$SSH_KEY")"
if [ "$key_mode" != "600" ]; then
echo "ERROR: Private SSH key must have mode 600: $SSH_KEY (found $key_mode)"
exit 1
fi
printf -v shell_quoted_key '%q' "$SSH_KEY"
export GIT_SSH_COMMAND="ssh -i $shell_quoted_key -o IdentitiesOnly=yes -o BatchMode=yes"
git -C "$PROJECT_DIR" submodule sync --recursive
if [ "$UPDATE_MODE" = "remote" ]; then
git -C "$PROJECT_DIR" submodule update --init --remote
git -C "$PROJECT_DIR" submodule foreach 'git submodule sync --recursive && git submodule update --init --recursive'
else
git -C "$PROJECT_DIR" submodule update --init --recursive
fi
git -C "$PROJECT_DIR" submodule status --recursive