-
Notifications
You must be signed in to change notification settings - Fork 0
/
unison.sh
69 lines (58 loc) · 1.39 KB
/
unison.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
#
# Facebook CTF: Script to install unison. Valid version: 2.48.4
# https://keylocation.sg/blog/vagrant-and-unison-without-a-plugin/
#
# Usage: ./unison.sh [path_to_ctf_code] [unison_full_path] [unison_version]
#
if [[ "$#" -lt 1 ]]; then
echo "[!] Need path to CTF folder"
exit 1
fi
CODE_PATH="$1"
if [[ -z "$2" ]]; then
UNISON="unison"
else
UNISON="$2"
fi
if [[ -z "$3" ]]; then
UNISON_VERSION="2.48.4"
else
UNISON_VERSION="$3"
fi
# Make sure the right version is installed
if [[ "$($UNISON -version | awk '{print $3}')" != "$UNISON_VERSION" ]]; then
echo "Sorry, you need unison $UNISON_VERSION"
exit 1
fi
# Generate ssh-config file from vagrant
echo "[+] Generating SSH config"
SSH_CONFIG="$CODE_PATH/.vagrant/ssh-config"
vagrant ssh-config > "$SSH_CONFIG"
# Create unison profile
echo "[+] Creating unison profile"
PROFILE="
root = $CODE_PATH
root = ssh://default//var/www/fbctf/
ignore = Name {.vagrant,.DS_Store,.sources,node_modules,settings.ini}
prefer = $CODE_PATH
repeat = 2
terse = true
dontchmod = false
perms = 0
sshargs = -F $SSH_CONFIG
"
# Write profile
if [[ -z ${USERPROFILE+x} ]]; then
UNISONDIR=$HOME
else
UNISONDIR=$USERPROFILE
fi
cd $UNISONDIR
[[ -d "$UNISONDIR/.unison" ]] || mkdir "$UNISONDIR/.unison"
echo "$PROFILE" > "$UNISONDIR/.unison/fbctf.prf"
echo "[+] Sync'ing project in the background..."
$UNISON "fbctf" &
echo "[+] Done"
exit 0
#kthxbai