浏览代码

Standard domain name

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

+ 53
- 53
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_API_DOMAIN_NAME=
40
-TURTL_API_CODE=
41
-TURTL_API_ONION_PORT=8107
39
+TURTL_DOMAIN_NAME=
40
+TURTL_CODE=
41
+TURTL_ONION_PORT=8107
42
 TURTL_PORT=8181
42
 TURTL_PORT=8181
43
-TURTL_API_REPO="https://github.com/turtl/api.git"
44
-TURTL_API_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf'
43
+TURTL_REPO="https://github.com/turtl/api.git"
44
+TURTL_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf'
45
 TURTL_ADMIN_PASSWORD=
45
 TURTL_ADMIN_PASSWORD=
46
 TURTL_STORAGE_LIMIT_MB=100
46
 TURTL_STORAGE_LIMIT_MB=100
47
 TURTL_BASE_DIR=/etc/turtl
47
 TURTL_BASE_DIR=/etc/turtl
48
 
48
 
49
 turtl_variables=(ONION_ONLY
49
 turtl_variables=(ONION_ONLY
50
                  DEFAULT_DOMAIN_NAME
50
                  DEFAULT_DOMAIN_NAME
51
-                 TURTL_API_DOMAIN_NAME
52
-                 TURTL_API_CODE
51
+                 TURTL_DOMAIN_NAME
52
+                 TURTL_CODE
53
                  TURTL_STORAGE_LIMIT_MB
53
                  TURTL_STORAGE_LIMIT_MB
54
                  DDNS_PROVIDER
54
                  DDNS_PROVIDER
55
                  MY_EMAIL_ADDRESS
55
                  MY_EMAIL_ADDRESS
76
     fi
76
     fi
77
 
77
 
78
     if [[ $ONION_ONLY != "no" ]]; then
78
     if [[ $ONION_ONLY != "no" ]]; then
79
-        TURTL_API_DOMAIN_NAME='notes.local'
80
-        write_config_param "TURTL_API_DOMAIN_NAME" "$TURTL_API_DOMAIN_NAME"
79
+        TURTL_DOMAIN_NAME='notes.local'
80
+        write_config_param "TURTL_DOMAIN_NAME" "$TURTL_DOMAIN_NAME"
81
     else
81
     else
82
         function_check interactive_site_details
82
         function_check interactive_site_details
83
-        interactive_site_details "turtl" "TURTL_API_DOMAIN_NAME" "TURTL_API_CODE"
83
+        interactive_site_details "turtl" "TURTL_DOMAIN_NAME" "TURTL_CODE"
84
     fi
84
     fi
85
     APP_INSTALLED=1
85
     APP_INSTALLED=1
86
 }
86
 }
114
 }
114
 }
115
 
115
 
116
 function upgrade_turtl {
116
 function upgrade_turtl {
117
-    read_config_param "TURTL_API_DOMAIN_NAME"
117
+    read_config_param "TURTL_DOMAIN_NAME"
118
 
118
 
119
     function_check set_repo_commit
119
     function_check set_repo_commit
120
-    set_repo_commit $TURTL_BASE_DIR/api "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO
121
-    nginx_dissite $TURTL_API_DOMAIN_NAME
120
+    set_repo_commit $TURTL_BASE_DIR/api "turtl commit" "$TURTL_COMMIT" $TURTL_REPO
121
+    nginx_dissite $TURTL_DOMAIN_NAME
122
     chown -R turtl:turtl $TURTL_BASE_DIR
122
     chown -R turtl:turtl $TURTL_BASE_DIR
123
-    nginx_ensite $TURTL_API_DOMAIN_NAME
123
+    nginx_ensite $TURTL_DOMAIN_NAME
124
 }
124
 }
125
 
125
 
