|
@@ -36,20 +36,20 @@ VARIANTS="full full-vim writer"
|
36
|
36
|
IN_DEFAULT_INSTALL=0
|
37
|
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
|
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
|
45
|
TURTL_ADMIN_PASSWORD=
|
46
|
46
|
TURTL_STORAGE_LIMIT_MB=100
|
47
|
47
|
TURTL_BASE_DIR=/etc/turtl
|
48
|
48
|
|
49
|
49
|
turtl_variables=(ONION_ONLY
|
50
|
50
|
DEFAULT_DOMAIN_NAME
|
51
|
|
- TURTL_API_DOMAIN_NAME
|
52
|
|
- TURTL_API_CODE
|
|
51
|
+ TURTL_DOMAIN_NAME
|
|
52
|
+ TURTL_CODE
|
53
|
53
|
TURTL_STORAGE_LIMIT_MB
|
54
|
54
|
DDNS_PROVIDER
|
55
|
55
|
MY_EMAIL_ADDRESS
|
|
@@ -76,11 +76,11 @@ function install_interactive_turtl {
|
76
|
76
|
fi
|
77
|
77
|
|
78
|
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
|
81
|
else
|
82
|
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
|
84
|
fi
|
85
|
85
|
APP_INSTALLED=1
|
86
|
86
|
}
|
|
@@ -114,22 +114,22 @@ function reconfigure_turtl {
|
114
|
114
|
}
|
115
|
115
|
|
116
|
116
|
function upgrade_turtl {
|
117
|
|
- read_config_param "TURTL_API_DOMAIN_NAME"
|
|
117
|
+ read_config_param "TURTL_DOMAIN_NAME"
|
118
|
118
|
|
119
|
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
|
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
|
126
|
function backup_local_turtl {
|
127
|
|
- read_config_param "TURTL_API_DOMAIN_NAME"
|
|
127
|
+ read_config_param "TURTL_DOMAIN_NAME"
|
128
|
128
|
source_directory=$TURTL_BASE_DIR
|
129
|
129
|
if [ -d $source_directory ]; then
|
130
|
130
|
dest_directory=turtl
|
131
|
131
|
function_check suspend_site
|
132
|
|
- suspend_site ${TURTL_API_DOMAIN_NAME}
|
|
132
|
+ suspend_site ${TURTL_DOMAIN_NAME}
|
133
|
133
|
|
134
|
134
|
function_check backup_directory_to_usb
|
135
|
135
|
backup_directory_to_usb $source_directory $dest_directory
|
|
@@ -141,7 +141,7 @@ function backup_local_turtl {
|
141
|
141
|
if [ -d $source_directory ]; then
|
142
|
142
|
dest_directory=rethinkdb
|
143
|
143
|
function_check suspend_site
|
144
|
|
- suspend_site ${TURTL_API_DOMAIN_NAME}
|
|
144
|
+ suspend_site ${TURTL_DOMAIN_NAME}
|
145
|
145
|
|
146
|
146
|
function_check backup_directory_to_usb
|
147
|
147
|
backup_directory_to_usb $source_directory $dest_directory
|
|
@@ -152,8 +152,8 @@ function backup_local_turtl {
|
152
|
152
|
}
|
153
|
153
|
|
154
|
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
|
157
|
temp_restore_dir=/root/tempturtl
|
158
|
158
|
restore_directory_from_usb $temp_restore_dir turtl
|
159
|
159
|
if [ -d $TURTL_BASE_DIR ]; then
|
|
@@ -198,8 +198,8 @@ function restore_local_turtl {
|
198
|
198
|
}
|
199
|
199
|
|
200
|
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
|
203
|
temp_backup_dir=$TURTL_BASE_DIR
|
204
|
204
|
if [ -d $temp_backup_dir ]; then
|
205
|
205
|
echo $"Backing up turtl"
|
|
@@ -220,8 +220,8 @@ function backup_remote_turtl {
|
220
|
220
|
}
|
221
|
221
|
|
222
|
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
|
225
|
temp_restore_dir=/root/tempturtl
|
226
|
226
|
mkdir $temp_restore_dir
|
227
|
227
|
function_check restore_directory_from_friend
|
|
@@ -276,15 +276,15 @@ function remove_turtl {
|
276
|
276
|
remove_completion_param install_turtl
|
277
|
277
|
sed -i '/turtl/d' $COMPLETION_FILE
|
278
|
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
|
282
|
fi
|
283
|
|
- remove_certs $TURTL_API_DOMAIN_NAME
|
|
283
|
+ remove_certs $TURTL_DOMAIN_NAME
|
284
|
284
|
function_check remove_onion_service
|
285
|
|
- remove_onion_service turtlapi ${TURTL_API_ONION_PORT}
|
|
285
|
+ remove_onion_service turtlapi ${TURTL_ONION_PORT}
|
286
|
286
|
function_check remove_ddns_domain
|
287
|
|
- remove_ddns_domain $TURTL_API_DOMAIN_NAME
|
|
287
|
+ remove_ddns_domain $TURTL_DOMAIN_NAME
|
288
|
288
|
rm -rf /etc/rethinkdb
|
289
|
289
|
rm -rf /var/lib/rethinkdb
|
290
|
290
|
rm -rf $TURTL_BASE_DIR
|
|
@@ -297,11 +297,11 @@ function turtl_setup {
|
297
|
297
|
BINDPORT=${BINDPORT:-8181}
|
298
|
298
|
PROD_ERR_HANDLING=${PROD_ERR_HANDLING:-t}
|
299
|
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
|
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
|
305
|
fi
|
306
|
306
|
ADMIN_EMAIL=${ADMIN_EMAIL:-$MY_USERNAME@$DEFAULT_DOMAIN_NAME}
|
307
|
307
|
EMAIL_FROM=${EMAIL_FROM:-noreply@$DEFAULT_DOMAIN_NAME}
|
|
@@ -311,9 +311,9 @@ function turtl_setup {
|
311
|
311
|
DEFAULT_STORAGE_LIMIT=${DEFAULT_STORAGE_LIMIT:-100}
|
312
|
312
|
STORAGE_INVITE_CREDIT=${STORAGE_INVITE_CREDIT:-25}
|
313
|
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
|
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
|
317
|
fi
|
318
|
318
|
LOCAL_UPLOAD_PATH=${LOCAL_UPLOAD_PATH:-"$TURTL_BASE_DIR/data"}
|
319
|
319
|
AWS_S3_TOKEN=${AWS_S3_TOKEN:-(:token ''
|
|
@@ -501,10 +501,10 @@ __ENDCONFIG__
|
501
|
501
|
|
502
|
502
|
# install turtl API
|
503
|
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
|
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
|
508
|
cd $TURTL_BASE_DIR/quicklisp/local-projects
|
509
|
509
|
git clone git://github.com/orthecreedence/cl-hash-util
|
510
|
510
|
if [[ "$check_architecture" != *"arm"* ]]; then
|
|
@@ -538,27 +538,27 @@ __ENDCONFIG__
|
538
|
538
|
echo "(pushnew \"./\" asdf:*central-registry* :test #'equal)" >> $TURTL_BASE_DIR/api/launch.lisp
|
539
|
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
|
543
|
turtl_setup
|
544
|
544
|
}
|
545
|
545
|
|
546
|
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
|
548
|
if [[ $ONION_ONLY == "no" ]]; then
|
549
|
549
|
function_check nginx_http_redirect
|
550
|
|
- nginx_http_redirect $TURTL_API_DOMAIN_NAME
|
|
550
|
+ nginx_http_redirect $TURTL_DOMAIN_NAME
|
551
|
551
|
echo 'server {' >> $turtl_nginx_site
|
552
|
552
|
echo ' listen 443 ssl;' >> $turtl_nginx_site
|
553
|
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
|
555
|
echo '' >> $turtl_nginx_site
|
556
|
556
|
echo ' # Security' >> $turtl_nginx_site
|
557
|
557
|
function_check nginx_ssl
|
558
|
|
- nginx_ssl $TURTL_API_DOMAIN_NAME
|
|
558
|
+ nginx_ssl $TURTL_DOMAIN_NAME
|
559
|
559
|
|
560
|
560
|
function_check nginx_disable_sniffing
|
561
|
|
- nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
|
|
561
|
+ nginx_disable_sniffing $TURTL_DOMAIN_NAME
|
562
|
562
|
|
563
|
563
|
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site
|
564
|
564
|
echo '' >> $turtl_nginx_site
|
|
@@ -568,7 +568,7 @@ function install_turtl_nginx {
|
568
|
568
|
echo '' >> $turtl_nginx_site
|
569
|
569
|
echo ' location / {' >> $turtl_nginx_site
|
570
|
570
|
function_check nginx_limits
|
571
|
|
- nginx_limits $TURTL_API_DOMAIN_NAME '15m'
|
|
571
|
+ nginx_limits $TURTL_DOMAIN_NAME '15m'
|
572
|
572
|
echo " proxy_pass http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
|
573
|
573
|
echo ' proxy_set_header Host $host;' >> $turtl_nginx_site
|
574
|
574
|
echo ' proxy_buffering off;' >> $turtl_nginx_site
|
|
@@ -578,11 +578,11 @@ function install_turtl_nginx {
|
578
|
578
|
echo -n '' > $turtl_nginx_site
|
579
|
579
|
fi
|
580
|
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
|
583
|
echo '' >> $turtl_nginx_site
|
584
|
584
|
function_check nginx_disable_sniffing
|
585
|
|
- nginx_disable_sniffing $TURTL_API_DOMAIN_NAME
|
|
585
|
+ nginx_disable_sniffing $TURTL_DOMAIN_NAME
|
586
|
586
|
echo '' >> $turtl_nginx_site
|
587
|
587
|
echo ' # Logs' >> $turtl_nginx_site
|
588
|
588
|
echo ' access_log /dev/null;' >> $turtl_nginx_site
|
|
@@ -590,7 +590,7 @@ function install_turtl_nginx {
|
590
|
590
|
echo '' >> $turtl_nginx_site
|
591
|
591
|
echo ' location / {' >> $turtl_nginx_site
|
592
|
592
|
function_check nginx_limits
|
593
|
|
- nginx_limits $TURTL_API_DOMAIN_NAME '15m'
|
|
593
|
+ nginx_limits $TURTL_DOMAIN_NAME '15m'
|
594
|
594
|
echo " proxy_pass http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site
|
595
|
595
|
echo ' proxy_set_header Host $host;' >> $turtl_nginx_site
|
596
|
596
|
echo ' proxy_buffering off;' >> $turtl_nginx_site
|
|
@@ -598,15 +598,15 @@ function install_turtl_nginx {
|
598
|
598
|
echo '}' >> $turtl_nginx_site
|
599
|
599
|
|
600
|
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
|
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
|
608
|
function_check nginx_ensite
|
609
|
|
- nginx_ensite $TURTL_API_DOMAIN_NAME
|
|
609
|
+ nginx_ensite $TURTL_DOMAIN_NAME
|
610
|
610
|
|
611
|
611
|
systemctl restart nginx
|
612
|
612
|
}
|