summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..ad31a42
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+SITE_NAME="codegolf"
+CONF_NAME="${SITE_NAME}.nginx.conf"
+
+WWW_DIR="/var/www/${SITE_NAME}"
+
+ENABLED_DIR="/etc/nginx/sites-enabled"
+AVAILABLE_DIR="/etc/nginx/sites-available"
+
+function deploy_site {
+ sudo mkdir -p $WWW_DIR
+ sudo cp -r "static/." $WWW_DIR
+ sudo cp $CONF_NAME $AVAILABLE_DIR
+}
+
+function enable_site {
+
+ local AVAILABLE_CONF="$AVAILABLE_DIR/$CONF_NAME"
+ local ENABLED_CONF="$ENABLED_DIR/$CONF_NAME"
+
+ # enable site by linking available conf into enabled directory
+ if [[ -h $ENABLED_CONF ]]; then
+ sudo rm $ENABLED_CONF
+ sudo ln -s $AVAILABLE_CONF $ENABLED_CONF
+ elif [[ ! -e $ENABLED_CONF ]]; then
+ sudo ln -s $AVAILABLE_CONF $ENABLED_CONF
+ else
+ echo "$ENABLED_CONF already exists and is not a symlink"
+ exit 1
+ fi
+
+
+ # reload the nginx config
+ sudo nginx -s reload
+}
+
+deploy_site
+enable_site
+