126
 function backup_local_turtl {
126
 function backup_local_turtl {
127
-    read_config_param "TURTL_API_DOMAIN_NAME"
127
+    read_config_param "TURTL_DOMAIN_NAME"
128
     source_directory=$TURTL_BASE_DIR
128
     source_directory=$TURTL_BASE_DIR
129
     if [ -d $source_directory ]; then
129
     if [ -d $source_directory ]; then
130
         dest_directory=turtl
130
         dest_directory=turtl
131
         function_check suspend_site
131
         function_check suspend_site
132
-        suspend_site ${TURTL_API_DOMAIN_NAME}
132
+        suspend_site ${TURTL_DOMAIN_NAME}
133
 
133
 
134
         function_check backup_directory_to_usb
134
         function_check backup_directory_to_usb
135
         backup_directory_to_usb $source_directory $dest_directory
135
         backup_directory_to_usb $source_directory $dest_directory
141
     if [ -d $source_directory ]; then
141
     if [ -d $source_directory ]; then
142
         dest_directory=rethinkdb
142
         dest_directory=rethinkdb
143
         function_check suspend_site
143
         function_check suspend_site
144
-        suspend_site ${TURTL_API_DOMAIN_NAME}
144
+        suspend_site ${TURTL_DOMAIN_NAME}
145
 
145
 
146
         function_check backup_directory_to_usb
146
         function_check backup_directory_to_usb
147
         backup_directory_to_usb $source_directory $dest_directory
147
         backup_directory_to_usb $source_directory $dest_directory
152
 }
152
 }
153
 
153
 
154
 function restore_local_turtl {
154
 function restore_local_turtl {
155
-    read_config_param "TURTL_API_DOMAIN_NAME"
156
-    if [ $TURTL_API_DOMAIN_NAME ]; then
155
+    read_config_param "TURTL_DOMAIN_NAME"
156
+    if [ $TURTL_DOMAIN_NAME ]; then
157
         temp_restore_dir=/root/tempturtl
157
         temp_restore_dir=/root/tempturtl
158
         restore_directory_from_usb $temp_restore_dir turtl
158
         restore_directory_from_usb $temp_restore_dir turtl
159
         if [ -d $TURTL_BASE_DIR ]; then
159
         if [ -d $TURTL_BASE_DIR ]; then
198
 }
198
 }
199
 
199
 
200
 function backup_remote_turtl {
200
 function backup_remote_turtl {
201
-    read_config_param "TURTL_API_DOMAIN_NAME"
202
-    if [ $TURTL_API_DOMAIN_NAME ]; then
201
+    read_config_param "TURTL_DOMAIN_NAME"
202
+    if [ $TURTL_DOMAIN_NAME ]; then
203
         temp_backup_dir=$TURTL_BASE_DIR
203
         temp_backup_dir=$TURTL_BASE_DIR
204
         if [ -d $temp_backup_dir ]; then
204
         if [ -d $temp_backup_dir ]; then
205
             echo $"Backing up turtl"
205
             echo $"Backing up turtl"
220
 }
220
 }
221
 
221
 
