-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·48 lines (36 loc) · 1.03 KB
/
deploy.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
#! /usr/bin/env bash
#
# usage: ./deploy.sh <hostname>.lafayette.edu
usage() {
echo "usage: $0 <hostname>.lafayette.edu"
}
target_dir="/var/www/purefood/"
host=$1
if [ -z "$host" ]; then
echo -e "No host provided!\n"
usage && exit 1
fi
echo "checking to see if $target_dir exists..."
ssh $host stat $target_dir > /dev/null 2>&1
if [ $? -ne 0 ]; then
cat <<-EOL
[error] looks like the target directory doesn't exist! try running:
mkdir -p $target_dir
on $host (make sure you can write to it!) and try again.
EOL
exit 1
fi
echo "generating fresh build"
bundle exec jekyll clean
bundle exec jekyll build --safe
echo "moving the contents to $host"
# -r => recursive
# -a => archive mode
# -v => verbose
# -e ssh => which shell to use
# --delete => delete extraneous files on the target server
#
# note to self: make sure the directories have a trailing slash
# so that only the contents are copied and not the
# directories themselves.
rsync -rav -e ssh --delete _site/ $host:$target_dir