浏览代码

Remove turtl app

Bob Mottram 8 年前
父节点
当前提交
7abc762bfc
共有 1 个文件被更改,包括 65 次插入191 次删除
  1. 65
    191
      src/freedombone-app-turtl

+ 65
- 191
src/freedombone-app-turtl 查看文件

36
 IN_DEFAULT_INSTALL=0
36
 IN_DEFAULT_INSTALL=0
37
 SHOW_ON_ABOUT=1
37
 SHOW_ON_ABOUT=1
38
 
38
 
39
-TURTL_DOMAIN_NAME=
40
-TURTL_CODE=
41
-TURTL_ONION_PORT=8107
42
-TURTL_API_ONION_PORT=8108
39
+TURTL_API_DOMAIN_NAME=
40
+TURTL_API_CODE=
41
+TURTL_API_ONION_PORT=8107
43
 TURTL_PORT=8181
42
 TURTL_PORT=8181
44
 TURTL_API_REPO="https://github.com/turtl/api.git"
43
 TURTL_API_REPO="https://github.com/turtl/api.git"
45
 TURTL_API_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf'
44
 TURTL_API_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf'
46
-TURTL_REPO="https://github.com/turtl/js.git"
47
-TURTL_COMMIT='61923ffb47d95d172f80d14c76aa032a4d5f5d6d'
48
 TURTL_ADMIN_PASSWORD=
45
 TURTL_ADMIN_PASSWORD=
49
 TURTL_STORAGE_LIMIT_MB=100
46
 TURTL_STORAGE_LIMIT_MB=100
50
 TURTL_BASE_DIR=/etc/turtl
47
 TURTL_BASE_DIR=/etc/turtl
51
 
48
 
52
 turtl_variables=(ONION_ONLY
49
 turtl_variables=(ONION_ONLY
53
                  DEFAULT_DOMAIN_NAME
50
                  DEFAULT_DOMAIN_NAME
54
-                 TURTL_DOMAIN_NAME
55
-                 TURTL_CODE
51
+                 TURTL_API_DOMAIN_NAME
52
+                 TURTL_API_CODE
56
                  TURTL_STORAGE_LIMIT_MB
53
                  TURTL_STORAGE_LIMIT_MB
57
                  DDNS_PROVIDER
54
                  DDNS_PROVIDER
58
                  MY_EMAIL_ADDRESS
55
                  MY_EMAIL_ADDRESS
79
     fi
76
     fi
80
 
77
 
81
     if [[ $ONION_ONLY != "no" ]]; then
78
     if [[ $ONION_ONLY != "no" ]]; then
82
-        TURTL_DOMAIN_NAME='notes.local'
83
-        write_config_param "TURTL_DOMAIN_NAME" "$TURTL_DOMAIN_NAME"
79
+        TURTL_API_DOMAIN_NAME='notes.local'
80
+        write_config_param "TURTL_API_DOMAIN_NAME" "$TURTL_API_DOMAIN_NAME"
84
     else
81
     else
85
         function_check interactive_site_details
82
         function_check interactive_site_details
86
-        interactive_site_details "turtl" "TURTL_DOMAIN_NAME" "TURTL_CODE"
87
-        write_config_param "API_TURTL_DOMAIN_NAME" "api.${TURTL_DOMAIN_NAME}"
88
-        write_config_param "API_TURTL_CODE" "${TURTL_CODE}"
83
+        interactive_site_details "turtl" "TURTL_API_DOMAIN_NAME" "TURTL_API_CODE"
89
     fi
84
     fi
90
     APP_INSTALLED=1
85
     APP_INSTALLED=1
91
 }
86
 }
113
 
108
 
114
 
109
 
