Skip to content

Commit 01b55fc

Browse files
committed
Add missing Bosco setup script
1 parent 85c1595 commit 01b55fc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

hosted-ce/bosco-override-setup.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# Populate the bosco override dir from a Git repo
4+
# Expected Git repo layout:
5+
# RESOURCE_NAME_1/
6+
# bosco_override/
7+
# ...
8+
# RESOURCE_NAME_2/
9+
# bosco_override/
10+
# ...
11+
# ...
12+
13+
function errexit {
14+
echo "$1" >&2
15+
exit 1
16+
}
17+
18+
[[ $# -ge 2 ]] || errexit "Usage: bosco-override-setup.sh <GIT ENDPOINT> <RESOURCE NAME> [<GIT SSH KEY>]"
19+
20+
GIT_ENDPOINT=$1
21+
RESOURCE_NAME=$2
22+
GIT_SSH_KEY=$3
23+
24+
# pre-scan the Git repo's host key
25+
if [[ $GIT_ENDPOINT =~ ^([A-Za-z0-9_-]+)@([^:]+): ]]; then
26+
GIT_USER="${BASH_REMATCH[1]}"
27+
GIT_HOST="${BASH_REMATCH[2]}"
28+
GIT_HOST_KEY=$(ssh-keyscan "$GIT_HOST")
29+
if [[ -n $GIT_HOST_KEY ]]; then
30+
echo $GIT_HOST_KEY >> /etc/ssh/ssh_known_hosts
31+
else
32+
errexit "Failed to determine host key for $GIT_HOST"
33+
fi
34+
35+
if [[ -f "$GIT_SSH_KEY" ]]; then
36+
cat <<EOF >> /etc/ssh/ssh_config
37+
38+
Host $GIT_HOST
39+
User $GIT_USER
40+
IdentityFile $GIT_SSH_KEY
41+
EOF
42+
fi
43+
fi
44+
45+
REPO_DIR=$(mktemp -d)
46+
OVERRIDE_DIR=/etc/condor-ce/bosco_override/
47+
48+
git clone --depth=1 $GIT_ENDPOINT $REPO_DIR || errexit "Failed to clone $GIT_ENDPOINT into $REPO_DIR"
49+
50+
# Bosco override dirs are expected in the following location in the git repo:
51+
# <RESOURCE NAME>/bosco_override/
52+
RESOURCE_DIR="$REPO_DIR/$RESOURCE_NAME/"
53+
[[ -d $RESOURCE_DIR ]] || errexit "Could not find $RESOURCE_NAME/ under $GIT_ENDPOINT"
54+
rsync -az "$RESOURCE_DIR/bosco_override/" $OVERRIDE_DIR

0 commit comments

Comments
 (0)