| 
				
			 | 
			
			
				@@ -39,9 +39,12 @@ SHOW_ON_ABOUT=1 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				39
			 | 
			
			
				 TURTL_DOMAIN_NAME= 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				40
			 | 
			
			
				 TURTL_CODE= 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				41
			 | 
			
			
				 TURTL_ONION_PORT=8107 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+TURTL_API_ONION_PORT=8108 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				43
			 | 
			
			
				 TURTL_PORT=8181 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-TURTL_REPO="https://github.com/turtl/api.git" 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-TURTL_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+TURTL_API_REPO="https://github.com/turtl/api.git" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+TURTL_API_COMMIT='53e00a5583f52de8f86ef380fe11c176b5738dcf' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+TURTL_REPO="https://github.com/turtl/js.git" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+TURTL_COMMIT='61923ffb47d95d172f80d14c76aa032a4d5f5d6d' 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				48
			 | 
			
			
				 TURTL_ADMIN_PASSWORD= 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				49
			 | 
			
			
				 TURTL_STORAGE_LIMIT_MB=100 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				50
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -99,7 +102,7 @@ function configure_interactive_turtl { 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				102
			 | 
			
			
				             STORAGE=$(<$data) 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				103
			 | 
			
			
				             if [ ${#STORAGE} -gt 0 ]; then 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				104
			 | 
			
			
				                 TURTL_STORAGE_LIMIT_MB=$STORAGE 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-                sed -i "s|defparameter *default-storage-limit*.*|defparameter *default-storage-limit* $TURTL_STORAGE_LIMIT_MB|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+                sed -i "s|defparameter *default-storage-limit*.*|defparameter *default-storage-limit* $TURTL_STORAGE_LIMIT_MB|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				106
			 | 
			
			
				                 systemctl restart turtl 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				107
			 | 
			
			
				                 dialog --title $"Change storage limit" \ 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				108
			 | 
			
			
				                        --msgbox $"Storage limit changed to ${TURTL_STORAGE_LIMIT_MB}M" 6 50 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -122,6 +125,7 @@ function upgrade_turtl { 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				125
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				123
			 | 
			
				126
			 | 
			
			
				     function_check set_repo_commit 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				127
			 | 
			
			
				     set_repo_commit /var/www/$TURTL_DOMAIN_NAME/htdocs "turtl commit" "$TURTL_COMMIT" $TURTL_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				+    set_repo_commit /var/www/$TURTL_DOMAIN_NAME/htdocs "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				129
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				130
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				127
			 | 
			
				131
			 | 
			
			
				 function backup_local_turtl { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -228,6 +232,7 @@ function remove_turtl { 
			 | 
		
	
		
			
			| 
				228
			 | 
			
				232
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				229
			 | 
			
				233
			 | 
			
			
				     function_check remove_onion_service 
			 | 
		
	
		
			
			| 
				230
			 | 
			
				234
			 | 
			
			
				     remove_onion_service turtl ${TURTL_ONION_PORT} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				235
			 | 
			
			
				+    remove_onion_service turtlapi ${TURTL_API_ONION_PORT} 
			 | 
		
	
		
			
			| 
				231
			 | 
			
				236
			 | 
			
			
				     remove_app turtl 
			 | 
		
	
		
			
			| 
				232
			 | 
			
				237
			 | 
			
			
				     remove_completion_param install_turtl 
			 | 
		
	
		
			
			| 
				233
			 | 
			
				238
			 | 
			
			
				     sed -i '/turtl/d' $COMPLETION_FILE 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -295,9 +300,12 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				295
			 | 
			
				300
			 | 
			
			
				         mkdir -p $INSTALL_DIR 
			 | 
		
	
		
			
			| 
				296
			 | 
			
				301
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				297
			 | 
			
				302
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				298
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /var/www/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				299
			 | 
			
				
			 | 
			
			
				-        mkdir /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+    if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+        rm -rf /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				300
			 | 
			
				305
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+    mkdir /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				+    # get the app 
			 | 
		
	
		
			
			| 
				301
			 | 
			
				309
			 | 
			
			
				     if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs ]; then 
			 | 
		
	
		
			
			| 
				302
			 | 
			
				310
			 | 
			
			
				         function_check git_clone 
			 | 
		
	
		
			
			| 
				303
			 | 
			
				311
			 | 
			
			
				         git_clone $TURTL_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -307,30 +315,56 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				307
			 | 
			
				315
			 | 
			
			
				         fi 
			 | 
		
	
		
			
			| 
				308
			 | 
			
				316
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				309
			 | 
			
				317
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				310
			 | 
			
				
			 | 
			
			
				-    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.default.lisp ]; then 
			 | 
		
	
		
			
			| 
				311
			 | 
			
				
			 | 
			
			
				-        echo $'No default turtl config found' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				318
			 | 
			
			
				+    # get the api 
			 | 
		
	
		
			
			| 
				
			 | 
			
				319
			 | 
			
			
				+    if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/api ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				320
			 | 
			
			
				+        git_clone $TURTL_API_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs/api 
			 | 
		
	
		
			
			| 
				
			 | 
			
				321
			 | 
			
			
				+        if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/api ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				322
			 | 
			
			
				+            echo $'Unable to clone turtl api repo' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				323
			 | 
			
			
				+            exit 473843 
			 | 
		
	
		
			
			| 
				
			 | 
			
				324
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				325
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				326
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				327
			 | 
			
			
				+    # check that default config files exist 
			 | 
		
	
		
			
			| 
				
			 | 
			
				328
			 | 
			
			
				+    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.default.lisp ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				329
			 | 
			
			
				+        echo $'No default turtl api config found' 
			 | 
		
	
		
			
			| 
				312
			 | 
			
				330
			 | 
			
			
				         exit 825328 
			 | 
		
	
		
			
			| 
				313
			 | 
			
				331
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				332
			 | 
			
			
				+    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.default ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				333
			 | 
			
			
				+        echo $'No default turtl config found' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				334
			 | 
			
			
				+        exit 783524 
			 | 
		
	
		
			
			| 
				
			 | 
			
				335
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				336
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				337
			 | 
			
			
				+    # directory where uploads are stored 
			 | 
		
	
		
			
			| 
				314
			 | 
			
				338
			 | 
			
			
				     if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/data ]; then 
			 | 
		
	
		
			
			| 
				315
			 | 
			
				339
			 | 
			
			
				         mkdir -p /var/www/$TURTL_DOMAIN_NAME/htdocs/data 
			 | 
		
	
		
			
			| 
				316
			 | 
			
				340
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				317
			 | 
			
				
			 | 
			
			
				-    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.default.lisp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				318
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *admin-email* \".*|defvar *admin-email* \"$MY_EMAIL_ADDRESS\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				319
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *email-from* \".*|defvar *email-from* \"noreply@$DEFAULT_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *site-url* \".*|defvar *site-url* \"https://$TURTL_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *analytics* '(:enabled.*|defvar *analytics* '(:enabled f|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				
			 | 
			
			
				-    sed -i 's|http://turtl.dev:8181|https://$TURTL_DOMAIN_NAME|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *local-upload*.*|defvar *local-upload* \"/var/www/$TURTL_DOMAIN_NAME/htdocs/data\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *local-upload-url*.*|defvar *local-upload-url* \"https://$TURTL_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				325
			 | 
			
				
			 | 
			
			
				-    sed -i 's|defparameter *storage-invite-credit*.*|defparameter *storage-invite-credit* 0|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				326
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defparameter *default-storage-limit*.*|defparameter *default-storage-limit* $TURTL_STORAGE_LIMIT_MB|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				341
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				342
			 | 
			
			
				+    # create config files 
			 | 
		
	
		
			
			| 
				
			 | 
			
				343
			 | 
			
			
				+    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.default.lisp /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				345
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				346
			 | 
			
			
				+    # app config file settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				347
			 | 
			
			
				+    sed -i "s|api_url.*|api_url: 'https://api.${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				348
			 | 
			
			
				+    sed -i "s|site_url.*|api_url: 'https://${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				349
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				350
			 | 
			
			
				+    # api config file settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				351
			 | 
			
			
				+    sed -i "s|defvar *admin-email* \".*|defvar *admin-email* \"$MY_EMAIL_ADDRESS\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				352
			 | 
			
			
				+    sed -i "s|defvar *email-from* \".*|defvar *email-from* \"noreply@$DEFAULT_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				353
			 | 
			
			
				+    sed -i "s|defvar *site-url* \".*|defvar *site-url* \"https://$TURTL_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				354
			 | 
			
			
				+    sed -i "s|defvar *analytics* '(:enabled.*|defvar *analytics* '(:enabled f|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				355
			 | 
			
			
				+    sed -i 's|http://turtl.dev:8181|https://$TURTL_DOMAIN_NAME|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				356
			 | 
			
			
				+    sed -i "s|defvar *local-upload*.*|defvar *local-upload* \"/var/www/$TURTL_DOMAIN_NAME/htdocs/data\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				357
			 | 
			
			
				+    sed -i "s|defvar *local-upload-url*.*|defvar *local-upload-url* \"https://api.${TURTL_DOMAIN_NAME}\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				358
			 | 
			
			
				+    sed -i 's|defparameter *storage-invite-credit*.*|defparameter *storage-invite-credit* 0|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				359
			 | 
			
			
				+    sed -i "s|defparameter *default-storage-limit*.*|defparameter *default-storage-limit* $TURTL_STORAGE_LIMIT_MB|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				327
			 | 
			
				360
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				328
			 | 
			
				361
			 | 
			
			
				     cd /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				329
			 | 
			
				362
			 | 
			
			
				     git checkout $TURTL_COMMIT -b $TURTL_COMMIT 
			 | 
		
	
		
			
			| 
				330
			 | 
			
				363
			 | 
			
			
				     set_completion_param "turtl commit" "$TURTL_COMMIT" 
			 | 
		
	
		
			
			| 
				331
			 | 
			
				364
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				332
			 | 
			
				
			 | 
			
			
				-    chmod a+w /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				333
			 | 
			
				
			 | 
			
			
				-    chown www-data:www-data /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				365
			 | 
			
			
				+    cd /var/www/$TURTL_DOMAIN_NAME/htdocs/api 
			 | 
		
	
		
			
			| 
				
			 | 
			
				366
			 | 
			
			
				+    git checkout $TURTL_API_COMMIT -b $TURTL_API_COMMIT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				367
			 | 
			
			
				+    set_completion_param "turtl api commit" "$TURTL_API_COMMIT" 
			 | 
		
	
		
			
			| 
				334
			 | 
			
				368
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				335
			 | 
			
				369
			 | 
			
			
				     install_libuv 
			 | 
		
	
		
			
			| 
				336
			 | 
			
				370
			 | 
			
			
				     install_rethinkdb 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -344,6 +378,7 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				344
			 | 
			
				378
			 | 
			
			
				     add_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				345
			 | 
			
				379
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				346
			 | 
			
				380
			 | 
			
			
				     adduser --system --home=/var/www/$TURTL_DOMAIN_NAME/htdocs/ --group turtl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				381
			 | 
			
			
				+    chmod a+w /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				347
			 | 
			
				382
			 | 
			
			
				     chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				348
			 | 
			
				383
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				349
			 | 
			
				384
			 | 
			
			
				     echo '[Unit]' > /etc/systemd/system/turtl.service 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -357,7 +392,7 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				357
			 | 
			
				392
			 | 
			
			
				     echo '[Service]' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				358
			 | 
			
				393
			 | 
			
			
				     echo 'Type=simple' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				359
			 | 
			
				394
			 | 
			
			
				     echo 'User=turtl' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				360
			 | 
			
				
			 | 
			
			
				-    echo "WorkingDirectory=/var/www/$TURTL_DOMAIN_NAME/htdocs/" >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				395
			 | 
			
			
				+    echo "WorkingDirectory=/var/www/$TURTL_DOMAIN_NAME/htdocs/api/" >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				361
			 | 
			
				396
			 | 
			
			
				     check_architecture=$(uname -a) 
			 | 
		
	
		
			
			| 
				362
			 | 
			
				397
			 | 
			
			
				     if [[ "$check_architecture" == *"64"* && "$check_architecture" != *"arm"* ]]; then 
			 | 
		
	
		
			
			| 
				363
			 | 
			
				398
			 | 
			
			
				         echo 'ExecStart=/usr/bin/ccl64 -Q -b --load start.lisp' >> /etc/systemd/system/turtl.service 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -369,6 +404,9 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				369
			 | 
			
				404
			 | 
			
			
				     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				370
			 | 
			
				405
			 | 
			
			
				     chmod +x /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				371
			 | 
			
				406
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				407
			 | 
			
			
				+    TURTL_ONION_HOSTNAME=$(add_onion_service turtl 80 ${TURTL_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				408
			 | 
			
			
				+    TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				409
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				372
			 | 
			
				410
			 | 
			
			
				     turtl_nginx_site=/etc/nginx/sites-available/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				373
			 | 
			
				411
			 | 
			
			
				     if [[ $ONION_ONLY == "no" ]]; then 
			 | 
		
	
		
			
			| 
				374
			 | 
			
				412
			 | 
			
			
				         function_check nginx_http_redirect 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -376,7 +414,7 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				376
			 | 
			
				414
			 | 
			
			
				         echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				377
			 | 
			
				415
			 | 
			
			
				         echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				378
			 | 
			
				416
			 | 
			
			
				         echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				379
			 | 
			
				
			 | 
			
			
				-        echo "  server_name $TURTL_DOMAIN_NAME;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				417
			 | 
			
			
				+        echo "  server_name api.${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				380
			 | 
			
				418
			 | 
			
			
				         echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				381
			 | 
			
				419
			 | 
			
			
				         echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				382
			 | 
			
				420
			 | 
			
			
				         function_check nginx_ssl 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -392,7 +430,7 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				392
			 | 
			
				430
			 | 
			
			
				         echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				393
			 | 
			
				431
			 | 
			
			
				         echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				394
			 | 
			
				432
			 | 
			
			
				         echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				395
			 | 
			
				
			 | 
			
			
				-        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				433
			 | 
			
			
				+        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs/api;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				396
			 | 
			
				434
			 | 
			
			
				         echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				397
			 | 
			
				435
			 | 
			
			
				         echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				398
			 | 
			
				436
			 | 
			
			
				         function_check nginx_limits 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -404,12 +442,43 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				404
			 | 
			
				442
			 | 
			
			
				         echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				405
			 | 
			
				443
			 | 
			
			
				         nginx_keybase $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				406
			 | 
			
				444
			 | 
			
			
				         echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				445
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				446
			 | 
			
			
				+        echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				447
			 | 
			
			
				+        echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				448
			 | 
			
			
				+        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				449
			 | 
			
			
				+        echo "  server_name ${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				450
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				451
			 | 
			
			
				+        echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				452
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				453
			 | 
			
			
				+        echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				454
			 | 
			
			
				+        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				455
			 | 
			
			
				+        nginx_ssl $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				456
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				457
			 | 
			
			
				+        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				458
			 | 
			
			
				+        nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				459
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				460
			 | 
			
			
				+        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				461
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				462
			 | 
			
			
				+        echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				463
			 | 
			
			
				+        echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				464
			 | 
			
			
				+        echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				465
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				466
			 | 
			
			
				+        echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				467
			 | 
			
			
				+        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				468
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				469
			 | 
			
			
				+        echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				470
			 | 
			
			
				+        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				471
			 | 
			
			
				+        nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				472
			 | 
			
			
				+        echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				473
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				474
			 | 
			
			
				+        nginx_keybase $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				475
			 | 
			
			
				+        echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				407
			 | 
			
				476
			 | 
			
			
				     else 
			 | 
		
	
		
			
			| 
				408
			 | 
			
				477
			 | 
			
			
				         echo -n '' > $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				409
			 | 
			
				478
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				410
			 | 
			
				479
			 | 
			
			
				     echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				411
			 | 
			
				
			 | 
			
			
				-    echo "    listen 127.0.0.1:$TURTL_ONION_PORT default_server;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				412
			 | 
			
				
			 | 
			
			
				-    echo "    server_name $TURTL_DOMAIN_NAME;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				480
			 | 
			
			
				+    echo "  listen 127.0.0.1:${TURTL_API_ONION_PORT};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				481
			 | 
			
			
				+    echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				413
			 | 
			
				482
			 | 
			
			
				     echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				414
			 | 
			
				483
			 | 
			
			
				     function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				415
			 | 
			
				484
			 | 
			
			
				     nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -419,7 +488,7 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				419
			 | 
			
				488
			 | 
			
			
				     echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				420
			 | 
			
				489
			 | 
			
			
				     echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				421
			 | 
			
				490
			 | 
			
			
				     echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				422
			 | 
			
				
			 | 
			
			
				-    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				491
			 | 
			
			
				+    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs/api;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				423
			 | 
			
				492
			 | 
			
			
				     echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				424
			 | 
			
				493
			 | 
			
			
				     echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				425
			 | 
			
				494
			 | 
			
			
				     function_check nginx_limits 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -431,6 +500,30 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				431
			 | 
			
				500
			 | 
			
			
				     echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				432
			 | 
			
				501
			 | 
			
			
				     nginx_keybase $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				433
			 | 
			
				502
			 | 
			
			
				     echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				503
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				504
			 | 
			
			
				+    echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				505
			 | 
			
			
				+    echo "  listen 127.0.0.1:$TURTL_ONION_PORT default_server;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				506
			 | 
			
			
				+    echo "  server_name $TURTL_ONION_HOSTNAME;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				507
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				508
			 | 
			
			
				+    echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				509
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				510
			 | 
			
			
				+    function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				511
			 | 
			
			
				+    nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				512
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				513
			 | 
			
			
				+    echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				514
			 | 
			
			
				+    echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				515
			 | 
			
			
				+    echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				516
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				517
			 | 
			
			
				+    echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				518
			 | 
			
			
				+    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				519
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				520
			 | 
			
			
				+    echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				521
			 | 
			
			
				+    function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				522
			 | 
			
			
				+    nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				523
			 | 
			
			
				+    echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				524
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				525
			 | 
			
			
				+    nginx_keybase $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				526
			 | 
			
			
				+    echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				434
			 | 
			
				527
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				435
			 | 
			
				528
			 | 
			
			
				     function_check create_site_certificate 
			 | 
		
	
		
			
			| 
				436
			 | 
			
				529
			 | 
			
			
				     create_site_certificate $TURTL_DOMAIN_NAME 'yes' 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -448,10 +541,11 @@ function install_turtl { 
			 | 
		
	
		
			
			| 
				448
			 | 
			
				541
			 | 
			
			
				     function_check nginx_ensite 
			 | 
		
	
		
			
			| 
				449
			 | 
			
				542
			 | 
			
			
				     nginx_ensite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				450
			 | 
			
				543
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				451
			 | 
			
				
			 | 
			
			
				-    TURTL_ONION_HOSTNAME=$(add_onion_service turtl 80 ${TURTL_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				452
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				453
			 | 
			
				544
			 | 
			
			
				     if [[ $ONION_ONLY != 'no' ]]; then 
			 | 
		
	
		
			
			| 
				454
			 | 
			
				
			 | 
			
			
				-        sed -i "s|https://$TURTL_DOMAIN_NAME|http://$TURTL_ONION_HOSTNAME|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				545
			 | 
			
			
				+        sed -i "s|https://${TURTL_DOMAIN_NAME}|http://${TURTL_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				546
			 | 
			
			
				+        sed -i "s|https://api.${TURTL_DOMAIN_NAME}|http://${TURTL_API_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				547
			 | 
			
			
				+        sed -i "s|https://${TURTL_DOMAIN_NAME}|http://${TURTL_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				548
			 | 
			
			
				+        sed -i "s|https://api.${TURTL_DOMAIN_NAME}|http://${TURTL_API_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				455
			 | 
			
				549
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				456
			 | 
			
				550
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				457
			 | 
			
				551
			 | 
			
			
				     ${PROJECT_NAME}-pass -u $MY_USERNAME -a turtl -p "$TURTL_ADMIN_PASSWORD" 
			 |