115
 function reconfigure_turtl {
110
 function reconfigure_turtl {
116
-    if [ -d /var/www/${TURTL_DOMAIN_NAME}/htdocs/data ]; then
117
-        rm -rf /var/www/${TURTL_DOMAIN_NAME}/htdocs/data/*
111
+    if [ -d $TURTL_BASE_DIR/data ]; then
112
+        rm -rf $TURTL_BASE_DIR/data/*
118
     fi
113
     fi
119
 }
114
 }
120
 
115
 
121
 function upgrade_turtl {
116
 function upgrade_turtl {
122
-    read_config_param "TURTL_DOMAIN_NAME"
117
+    read_config_param "TURTL_API_DOMAIN_NAME"
123
 
118
 
124
     function_check set_repo_commit
119
     function_check set_repo_commit
125
-    set_repo_commit /var/www/$TURTL_DOMAIN_NAME/htdocs "turtl commit" "$TURTL_COMMIT" $TURTL_REPO
126
     set_repo_commit $TURTL_BASE_DIR/api "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO
120
     set_repo_commit $TURTL_BASE_DIR/api "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO
127
-    nginx_dissite $TURTL_DOMAIN_NAME
128
-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs
129
-    rm -rf node_modules npm-shrinkwrap.json
130
-    npm install uglify@0.1.5 --no-optional
131
-    npm install minimatch@3.0.2 --no-optional
132
-    npm install --no-optional
133
-    sed -i 's|{config,controllers,handlers,locales,library,models,turtl}|.|g' Makefile
134
-    sed -i 's|tests/{data,tests}|tests|g' Makefile
135
-    make clean
136
-    make
121
+    nginx_dissite $TURTL_API_DOMAIN_NAME
137
     chown -R turtl:turtl $TURTL_BASE_DIR
122
     chown -R turtl:turtl $TURTL_BASE_DIR
138
-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs
139
-    nginx_ensite $TURTL_DOMAIN_NAME
123
+    nginx_ensite $TURTL_API_DOMAIN_NAME
140
 }
124
 }
141
 
125
 
142
 function backup_local_turtl {
126
 function backup_local_turtl {
143
-    read_config_param "TURTL_DOMAIN_NAME"
144
-    source_directory=/var/www/${TURTL_DOMAIN_NAME}/htdocs
127
+    read_config_param "TURTL_API_DOMAIN_NAME"
128
+    source_directory=$TURTL_BASE_DIR
145
     if [ -d $source_directory ]; then
129
     if [ -d $source_directory ]; then
146
         dest_directory=turtl
130
         dest_directory=turtl
147
         function_check suspend_site
131
         function_check suspend_site
148
-        suspend_site ${TURTL_DOMAIN_NAME}
132
+        suspend_site ${TURTL_API_DOMAIN_NAME}
149
 
133
 
150
         function_check backup_directory_to_usb
134
         function_check backup_directory_to_usb
151
         backup_directory_to_usb $source_directory $dest_directory
135
         backup_directory_to_usb $source_directory $dest_directory
157
     if [ -d $source_directory ]; then
141
     if [ -d $source_directory ]; then
158
         dest_directory=rethinkdb
142
         dest_directory=rethinkdb
159
         function_check suspend_site
143
         function_check suspend_site
160
-        suspend_site ${TURTL_DOMAIN_NAME}
144
+        suspend_site ${TURTL_API_DOMAIN_NAME}
161
 
145
 
162
         function_check backup_directory_to_usb
146
         function_check backup_directory_to_usb
163
         backup_directory_to_usb $source_directory $dest_directory
147
         backup_directory_to_usb $source_directory $dest_directory
168
 }
152
 }
169
 
153
 
170
 function restore_local_turtl {
154
 function restore_local_turtl {
171
-    read_config_param "TURTL_DOMAIN_NAME"
172
-    if [ $TURTL_DOMAIN_NAME ]; then
155
+    read_config_param "TURTL_API_DOMAIN_NAME"
156
+    if [ $TURTL_API_DOMAIN_NAME ]; then
173
         temp_restore_dir=/root/tempturtl
157
         temp_restore_dir=/root/tempturtl
174
         restore_directory_from_usb $temp_restore_dir turtl
158
         restore_directory_from_usb $temp_restore_dir turtl
175
-        if [ -d /var/www/${TURTL_DOMAIN_NAME}/htdocs ]; then
176
-            if [ -d /var/www/${TURTL_DOMAIN_NAME}/previous ]; then
177
-                rm -rf /var/www/${TURTL_DOMAIN_NAME}/previous
159
+        if [ -d $TURTL_BASE_DIR ]; then
160
+            if [ -d /etc/turtl_previous ]; then
161
+                rm -rf /etc/turtl_previous
178
             fi
162
             fi
179
-            mv /var/www/${TURTL_DOMAIN_NAME}/htdocs /var/www/${TURTL_DOMAIN_NAME}/previous
163
+            mv $TURTL_BASE_DIR /etc/turtl_previous
180
         fi
164
         fi
181
-        temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
182
-        cp -r ${temp_source_dir} /var/www/${TURTL_DOMAIN_NAME}/
165
+        temp_source_dir=$(find ${temp_restore_dir} -name turtl)
166
+        cp -r ${temp_source_dir} /etc/
183
         if [ ! "$?" = "0" ]; then
167
         if [ ! "$?" = "0" ]; then
184
-            if [ -d /var/www/${TURTL_DOMAIN_NAME}/previous ]; then
185
-                mv /var/www/${TURTL_DOMAIN_NAME}/previous /var/www/${TURTL_DOMAIN_NAME}/htdocs
168
+            if [ -d /etc/turtl_previous ]; then
169
+                mv /etc/turtl_previous $TURTL_BASE_DIR
186
             fi
170
             fi
187
             set_user_permissions
171
             set_user_permissions
188
             backup_unmount_drive
172
             backup_unmount_drive
189
             exit 36723
173
             exit 36723
190
         fi
174
         fi
191
         rm -rf ${temp_restore_dir}
175
         rm -rf ${temp_restore_dir}
192
-        chown -R turtl:turtl /var/www/${TURTL_DOMAIN_NAME}/htdocs
176
+        chown -R turtl:turtl $TURTL_BASE_DIR
193
 
177
 
194
         temp_restore_dir=/root/temprethinkdb
178
         temp_restore_dir=/root/temprethinkdb
195
         restore_directory_from_usb $temp_restore_dir rethinkdb
179
         restore_directory_from_usb $temp_restore_dir rethinkdb
214
 }
198
 }
215
 
199
 
216
 function backup_remote_turtl {
200
 function backup_remote_turtl {
217
-    read_config_param "TURTL_DOMAIN_NAME"
218
-    if [ $TURTL_DOMAIN_NAME ]; then
219
-        temp_backup_dir=/var/www/${TURTL_DOMAIN_NAME}/htdocs
201
+    read_config_param "TURTL_API_DOMAIN_NAME"
202
+    if [ $TURTL_API_DOMAIN_NAME ]; then
203
+        temp_backup_dir=$TURTL_BASE_DIR
220
         if [ -d $temp_backup_dir ]; then
204
         if [ -d $temp_backup_dir ]; then
221
             echo $"Backing up turtl"
205
             echo $"Backing up turtl"
222
             backup_directory_to_friend $temp_backup_dir turtl
206
             backup_directory_to_friend $temp_backup_dir turtl
236
 }
220
 }
237
 
221
 
238
 function restore_remote_turtl {
222
 function restore_remote_turtl {
239
-    read_config_param "TURTL_DOMAIN_NAME"
240
-    if [ $TURTL_DOMAIN_NAME ]; then
223
+    read_config_param "TURTL_API_DOMAIN_NAME"
224
+    if [ $TURTL_API_DOMAIN_NAME ]; then
241
         temp_restore_dir=/root/tempturtl
225
         temp_restore_dir=/root/tempturtl
242
         mkdir $temp_restore_dir
226
         mkdir $temp_restore_dir
243
         function_check restore_directory_from_friend
227
         function_check restore_directory_from_friend
244
         restore_directory_from_friend $temp_restore_dir turtl
228
         restore_directory_from_friend $temp_restore_dir turtl
245
-        if [ -d /var/www/${TURTL_DOMAIN_NAME}/htdocs ]; then
246
-            if [ -d /var/www/${TURTL_DOMAIN_NAME}/previous ]; then
247
-                rm -rf /var/www/${TURTL_DOMAIN_NAME}/previous
229
+        if [ -d $TURTL_BASE_DIR ]; then
230
+            if [ -d /etc/turtl_previous ]; then
231
+                rm -rf /etc/turtl_previous
248
             fi
232
             fi
249
-            mv /var/www/${TURTL_DOMAIN_NAME}/htdocs /var/www/${TURTL_DOMAIN_NAME}/previous
233
+            mv $TURTL_BASE_DIR /etc/turtl_previous
250
         fi
234
         fi
251
-        temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
252
-        cp -r ${temp_source_dir} /var/www/${TURTL_DOMAIN_NAME}/
235
+        temp_source_dir=$(find ${temp_restore_dir} -name turtl)
236
+        cp -r ${temp_source_dir} /etc/
253
         if [ ! "$?" = "0" ]; then
237
         if [ ! "$?" = "0" ]; then
254
-            if [ -d /var/www/${TURTL_DOMAIN_NAME}/previous ]; then
255
-                mv /var/www/${TURTL_DOMAIN_NAME}/previous /var/www/${TURTL_DOMAIN_NAME}/htdocs
238
+            if [ -d /etc/turtl_previous ]; then
239
+                mv /etc/turtl_previous $TURTL_BASE_DIR
256
             fi
240
             fi
257
             exit 37823
241
             exit 37823
258
         fi
242
         fi
259
         rm -rf ${temp_restore_dir}
243
         rm -rf ${temp_restore_dir}
260
 
244
 
261
-
262
         temp_restore_dir=/root/temprethinkdb
245
         temp_restore_dir=/root/temprethinkdb
263
         mkdir $temp_restore_dir
246
         mkdir $temp_restore_dir
264
         function_check restore_directory_from_friend
247
         function_check restore_directory_from_friend
293
     remove_completion_param install_turtl
276
     remove_completion_param install_turtl
294
     sed -i '/turtl/d' $COMPLETION_FILE
277
     sed -i '/turtl/d' $COMPLETION_FILE
295
     deluser turtl
278
     deluser turtl
296
-    nginx_dissite $TURTL_DOMAIN_NAME
297
-    if [ -f /etc/nginx/sites-available/$TURTL_DOMAIN_NAME ]; then
298
-        rm /etc/nginx/sites-available/$TURTL_DOMAIN_NAME
299
-    fi
300
-    remove_certs $TURTL_DOMAIN_NAME
301
-    if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then
302
-        rm -rf /var/www/$TURTL_DOMAIN_NAME
279
+    nginx_dissite $TURTL_API_DOMAIN_NAME
280
+    if [ -f /etc/nginx/sites-available/$TURTL_API_DOMAIN_NAME ]; then
281
+        rm /etc/nginx/sites-available/$TURTL_API_DOMAIN_NAME
303
     fi
282
     fi
283
+    remove_certs $TURTL_API_DOMAIN_NAME
304
     function_check remove_onion_service
284
     function_check remove_onion_service
305
-    remove_onion_service turtl ${TURTL_ONION_PORT}
306
     remove_onion_service turtlapi ${TURTL_API_ONION_PORT}
285
     remove_onion_service turtlapi ${TURTL_API_ONION_PORT}
307
     function_check remove_ddns_domain
286
     function_check remove_ddns_domain
308
-    remove_ddns_domain $TURTL_DOMAIN_NAME
309
-    remove_nodejs turtl
287
+    remove_ddns_domain $TURTL_API_DOMAIN_NAME
310
     rm -rf /etc/rethinkdb
288
     rm -rf /etc/rethinkdb
311
     rm -rf /var/lib/rethinkdb
289
     rm -rf /var/lib/rethinkdb
312
     rm -rf $TURTL_BASE_DIR
290
     rm -rf $TURTL_BASE_DIR
318
     BINDADDR=${BINDADDR:-0.0.0.0}
296
     BINDADDR=${BINDADDR:-0.0.0.0}
319
     BINDPORT=${BINDPORT:-8181}
297
     BINDPORT=${BINDPORT:-8181}
320
     PROD_ERR_HANDLING=${PROD_ERR_HANDLING:-t}
298
     PROD_ERR_HANDLING=${PROD_ERR_HANDLING:-t}
321
-    FQDN=${FQDN:-turtl.local}
322
-    SITE_URL=${SITE_URL:-http://turtl.local}
299
+    FQDN=${FQDN:-$TURTL_API_DOMAIN_NAME}
300
+    SITE_URL=${SITE_URL:-https://$TURTL_API_DOMAIN_NAME}
323
     ADMIN_EMAIL=${ADMIN_EMAIL:-$MY_USERNAME@$DEFAULT_DOMAIN_NAME}
301
     ADMIN_EMAIL=${ADMIN_EMAIL:-$MY_USERNAME@$DEFAULT_DOMAIN_NAME}
324
     EMAIL_FROM=${EMAIL_FROM:-noreply@$DEFAULT_DOMAIN_NAME}
302
     EMAIL_FROM=${EMAIL_FROM:-noreply@$DEFAULT_DOMAIN_NAME}
325
     SMTP_USER=${SMTP_USER:-}
303
     SMTP_USER=${SMTP_USER:-}
327
     DISPLAY_ERRORS=${DISPLAY_ERRORS:-t}
305
     DISPLAY_ERRORS=${DISPLAY_ERRORS:-t}
328
     DEFAULT_STORAGE_LIMIT=${DEFAULT_STORAGE_LIMIT:-100}
306
     DEFAULT_STORAGE_LIMIT=${DEFAULT_STORAGE_LIMIT:-100}
329
     STORAGE_INVITE_CREDIT=${STORAGE_INVITE_CREDIT:-25}
307
     STORAGE_INVITE_CREDIT=${STORAGE_INVITE_CREDIT:-25}
330
-    LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-http://turtl.local}
331
-    LOCAL_UPLOAD_PATH=${LOCAL_UPLOAD_PATH:-"$TURTL_BASE_DIR/api/uploads"}
308
+    LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-https://$TURTL_API_DOMAIN_NAME}
309
+    LOCAL_UPLOAD_PATH=${LOCAL_UPLOAD_PATH:-"$TURTL_BASE_DIR/data"}
332
     AWS_S3_TOKEN=${AWS_S3_TOKEN:-(:token ''
310
     AWS_S3_TOKEN=${AWS_S3_TOKEN:-(:token ''
333
                                   :secret ''
311
                                   :secret ''
334
                                   :bucket ''
312
                                   :bucket ''
407
         mkdir -p $TURTL_BASE_DIR
385
         mkdir -p $TURTL_BASE_DIR
408
     fi
386
     fi
409
     cd $TURTL_BASE_DIR
387
     cd $TURTL_BASE_DIR
388
+    mkdir cd $TURTL_BASE_DIR/data
410
     check_architecture=$(uname -a)
389
     check_architecture=$(uname -a)
411
 
390
 
412
     # Install ccl
391
     # Install ccl
553
     turtl_setup
532
     turtl_setup
554
 }
533
 }
555
 
534
 
556
-function install_turtl_app {
557
-    function_check install_nodejs
558
-    install_nodejs turtl
559
-
560
-    if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then
561
-        rm -rf /var/www/$TURTL_DOMAIN_NAME
562
-    fi
563
-    mkdir -p /var/www/$TURTL_DOMAIN_NAME
564
-
565
-    if [ -f $IMAGE_PASSWORD_FILE ]; then
566
-        TURTL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
567
-    else
568
-        if [ ! $TURTL_ADMIN_PASSWORD ]; then
569
-            TURTL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
570
-        fi
571
-    fi
572
-
573
-    cd /var/www/$TURTL_DOMAIN_NAME
574
-    git_clone $TURTL_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs
575
-    git checkout $TURTL_COMMIT -b $TURTL_COMMIT
576
-    set_completion_param "turtl commit" "$TURTL_COMMIT"
577
-
578
-    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default ]; then
579
-        echo $'turtl app config file not found'
580
-        exit 737223
581
-    fi
582
-    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js
583
-
584
-    # change settings
585
-    sed -i "s|api_url.*|api_url: 'https://api.${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js
586
-    sed -i "s|site_url.*|site_url: 'https://${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js
587
-
588
-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs
589
-
590
-    TURTL_ONION_HOSTNAME=$(add_onion_service turtl 80 ${TURTL_ONION_PORT})
535
+function install_turtl_nginx {
591
     TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT})
536
     TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT})
592
 
537
 
593
-    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_DOMAIN_NAME
538
+    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_API_DOMAIN_NAME
594
     if [[ $ONION_ONLY == "no" ]]; then
539
     if [[ $ONION_ONLY == "no" ]]; then
595
         function_check nginx_http_redirect
540
         function_check nginx_http_redirect
596
-        nginx_http_redirect $TURTL_DOMAIN_NAME
541
+        nginx_http_redirect $TURTL_API_DOMAIN_NAME
597
         echo 'server {' >> $turtl_nginx_site
542
         echo 'server {' >> $turtl_nginx_site
598
         echo '  listen 443 ssl;' >> $turtl_nginx_site
543
         echo '  listen 443 ssl;' >> $turtl_nginx_site
599
         echo '  listen [::]:443 ssl;' >> $turtl_nginx_site
544
         echo '  listen [::]:443 ssl;' >> $turtl_nginx_site
600
-        echo "  server_name api.${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site
545
+        echo "  server_name ${TURTL_API_DOMAIN_NAME};" >> $turtl_nginx_site
601
         echo '' >> $turtl_nginx_site
546
         echo '' >> $turtl_nginx_site
602
         echo '  # Security' >> $turtl_nginx_site
547
         echo '  # Security' >> $turtl_nginx_site
603
         function_check nginx_ssl
548
         function_check nginx_ssl
604
-        nginx_ssl $TURTL_DOMAIN_NAME
549
+        nginx_ssl $TURTL_API_DOMAIN_NAME
605
 
550
 
606
         function_check nginx_disable_sniffing
551
         function_check nginx_disable_sniffing
607
-        nginx_disable_sniffing $TURTL_DOMAIN_NAME
552
+        nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
608
 
553
 
609
         echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
554
         echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
610
         echo '' >> $turtl_nginx_site
555
         echo '' >> $turtl_nginx_site
614
         echo '' >> $turtl_nginx_site
559
         echo '' >> $turtl_nginx_site
615
         echo '  location / {' >> $turtl_nginx_site
560
         echo '  location / {' >> $turtl_nginx_site
616
         function_check nginx_limits
561
         function_check nginx_limits
617
-        nginx_limits $TURTL_DOMAIN_NAME '15m'
562
+        nginx_limits $TURTL_API_DOMAIN_NAME '15m'
618
         echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
563
         echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
619
         echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
564
         echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
620
         echo '    proxy_buffering   off;' >> $turtl_nginx_site
565
         echo '    proxy_buffering   off;' >> $turtl_nginx_site
621
         echo '  }' >> $turtl_nginx_site
566
         echo '  }' >> $turtl_nginx_site
622
-        echo '' >> $turtl_nginx_site
623
-        echo '}' >> $turtl_nginx_site
624
-        echo '' >> $turtl_nginx_site
625
-        echo 'server {' >> $turtl_nginx_site
626
-        echo '  listen 443 ssl;' >> $turtl_nginx_site
627
-        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site
628
-        echo "  server_name ${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site
629
-        echo '' >> $turtl_nginx_site
630
-        echo '  index index.html;' >> $turtl_nginx_site
631
-        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site
632
-        echo '' >> $turtl_nginx_site
633
-        echo '  # Security' >> $turtl_nginx_site
634
-        function_check nginx_ssl
635
-        nginx_ssl $TURTL_DOMAIN_NAME
636
-
637
-        function_check nginx_disable_sniffing
638
-        nginx_disable_sniffing $TURTL_DOMAIN_NAME
639
-
640
-        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
641
-        echo '' >> $turtl_nginx_site
642
-        echo '  # Logs' >> $turtl_nginx_site
643
-        echo '  access_log /dev/null;' >> $turtl_nginx_site
644
-        echo '  error_log /dev/null;' >> $turtl_nginx_site
645
-        echo '' >> $turtl_nginx_site
646
-        echo '  location / {' >> $turtl_nginx_site
647
-        function_check nginx_limits
648
-        nginx_limits $TURTL_DOMAIN_NAME '15m'
649
-        echo '  }' >> $turtl_nginx_site
650
-        echo '' >> $turtl_nginx_site
651
         echo '}' >> $turtl_nginx_site
567
         echo '}' >> $turtl_nginx_site
652
     else
568
     else
653
-        sed -i "s|api_url.*|api_url: 'http://${TURTL_API_ONION_HOSTNAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js
654
-        sed -i "s|site_url.*|site_url: 'http://${TURTL_ONION_HOSTNAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js
655
         echo -n '' > $turtl_nginx_site
569
         echo -n '' > $turtl_nginx_site
656
     fi
570
     fi
657
     echo 'server {' >> $turtl_nginx_site
571
     echo 'server {' >> $turtl_nginx_site
659
     echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site
573
     echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site
660
     echo '' >> $turtl_nginx_site
574
     echo '' >> $turtl_nginx_site
661
     function_check nginx_disable_sniffing
575
     function_check nginx_disable_sniffing
662
-    nginx_disable_sniffing $TURTL_DOMAIN_NAME
576
+    nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
663
     echo '' >> $turtl_nginx_site
577
     echo '' >> $turtl_nginx_site
664
     echo '  # Logs' >> $turtl_nginx_site
578
     echo '  # Logs' >> $turtl_nginx_site
665
     echo '  access_log /dev/null;' >> $turtl_nginx_site
579
     echo '  access_log /dev/null;' >> $turtl_nginx_site
667
     echo '' >> $turtl_nginx_site
581
     echo '' >> $turtl_nginx_site
668
     echo '  location / {' >> $turtl_nginx_site
582
     echo '  location / {' >> $turtl_nginx_site
669
     function_check nginx_limits
583
     function_check nginx_limits
670
-    nginx_limits $TURTL_DOMAIN_NAME '15m'
584
+    nginx_limits $TURTL_API_DOMAIN_NAME '15m'
671
     echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
585
     echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
672
     echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
586
     echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
673
     echo '    proxy_buffering   off;' >> $turtl_nginx_site
587
     echo '    proxy_buffering   off;' >> $turtl_nginx_site
674
     echo '  }' >> $turtl_nginx_site
588
     echo '  }' >> $turtl_nginx_site
675
-    echo '' >> $turtl_nginx_site
676
-    echo '}' >> $turtl_nginx_site
677
-    echo '' >> $turtl_nginx_site
678
-    echo 'server {' >> $turtl_nginx_site
679
-    echo "  listen 127.0.0.1:$TURTL_ONION_PORT default_server;" >> $turtl_nginx_site
680
-    echo "  server_name $TURTL_ONION_HOSTNAME;" >> $turtl_nginx_site
681
-    echo '' >> $turtl_nginx_site
682
-    echo '  index index.html;' >> $turtl_nginx_site
683
-    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site
684
-    echo '' >> $turtl_nginx_site
685
-    function_check nginx_disable_sniffing
686
-    nginx_disable_sniffing $TURTL_DOMAIN_NAME
687
-    echo '' >> $turtl_nginx_site
688
-    echo '  # Logs' >> $turtl_nginx_site
689
-    echo '  access_log /dev/null;' >> $turtl_nginx_site
690
-    echo '  error_log /dev/null;' >> $turtl_nginx_site
691
-    echo '' >> $turtl_nginx_site
692
-    echo '  location / {' >> $turtl_nginx_site
693
-    function_check nginx_limits
694
-    nginx_limits $TURTL_DOMAIN_NAME '15m'
695
-    echo '  }' >> $turtl_nginx_site
696
-    echo '' >> $turtl_nginx_site
697
     echo '}' >> $turtl_nginx_site
589
     echo '}' >> $turtl_nginx_site
698
 
590
 
699
-    ${PROJECT_NAME}-pass -u $MY_USERNAME -a turtl -p "$TURTL_ADMIN_PASSWORD"
700
-
701
     function_check add_ddns_domain
591
     function_check add_ddns_domain
702
-    add_ddns_domain $TURTL_DOMAIN_NAME
703
-
704
-    set_completion_param "turtl domain" "$TURTL_DOMAIN_NAME"
705
-
706
-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs
707
-    sed -i 's|GPLv3|GPL-3.0|g' package.json
708
-    sed -i "/license/a \"repository\": \"$TURTL_REPO\"," package.json
709
-    rm -rf node_modules npm-shrinkwrap.json
710
-    npm install uglify@0.1.5 --no-optional
711
-    npm install minimatch@3.0.2 --no-optional
712
-    npm install --no-optional
713
-
714
-    sed -i 's|{config,controllers,handlers,locales,library,models,turtl}|.|g' Makefile
715
-    sed -i 's|tests/{data,tests}|tests|g' Makefile
716
-
717
-    make clean
718
-    make
592
+    add_ddns_domain $TURTL_API_DOMAIN_NAME
719
 
593
 
720
-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs
594
+    set_completion_param "turtl api domain" "$TURTL_API_DOMAIN_NAME"
721
 
595
 
722
     function_check create_site_certificate
596
     function_check create_site_certificate
723
-    create_site_certificate $TURTL_DOMAIN_NAME 'yes'
597
+    create_site_certificate $TURTL_API_DOMAIN_NAME 'yes'
724
 
598
 
725
     function_check nginx_ensite
599
     function_check nginx_ensite
726
-    nginx_ensite $TURTL_DOMAIN_NAME
600
+    nginx_ensite $TURTL_API_DOMAIN_NAME
727
 
601
 
728
     systemctl restart nginx
602
     systemctl restart nginx
729
 }
603
 }
730
 
604
 
731
 function install_turtl {
605
 function install_turtl {
732
     install_turtl_api
606
     install_turtl_api
733
-    install_turtl_app
607
+    install_turtl_nginx
734
 
608
 
735
     APP_INSTALLED=1
609
     APP_INSTALLED=1
736
 }
610
 }