forked from TiddlySpace/tiddlyspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·42 lines (36 loc) · 1.22 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
#!/usr/bin/env bash
# Usage:
# $ ./deploy.sh [quick] [<logname>]
package_name="tiddlywebplugins.tiddlyspace"
host="tiddlyspace.com"
remote_sudo_id="tiddlyweb"
instance_dir="/home/tiddlyweb/tiddlywebs/tiddlyspace.com"
set -e
set -x
if [ ! -d .git ]; then
echo "ERROR: script must be executed from repository root"
exit 1
fi
# TODO: use getopts
if [ "$1" = "quick" ]; then
pip_options="--no-dependencies"
shift
fi
if [ -n "$1" ]; then
log_name="$1@"
fi
host="${log_name}${host}"
sql="DELETE FROM revision WHERE bag_name='system' OR bag_name='tiddlyspace' \
OR bag_name='system-plugins_public' \
OR bag_name='system-info_public' \
OR bag_name='system-images_public' \
OR bag_name='system-theme_public'; \
DELETE FROM tiddler WHERE bag_name='system' OR bag_name='tiddlyspace' \
OR bag_name='system-plugins_public' \
OR bag_name='system-info_public' \
OR bag_name='system-images_public' \
OR bag_name='system-theme_public';"
ssh $host "sudo pip install --upgrade $pip_options $package_name && " \
"mysql -u tiddlyweb tiddlyspace -e \"${sql}\" && " \
"cd $instance_dir && sudo -u $remote_sudo_id twanager update && " \
"sudo apache2ctl restart && echo INFO: deployment complete"