From 40e588e0e73c7d508e78b57f8fde3d22ac1563f5 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Sun, 30 Sep 2018 11:49:56 +0100
Subject: [PATCH] website directory

---
 website/deploy.sh | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/website/deploy.sh b/website/deploy.sh
index 8c552b598..d78a897de 100755
--- a/website/deploy.sh
+++ b/website/deploy.sh
@@ -1,7 +1,6 @@
 #!/bin/bash
 
 lang=$1
-dest_dir=$2
 
 PROJECT_NAME=freedombone
 
@@ -11,6 +10,16 @@ ONION_ONLY='no'
 site_domain=${PROJECT_NAME}.net
 site_onion_port=8149
 
+if [ ! -d /root/${PROJECT_NAME}/website ]; then
+    echo "Directory not found /root/${PROJECT_NAME}/website"
+    exit 1
+fi
+
+dest_dir="/var/www/${site_domain}/htdocs"
+if [ ! -d "$dest_dir" ]; then
+    mkdir -p "$dest_dir"
+fi
+
 if [ -f "$CONFIGURATION_FILE" ]; then
     ONION_ONLY=$(grep 'ONION_ONLY=' "$CONFIGURATION_FILE" | head -n 1 | awk -F '=' '{print $2}')
 fi
@@ -27,7 +36,7 @@ if [[ "$ONION_ONLY" == 'no' ]]; then
       echo '    listen 80;';
       echo '    listen [::]:80;';
       echo "    server_name ${site_domain};";
-      echo "    root /var/www/${site_domain}/htdocs;";
+      echo "    root ${dest_dir};";
       echo '    access_log /dev/null;';
       echo '    error_log /dev/null;';
       echo '    client_max_body_size 20m;';
@@ -74,7 +83,7 @@ if [[ "$ONION_ONLY" == 'no' ]]; then
       echo '  access_log /dev/null;';
       echo '  error_log /dev/null;';
       echo '';
-      echo "  root /var/www/${site_domain}/htdocs;";
+      echo "  root ${dest_dir};";
       echo '';
       echo '  index index.html;';
       echo '';
@@ -159,7 +168,7 @@ fi
   echo '    access_log /dev/null;';
   echo '    error_log /dev/null;';
   echo '';
-  echo "    root /var/www/${site_domain}/htdocs;";
+  echo "    root ${dest_dir};";
   echo '';
   echo '    index index.html;';
   echo '';
@@ -222,10 +231,8 @@ fi
 if [ ! "$lang" ]; then
     lang='EN'
 fi
-if [ ! "$2" ]; then
-    echo 'Specify language and destination directory'
-    exit 1
-fi
+
+cd /root/${PROJECT_NAME}/website || exit 2
 
 if [ ! -d "$dest_dir" ]; then
     mkdir -p "$dest_dir"
-- 
GitLab