222
 function restore_remote_turtl {
222
 function restore_remote_turtl {
223
-    read_config_param "TURTL_API_DOMAIN_NAME"
224
-    if [ $TURTL_API_DOMAIN_NAME ]; then
223
+    read_config_param "TURTL_DOMAIN_NAME"
224
+    if [ $TURTL_DOMAIN_NAME ]; then
225
         temp_restore_dir=/root/tempturtl
225
         temp_restore_dir=/root/tempturtl
226
         mkdir $temp_restore_dir
226
         mkdir $temp_restore_dir
227
         function_check restore_directory_from_friend
227
         function_check restore_directory_from_friend
276
     remove_completion_param install_turtl
276
     remove_completion_param install_turtl
277
     sed -i '/turtl/d' $COMPLETION_FILE
277
     sed -i '/turtl/d' $COMPLETION_FILE
278
     deluser turtl
278
     deluser turtl
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
279
+    nginx_dissite $TURTL_DOMAIN_NAME
280
+    if [ -f /etc/nginx/sites-available/$TURTL_DOMAIN_NAME ]; then
281
+        rm /etc/nginx/sites-available/$TURTL_DOMAIN_NAME
282
     fi
282
     fi
283
-    remove_certs $TURTL_API_DOMAIN_NAME
283
+    remove_certs $TURTL_DOMAIN_NAME
284
     function_check remove_onion_service
284
     function_check remove_onion_service
285
-    remove_onion_service turtlapi ${TURTL_API_ONION_PORT}
285
+    remove_onion_service turtlapi ${TURTL_ONION_PORT}
286
     function_check remove_ddns_domain
286
     function_check remove_ddns_domain
287
-    remove_ddns_domain $TURTL_API_DOMAIN_NAME
287
+    remove_ddns_domain $TURTL_DOMAIN_NAME
288
     rm -rf /etc/rethinkdb
288
     rm -rf /etc/rethinkdb
289
     rm -rf /var/lib/rethinkdb
289
     rm -rf /var/lib/rethinkdb
290
     rm -rf $TURTL_BASE_DIR
290
     rm -rf $TURTL_BASE_DIR
297
     BINDPORT=${BINDPORT:-8181}
297
     BINDPORT=${BINDPORT:-8181}
298
     PROD_ERR_HANDLING=${PROD_ERR_HANDLING:-t}
298
     PROD_ERR_HANDLING=${PROD_ERR_HANDLING:-t}
299
     if [[ $ONION_ONLY == 'no' ]]; then
299
     if [[ $ONION_ONLY == 'no' ]]; then
300
-        FQDN=${FQDN:-$TURTL_API_DOMAIN_NAME}
301
-        SITE_URL=${SITE_URL:-https://$TURTL_API_DOMAIN_NAME}
300
+        FQDN=${FQDN:-$TURTL_DOMAIN_NAME}
301
+        SITE_URL=${SITE_URL:-https://$TURTL_DOMAIN_NAME}
302
     else
302
     else
303
-        FQDN=${FQDN:-$TURTL_API_ONION_HOSTNAME}
304
-        SITE_URL=${SITE_URL:-http://$TURTL_API_ONION_HOSTNAME}
303
+        FQDN=${FQDN:-$TURTL_ONION_HOSTNAME}
304
+        SITE_URL=${SITE_URL:-http://$TURTL_ONION_HOSTNAME}
305
     fi
305
     fi
306
     ADMIN_EMAIL=${ADMIN_EMAIL:-$MY_USERNAME@$DEFAULT_DOMAIN_NAME}
306
     ADMIN_EMAIL=${ADMIN_EMAIL:-$MY_USERNAME@$DEFAULT_DOMAIN_NAME}
307
     EMAIL_FROM=${EMAIL_FROM:-noreply@$DEFAULT_DOMAIN_NAME}
307
     EMAIL_FROM=${EMAIL_FROM:-noreply@$DEFAULT_DOMAIN_NAME}
311
     DEFAULT_STORAGE_LIMIT=${DEFAULT_STORAGE_LIMIT:-100}
311
     DEFAULT_STORAGE_LIMIT=${DEFAULT_STORAGE_LIMIT:-100}
312
     STORAGE_INVITE_CREDIT=${STORAGE_INVITE_CREDIT:-25}
312
     STORAGE_INVITE_CREDIT=${STORAGE_INVITE_CREDIT:-25}
313
     if [[ $ONION_ONLY == 'no' ]]; then
313
     if [[ $ONION_ONLY == 'no' ]]; then
314
-        LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-https://$TURTL_API_DOMAIN_NAME}
314
+        LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-https://$TURTL_DOMAIN_NAME}
315
     else
315
     else
316
-        LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-http://$TURTL_API_ONION_HOSTNAME}
316
+        LOCAL_UPLOAD_URL=${LOCAL_UPLOAD_URL:-http://$TURTL_ONION_HOSTNAME}
317
     fi
317
     fi
318
     LOCAL_UPLOAD_PATH=${LOCAL_UPLOAD_PATH:-"$TURTL_BASE_DIR/data"}
318
     LOCAL_UPLOAD_PATH=${LOCAL_UPLOAD_PATH:-"$TURTL_BASE_DIR/data"}
319
     AWS_S3_TOKEN=${AWS_S3_TOKEN:-(:token ''
319
     AWS_S3_TOKEN=${AWS_S3_TOKEN:-(:token ''
501
 
501
 
502
     # install turtl API
502
     # install turtl API
503
     cd $TURTL_BASE_DIR/
503
     cd $TURTL_BASE_DIR/
504
-    git clone $TURTL_API_REPO $TURTL_BASE_DIR/api
504
+    git clone $TURTL_REPO $TURTL_BASE_DIR/api
505
     cd $TURTL_BASE_DIR/api
505
     cd $TURTL_BASE_DIR/api
506
-    git checkout $TURTL_API_COMMIT -b $TURTL_API_COMMIT
507
-    set_completion_param "turtl api commit" "$TURTL_API_COMMIT"
506
+    git checkout $TURTL_COMMIT -b $TURTL_COMMIT
507
+    set_completion_param "turtl commit" "$TURTL_COMMIT"
508
     cd $TURTL_BASE_DIR/quicklisp/local-projects
508
     cd $TURTL_BASE_DIR/quicklisp/local-projects
509
     git clone git://github.com/orthecreedence/cl-hash-util
509
     git clone git://github.com/orthecreedence/cl-hash-util
510
     if [[ "$check_architecture" != *"arm"* ]]; then
510
     if [[ "$check_architecture" != *"arm"* ]]; then
538
     echo "(pushnew \"./\" asdf:*central-registry* :test #'equal)" >> $TURTL_BASE_DIR/api/launch.lisp
538
     echo "(pushnew \"./\" asdf:*central-registry* :test #'equal)" >> $TURTL_BASE_DIR/api/launch.lisp
539
     echo '(load "start")' >> $TURTL_BASE_DIR/api/launch.lisp
539
     echo '(load "start")' >> $TURTL_BASE_DIR/api/launch.lisp
540
 
540
 
541
-    TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT})
541
+    TURTL_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_ONION_PORT})
542
 
542
 
543
     turtl_setup
543
     turtl_setup
544
 }
544
 }
545
 
545
 
546
 function install_turtl_nginx {
546
 function install_turtl_nginx {
547
-    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_API_DOMAIN_NAME
547
+    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_DOMAIN_NAME
548
     if [[ $ONION_ONLY == "no" ]]; then
548
     if [[ $ONION_ONLY == "no" ]]; then
549
         function_check nginx_http_redirect
549
         function_check nginx_http_redirect
550
-        nginx_http_redirect $TURTL_API_DOMAIN_NAME
550
+        nginx_http_redirect $TURTL_DOMAIN_NAME
551
         echo 'server {' >> $turtl_nginx_site
551
         echo 'server {' >> $turtl_nginx_site
552
         echo '  listen 443 ssl;' >> $turtl_nginx_site
552
         echo '  listen 443 ssl;' >> $turtl_nginx_site
553
         echo '  listen [::]:443 ssl;' >> $turtl_nginx_site
553
         echo '  listen [::]:443 ssl;' >> $turtl_nginx_site
554
-        echo "  server_name ${TURTL_API_DOMAIN_NAME};" >> $turtl_nginx_site
554
+        echo "  server_name ${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site
555
         echo '' >> $turtl_nginx_site
555
         echo '' >> $turtl_nginx_site
556
         echo '  # Security' >> $turtl_nginx_site
556
         echo '  # Security' >> $turtl_nginx_site
557
         function_check nginx_ssl
557
         function_check nginx_ssl
558
-        nginx_ssl $TURTL_API_DOMAIN_NAME
558
+        nginx_ssl $TURTL_DOMAIN_NAME
559
 
559
 
560
         function_check nginx_disable_sniffing
560
         function_check nginx_disable_sniffing
561
-        nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
561
+        nginx_disable_sniffing $TURTL_DOMAIN_NAME
562
 
562
 
563
         echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
563
         echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
564
         echo '' >> $turtl_nginx_site
564
         echo '' >> $turtl_nginx_site
568
         echo '' >> $turtl_nginx_site
568
         echo '' >> $turtl_nginx_site
569
         echo '  location / {' >> $turtl_nginx_site
569
         echo '  location / {' >> $turtl_nginx_site
570
         function_check nginx_limits
570
         function_check nginx_limits
571
-        nginx_limits $TURTL_API_DOMAIN_NAME '15m'
571
+        nginx_limits $TURTL_DOMAIN_NAME '15m'
572
         echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
572
         echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
573
         echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
573
         echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
574
         echo '    proxy_buffering   off;' >> $turtl_nginx_site
574
         echo '    proxy_buffering   off;' >> $turtl_nginx_site
578
         echo -n '' > $turtl_nginx_site
578
         echo -n '' > $turtl_nginx_site
579
     fi
579
     fi
580
     echo 'server {' >> $turtl_nginx_site
580
     echo 'server {' >> $turtl_nginx_site
581
-    echo "  listen 127.0.0.1:${TURTL_API_ONION_PORT};" >> $turtl_nginx_site
582
-    echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site
581
+    echo "  listen 127.0.0.1:${TURTL_ONION_PORT};" >> $turtl_nginx_site
582
+    echo "  server_name ${TURTL_ONION_HOSTNAME};" >> $turtl_nginx_site
583
     echo '' >> $turtl_nginx_site
583
     echo '' >> $turtl_nginx_site
584
     function_check nginx_disable_sniffing
584
     function_check nginx_disable_sniffing
585
-    nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
585
+    nginx_disable_sniffing $TURTL_DOMAIN_NAME
586
     echo '' >> $turtl_nginx_site
586
     echo '' >> $turtl_nginx_site
587
     echo '  # Logs' >> $turtl_nginx_site
587
     echo '  # Logs' >> $turtl_nginx_site
588
     echo '  access_log /dev/null;' >> $turtl_nginx_site
588
     echo '  access_log /dev/null;' >> $turtl_nginx_site
590
     echo '' >> $turtl_nginx_site
590
     echo '' >> $turtl_nginx_site
591
     echo '  location / {' >> $turtl_nginx_site
591
     echo '  location / {' >> $turtl_nginx_site
592
     function_check nginx_limits
592
     function_check nginx_limits
593
-    nginx_limits $TURTL_API_DOMAIN_NAME '15m'
593
+    nginx_limits $TURTL_DOMAIN_NAME '15m'
594
     echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
594
     echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
595
     echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
595
     echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site
596
     echo '    proxy_buffering   off;' >> $turtl_nginx_site
596
     echo '    proxy_buffering   off;' >> $turtl_nginx_site
598
     echo '}' >> $turtl_nginx_site
598
     echo '}' >> $turtl_nginx_site
599
 
599
 
600
     function_check add_ddns_domain
600
     function_check add_ddns_domain
601
-    add_ddns_domain $TURTL_API_DOMAIN_NAME
601
+    add_ddns_domain $TURTL_DOMAIN_NAME
602
 
602
 
603
-    set_completion_param "turtl api domain" "$TURTL_API_DOMAIN_NAME"
603
+    set_completion_param "turtl domain" "$TURTL_DOMAIN_NAME"
604
 
604
 
605
     function_check create_site_certificate
605
     function_check create_site_certificate
606
-    create_site_certificate $TURTL_API_DOMAIN_NAME 'yes'
606
+    create_site_certificate $TURTL_DOMAIN_NAME 'yes'
607
 
607
 
608
     function_check nginx_ensite
608
     function_check nginx_ensite
609
-    nginx_ensite $TURTL_API_DOMAIN_NAME
609
+    nginx_ensite $TURTL_DOMAIN_NAME
610
 
610
 
611
     systemctl restart nginx
611
     systemctl restart nginx
612
 }
612
 }