Skip to content

Commit ef8c017

Browse files
authored
Add deploy script (#155)
1 parent 86592ab commit ef8c017

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

deploy/remote.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#! /usr/bin/env bash
2+
3+
set -ex
4+
5+
# This script should be run on the trypurescript server to deploy a new
6+
# version. It does not attempt to take care of any of the following:
7+
#
8+
# - configuration of secrets/credentials
9+
# - nginx SSL configuration
10+
#
11+
# so whenever any of these are needed, they must be done manually.
12+
13+
if [ $(id --user) -ne 0 ]
14+
then
15+
echo >&2 "This script must be run as root"
16+
exit 1
17+
fi
18+
19+
trypurescript_version="$1"
20+
21+
if [ "$trypurescript_version" = "" ]
22+
then
23+
echo >&2 "Need to provide a version"
24+
exit 1
25+
fi
26+
27+
download_url_base="https://github.com/purescript/trypurescript/releases/download/${trypurescript_version}"
28+
29+
echo "[$(date)] $0: starting trypurescript install"
30+
31+
# set up directories for deploying into
32+
if [ ! -d /var/www/trypurescript ]; then
33+
mkdir -p /var/www/trypurescript
34+
chown -R www-data:www-data /var/www/trypurescript
35+
fi
36+
37+
# download release
38+
tmpdir="$(sudo -u www-data mktemp -d)"
39+
pushd "$tmpdir"
40+
for component in server client; do
41+
bundle="trypurescript-${component}.tar.gz"
42+
sudo -u www-data wget "$download_url_base/${bundle}"
43+
sudo -u www-data tar xzf "$bundle" -C /var/www/trypurescript --overwrite
44+
done
45+
# We install the binary to a location outside of /var/www/trypurescript so that we
46+
# can extract tar.gz files into /var/www/trypurescript safely in future deploys.
47+
install /var/www/trypurescript/trypurescript /usr/local/bin/trypurescript
48+
popd
49+
rm -r "$tmpdir"
50+
51+
# install nginx config
52+
cp /var/www/trypurescript/deploy/nginx.conf /etc/nginx/sites-enabled/trypurescript.conf
53+
systemctl reload nginx
54+
55+
# install systemd service confing
56+
cp /var/www/trypurescript/deploy/trypurescript.service /etc/systemd/system/trypurescript.service
57+
systemctl daemon-reload
58+
systemctl restart trypurescript.service
59+
60+
echo "[$(date)] $0: done trypurescript install"

deploy/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! /usr/bin/env bash
2+
3+
set -ex
4+
5+
# This script can be run to deploy a new version of Try PureScript.
6+
7+
trypurescript_version="$1"
8+
9+
if [ "$trypurescript_version" = "" ]
10+
then
11+
echo >&2 "Need to provide a version"
12+
exit 1
13+
fi
14+
15+
deploy_script="deploy-trypurescript.sh"
16+
scp deploy/remote.sh "[email protected]:${deploy_script}"
17+
ssh [email protected] "bash ${deploy_script} ${trypurescript_version}"

0 commit comments

Comments
 (0)