aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/deploy.sh34
-rwxr-xr-xscripts/post-deploy.sh25
-rwxr-xr-xscripts/provision.sh20
3 files changed, 79 insertions, 0 deletions
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
new file mode 100755
index 0000000..a2bde7a
--- /dev/null
+++ b/scripts/deploy.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -ex
+
+
+source license-generator/.env
+
+echo 'Deploying...'
+
+rsync -avz \
+ --exclude 'assets/stylesheets' \
+ 400.html \
+ 404.html \
+ assets \
+ doc \
+ downloads \
+ index.html \
+ internal_error.html \
+ license-generator/target/release/fulfillment \
+ license-generator/target/release/license \
+ robots.txt \
+ thank-you.html \
+ "$SSH_SERVER":"$REMOTE_PUBLIC_WWW/"
+
+rsync -avz \
+ --exclude '.git' \
+ license-generator/migrations \
+ production-config \
+ scripts \
+ "$SSH_SERVER":~/
+
+
+echo 'Running post-deploy script...'
+ssh "$SSH_SERVER" 'bash ~/scripts/post-deploy.sh'
diff --git a/scripts/post-deploy.sh b/scripts/post-deploy.sh
new file mode 100755
index 0000000..4d3fd9c
--- /dev/null
+++ b/scripts/post-deploy.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -ex
+
+
+export PATH="$HOME/opt/bin:$PATH"
+
+source "$HOME/production-config/env"
+
+echo 'Moving files...'
+
+mv "$REMOTE_PUBLIC_WWW/fulfillment" "$REMOTE_PUBLIC_WWW/fulfillment.fcgi"
+mv "$REMOTE_PUBLIC_WWW/license" "$REMOTE_PUBLIC_WWW/license.fcgi"
+
+mv production-config/.htaccess "$REMOTE_PUBLIC_WWW"
+
+
+echo 'Provisioning...'
+
+sh "$HOME/scripts/provision.sh"
+
+
+echo 'Migrating database...'
+
+migrate-up
diff --git a/scripts/provision.sh b/scripts/provision.sh
new file mode 100755
index 0000000..bf8e478
--- /dev/null
+++ b/scripts/provision.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -ex
+
+OPT="$HOME/opt"
+
+
+if [ ! -f "$OPT/bin/migrate" ]; then
+ echo "Installing 'migrate'..."
+
+ mkdir -p "$OPT/bin"
+
+ curl \
+ --remote-name \
+ --location 'https://github.com/golang-migrate/migrate/releases/download/v4.0.2/migrate.linux-amd64.tar.gz'
+
+ tar xf migrate.linux-amd64.tar.gz
+ mv migrate.linux-amd64 "$OPT/bin/migrate"
+ rm migrate.linux-amd64.tar.gz
+fi