forked from matematikk-mooc/mmooc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
b2d
executable file
·45 lines (40 loc) · 1.42 KB
/
b2d
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
#! /bin/bash
canvas_dir=$(pwd)/canvas-lms/
excludes="--exclude=.git --exclude=vendor/ --exclude=tmp"
ssh_key=$(boot2docker config 2> /dev/null | grep SSHKey | cut -d '"' -f2)
ssh_port=$(boot2docker config 2> /dev/null | grep SSHPort | cut -d' ' -f3)
ip_address=$(boot2docker ip 2> /dev/null)
hash fswatch 2> /dev/null || {
echo "Installing fswatch ..."
brew install fswatch
}
case $1 in
init)
boot2docker ssh tce-load -wi rsync
boot2docker ssh sudo mkdir -p $canvas_dir
boot2docker ssh sudo chown docker.docker $canvas_dir
scp -r -i $ssh_key canvas-lms docker@$ip_address:$(pwd)
;;
url)
url=$(boot2docker ip 2>/dev/null):$(docker port web 80 | cut -d: -f2)
echo "The following URL have been copied to your clipboard: $url"
echo $url | pbcopy
;;
watch)
rsync -av --del -e "ssh -i $ssh_key" $excludes canvas-lms/ --port=$ssh_port canvas-lms/ docker@$ip_address:$canvas_dir
echo "Watching..."
fswatch -o canvas-lms | \
xargs -t -n1 -I % \
rsync -av --del -e "ssh -i $ssh_key" $excludes canvas-lms/ --port=$ssh_port canvas-lms/ docker@$ip_address:$canvas_dir
;;
*)
cat <<EOF
Usage: b2d COMMAND
Utilities for doing development using boot2docker
Commands:
init First time initialization for setting up Canvas development environment
url FIXME
watch FIXME
EOF
;;
esac