| 
				
			 | 
			
			
				@@ -122,15 +122,15 @@ function reconfigure_turtl { 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				122
			 | 
			
			
				 function upgrade_turtl { 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				123
			 | 
			
			
				     read_config_param "TURTL_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				124
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				125
			 | 
			
				
			 | 
			
			
				-    install_libuv 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				125
			 | 
			
			
				     function_check set_repo_commit 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				126
			 | 
			
			
				     set_repo_commit /var/www/$TURTL_DOMAIN_NAME/htdocs "turtl commit" "$TURTL_COMMIT" $TURTL_REPO 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				-    set_repo_commit /var/www/$TURTL_DOMAIN_NAME/htdocs "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				+    set_repo_commit $TURTL_BASE_DIR/api "turtl api commit" "$TURTL_API_COMMIT" $TURTL_API_REPO 
			 | 
		
	
		
			
			| 
				130
			 | 
			
				128
			 | 
			
			
				     nginx_dissite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				131
			 | 
			
				129
			 | 
			
			
				     cd /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				132
			 | 
			
				130
			 | 
			
			
				     npm install 
			 | 
		
	
		
			
			| 
				133
			 | 
			
				131
			 | 
			
			
				     make minify 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+    chown -R turtl:turtl $TURTL_BASE_DIR 
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				134
			 | 
			
				134
			 | 
			
			
				     nginx_ensite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				135
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				136
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -148,6 +148,18 @@ function backup_local_turtl { 
			 | 
		
	
		
			
			| 
				148
			 | 
			
				148
			 | 
			
			
				         function_check restart_site 
			 | 
		
	
		
			
			| 
				149
			 | 
			
				149
			 | 
			
			
				         restart_site 
			 | 
		
	
		
			
			| 
				150
			 | 
			
				150
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				151
			 | 
			
			
				+    source_directory=/var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				152
			 | 
			
			
				+    if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				+        dest_directory=rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				+        function_check suspend_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				+        suspend_site ${TURTL_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				+        function_check backup_directory_to_usb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				+        backup_directory_to_usb $source_directory $dest_directory 
			 | 
		
	
		
			
			| 
				
			 | 
			
				159
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				160
			 | 
			
			
				+        function_check restart_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				+        restart_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				151
			 | 
			
				163
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				152
			 | 
			
				164
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				153
			 | 
			
				165
			 | 
			
			
				 function restore_local_turtl { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -173,6 +185,26 @@ function restore_local_turtl { 
			 | 
		
	
		
			
			| 
				173
			 | 
			
				185
			 | 
			
			
				         fi 
			 | 
		
	
		
			
			| 
				174
			 | 
			
				186
			 | 
			
			
				         rm -rf ${temp_restore_dir} 
			 | 
		
	
		
			
			| 
				175
			 | 
			
				187
			 | 
			
			
				         chown -R turtl:turtl /var/www/${TURTL_DOMAIN_NAME}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				188
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				189
			 | 
			
			
				+        temp_restore_dir=/root/temprethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				190
			 | 
			
			
				+        restore_directory_from_usb $temp_restore_dir rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				191
			 | 
			
			
				+        if [ -d /var/lib/rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				192
			 | 
			
			
				+            if [ -d /var/lib/previous_rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				193
			 | 
			
			
				+                rm -rf /var/lib/previous_rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				194
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+            mv /var/lib/rethinkdb /var/lib/previous_rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				196
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				197
			 | 
			
			
				+        temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				198
			 | 
			
			
				+        cp -r ${temp_source_dir} /var/lib/ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				199
			 | 
			
			
				+        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				200
			 | 
			
			
				+            if [ -d /var/lib/previous_rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				201
			 | 
			
			
				+                mv /var/lib/previous_rethinkdb /var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				202
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				203
			 | 
			
			
				+            set_user_permissions 
			 | 
		
	
		
			
			| 
				
			 | 
			
				204
			 | 
			
			
				+            backup_unmount_drive 
			 | 
		
	
		
			
			| 
				
			 | 
			
				205
			 | 
			
			
				+            exit 378324 
			 | 
		
	
		
			
			| 
				
			 | 
			
				206
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				207
			 | 
			
			
				+        rm -rf ${temp_restore_dir} 
			 | 
		
	
		
			
			| 
				176
			 | 
			
				208
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				177
			 | 
			
				209
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				178
			 | 
			
				210
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -188,6 +220,13 @@ function backup_remote_turtl { 
			 | 
		
	
		
			
			| 
				188
			 | 
			
				220
			 | 
			
			
				             echo $"turtl domain specified but not found in $temp_backup_dir" 
			 | 
		
	
		
			
			| 
				189
			 | 
			
				221
			 | 
			
			
				             exit 68725 
			 | 
		
	
		
			
			| 
				190
			 | 
			
				222
			 | 
			
			
				         fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				223
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				224
			 | 
			
			
				+        temp_backup_dir=/var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				225
			 | 
			
			
				+        if [ -d $temp_backup_dir ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				226
			 | 
			
			
				+            echo $"Backing up rethinkdb" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				227
			 | 
			
			
				+            backup_directory_to_friend $temp_backup_dir rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				228
			 | 
			
			
				+            echo $"Backup of rethinkdb complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				229
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				191
			 | 
			
				230
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				192
			 | 
			
				231
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				193
			 | 
			
				232
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -213,43 +252,28 @@ function restore_remote_turtl { 
			 | 
		
	
		
			
			| 
				213
			 | 
			
				252
			 | 
			
			
				             exit 37823 
			 | 
		
	
		
			
			| 
				214
			 | 
			
				253
			 | 
			
			
				         fi 
			 | 
		
	
		
			
			| 
				215
			 | 
			
				254
			 | 
			
			
				         rm -rf ${temp_restore_dir} 
			 | 
		
	
		
			
			| 
				216
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				217
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				218
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				219
			 | 
			
				
			 | 
			
			
				-function remove_turtl_old { 
			 | 
		
	
		
			
			| 
				220
			 | 
			
				
			 | 
			
			
				-    if [ ${#TURTL_DOMAIN_NAME} -eq 0 ]; then 
			 | 
		
	
		
			
			| 
				221
			 | 
			
				
			 | 
			
			
				-        return 
			 | 
		
	
		
			
			| 
				222
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				223
			 | 
			
				
			 | 
			
			
				-    read_config_param "TURTL_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				224
			 | 
			
				
			 | 
			
			
				-    read_config_param "MY_USERNAME" 
			 | 
		
	
		
			
			| 
				225
			 | 
			
				
			 | 
			
			
				-    echo "Removing $TURTL_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				226
			 | 
			
				
			 | 
			
			
				-    if [ -f /etc/systemd/system/turtl.service ]; then 
			 | 
		
	
		
			
			| 
				227
			 | 
			
				
			 | 
			
			
				-        systemctl stop turtl 
			 | 
		
	
		
			
			| 
				228
			 | 
			
				
			 | 
			
			
				-        systemctl disable turtl 
			 | 
		
	
		
			
			| 
				229
			 | 
			
				
			 | 
			
			
				-        rm /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				230
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				231
			 | 
			
				
			 | 
			
			
				-    nginx_dissite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				232
			 | 
			
				
			 | 
			
			
				-    remove_certs $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				233
			 | 
			
				
			 | 
			
			
				-    if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				234
			 | 
			
				
			 | 
			
			
				-        rm -rf /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				235
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				236
			 | 
			
				
			 | 
			
			
				-    if [ -f /etc/nginx/sites-available/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				237
			 | 
			
				
			 | 
			
			
				-        rm /etc/nginx/sites-available/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				238
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				239
			 | 
			
				
			 | 
			
			
				-    function_check remove_onion_service 
			 | 
		
	
		
			
			| 
				240
			 | 
			
				
			 | 
			
			
				-    remove_onion_service turtl ${TURTL_ONION_PORT} 
			 | 
		
	
		
			
			| 
				241
			 | 
			
				
			 | 
			
			
				-    remove_onion_service turtlapi ${TURTL_API_ONION_PORT} 
			 | 
		
	
		
			
			| 
				242
			 | 
			
				
			 | 
			
			
				-    remove_app turtl 
			 | 
		
	
		
			
			| 
				243
			 | 
			
				
			 | 
			
			
				-    remove_completion_param install_turtl 
			 | 
		
	
		
			
			| 
				244
			 | 
			
				
			 | 
			
			
				-    sed -i '/turtl/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				245
			 | 
			
				
			 | 
			
			
				-    deluser --remove-all-files turtl 
			 | 
		
	
		
			
			| 
				246
			 | 
			
				
			 | 
			
			
				-    remove_nodejs turtl 
			 | 
		
	
		
			
			| 
				247
			 | 
			
				255
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				248
			 | 
			
				
			 | 
			
			
				-    remove_rethinkdb 
			 | 
		
	
		
			
			| 
				249
			 | 
			
				
			 | 
			
			
				-    remove_common_lisp 
			 | 
		
	
		
			
			| 
				250
			 | 
			
				256
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				251
			 | 
			
				
			 | 
			
			
				-    function_check remove_ddns_domain 
			 | 
		
	
		
			
			| 
				252
			 | 
			
				
			 | 
			
			
				-    remove_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				257
			 | 
			
			
				+        temp_restore_dir=/root/temprethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				258
			 | 
			
			
				+        mkdir $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				259
			 | 
			
			
				+        function_check restore_directory_from_friend 
			 | 
		
	
		
			
			| 
				
			 | 
			
				260
			 | 
			
			
				+        restore_directory_from_friend $temp_restore_dir rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				261
			 | 
			
			
				+        if [ -d /var/lib/rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				262
			 | 
			
			
				+            if [ -d /var/lib/previous_rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				263
			 | 
			
			
				+                rm -rf /var/lib/previous_rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				264
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				265
			 | 
			
			
				+            mv /var/lib/rethinkdb /var/lib/previous_rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				266
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				267
			 | 
			
			
				+        temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				268
			 | 
			
			
				+        cp -r ${temp_source_dir} /var/lib/ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				269
			 | 
			
			
				+        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				270
			 | 
			
			
				+            if [ -d /var/lib/previous_rethinkdb ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				271
			 | 
			
			
				+                mv /var/lib/previous_rethinkdb /var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				+            exit 26783 
			 | 
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				+        rm -rf ${temp_restore_dir} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				253
			 | 
			
				277
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				254
			 | 
			
				278
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				255
			 | 
			
				279
			 | 
			
			
				 function remove_turtl { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -259,442 +283,30 @@ function remove_turtl { 
			 | 
		
	
		
			
			| 
				259
			 | 
			
				283
			 | 
			
			
				     systemctl stop turtl 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				284
			 | 
			
			
				     systemctl disable turtl 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				285
			 | 
			
			
				     rm /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				262
			 | 
			
				
			 | 
			
			
				-    apt-get -y remove rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				+    remove_rethinkdb 
			 | 
		
	
		
			
			| 
				263
			 | 
			
				287
			 | 
			
			
				     remove_app turtl 
			 | 
		
	
		
			
			| 
				264
			 | 
			
				288
			 | 
			
			
				     remove_completion_param install_turtl 
			 | 
		
	
		
			
			| 
				265
			 | 
			
				289
			 | 
			
			
				     sed -i '/turtl/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				266
			 | 
			
				290
			 | 
			
			
				     deluser turtl 
			 | 
		
	
		
			
			| 
				267
			 | 
			
				
			 | 
			
			
				-    rm -rf /etc/rethinkdb 
			 | 
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				-    rm -rf /var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				269
			 | 
			
				
			 | 
			
			
				-    rm -rf $TURTL_BASE_DIR 
			 | 
		
	
		
			
			| 
				270
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				-function install_libuv { 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /usr/local/src ]; then 
			 | 
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				-        mkdir -p /usr/local/src 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				276
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				277
			 | 
			
				
			 | 
			
			
				-    cd /usr/local/src 
			 | 
		
	
		
			
			| 
				278
			 | 
			
				
			 | 
			
			
				-    if [ ! -f libuv-v${LIBUV_VERSION}.tar.gz ]; then 
			 | 
		
	
		
			
			| 
				279
			 | 
			
				
			 | 
			
			
				-        wget http://dist.libuv.org/dist/v${LIBUV_VERSION}/libuv-v${LIBUV_VERSION}.tar.gz 
			 | 
		
	
		
			
			| 
				280
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				281
			 | 
			
				
			 | 
			
			
				-    if [ ! -f libuv-v${LIBUV_VERSION}.tar.gz ]; then 
			 | 
		
	
		
			
			| 
				282
			 | 
			
				
			 | 
			
			
				-        echo $"Couldn't download libuv ${LIBUV_VERSION}" 
			 | 
		
	
		
			
			| 
				283
			 | 
			
				
			 | 
			
			
				-        exit 728235 
			 | 
		
	
		
			
			| 
				284
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				285
			 | 
			
				
			 | 
			
			
				-    hashstr=$(sha256sum libuv-v${LIBUV_VERSION}.tar.gz | awk -F ' ' '{print $1}') 
			 | 
		
	
		
			
			| 
				286
			 | 
			
				
			 | 
			
			
				-    if [[ "$hashstr" != "$LIBUV_HASH" ]]; then 
			 | 
		
	
		
			
			| 
				287
			 | 
			
				
			 | 
			
			
				-        rm libuv-v${LIBUV_VERSION}.tar.gz 
			 | 
		
	
		
			
			| 
				288
			 | 
			
				
			 | 
			
			
				-        echo $"libuv hash does not match. Expected $LIBUV_HASH but found $hashstr" 
			 | 
		
	
		
			
			| 
				289
			 | 
			
				
			 | 
			
			
				-        exit 27685 
			 | 
		
	
		
			
			| 
				290
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				291
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /usr/local/src/libuv-v${LIBUV_VERSION} ]; then 
			 | 
		
	
		
			
			| 
				292
			 | 
			
				
			 | 
			
			
				-        tar -xf libuv-v${LIBUV_VERSION}.tar.gz 
			 | 
		
	
		
			
			| 
				293
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				294
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /usr/local/src/libuv-v${LIBUV_VERSION} ]; then 
			 | 
		
	
		
			
			| 
				295
			 | 
			
				
			 | 
			
			
				-        rm libuv-v${LIBUV_VERSION}.tar.gz 
			 | 
		
	
		
			
			| 
				296
			 | 
			
				
			 | 
			
			
				-        echo $'libuv could not be extracted' 
			 | 
		
	
		
			
			| 
				297
			 | 
			
				
			 | 
			
			
				-        exit 72754 
			 | 
		
	
		
			
			| 
				298
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				299
			 | 
			
				
			 | 
			
			
				-    cd /usr/local/src/libuv-v${LIBUV_VERSION} 
			 | 
		
	
		
			
			| 
				300
			 | 
			
				
			 | 
			
			
				-    sh autogen.sh 
			 | 
		
	
		
			
			| 
				301
			 | 
			
				
			 | 
			
			
				-    ./configure 
			 | 
		
	
		
			
			| 
				302
			 | 
			
				
			 | 
			
			
				-    make 
			 | 
		
	
		
			
			| 
				303
			 | 
			
				
			 | 
			
			
				-    make install 
			 | 
		
	
		
			
			| 
				304
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				305
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				306
			 | 
			
				
			 | 
			
			
				-function install_turtl_old { 
			 | 
		
	
		
			
			| 
				307
			 | 
			
				
			 | 
			
			
				-    if [ ! $TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				308
			 | 
			
				
			 | 
			
			
				-        echo $'No domain name was given for turtl' 
			 | 
		
	
		
			
			| 
				309
			 | 
			
				
			 | 
			
			
				-        exit 47823 
			 | 
		
	
		
			
			| 
				310
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				311
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				312
			 | 
			
				
			 | 
			
			
				-    if [ -f $IMAGE_PASSWORD_FILE ]; then 
			 | 
		
	
		
			
			| 
				313
			 | 
			
				
			 | 
			
			
				-        TURTL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" 
			 | 
		
	
		
			
			| 
				314
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				315
			 | 
			
				
			 | 
			
			
				-        if [ ! $TURTL_ADMIN_PASSWORD ]; then 
			 | 
		
	
		
			
			| 
				316
			 | 
			
				
			 | 
			
			
				-            TURTL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" 
			 | 
		
	
		
			
			| 
				317
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				318
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				319
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install git wget curl libtool subversion gcc make automake 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /usr/local/src ]; then 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				
			 | 
			
			
				-        mkdir -p /usr/local/src 
			 | 
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				+    nginx_dissite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				+    if [ -f /etc/nginx/sites-available/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				293
			 | 
			
			
				+        rm /etc/nginx/sites-available/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				294
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				325
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				+    remove_certs $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				326
			 | 
			
				296
			 | 
			
			
				     if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				327
			 | 
			
				297
			 | 
			
			
				         rm -rf /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				328
			 | 
			
				298
			 | 
			
			
				     fi 
			 | 
		
	
		
			
			| 
				329
			 | 
			
				
			 | 
			
			
				-    mkdir /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				330
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				331
			 | 
			
				
			 | 
			
			
				-    # get the app 
			 | 
		
	
		
			
			| 
				332
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs ]; then 
			 | 
		
	
		
			
			| 
				333
			 | 
			
				
			 | 
			
			
				-        function_check git_clone 
			 | 
		
	
		
			
			| 
				334
			 | 
			
				
			 | 
			
			
				-        git_clone $TURTL_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				335
			 | 
			
				
			 | 
			
			
				-        if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs ]; then 
			 | 
		
	
		
			
			| 
				336
			 | 
			
				
			 | 
			
			
				-            echo $'Unable to clone turtl repo' 
			 | 
		
	
		
			
			| 
				337
			 | 
			
				
			 | 
			
			
				-            exit 367292 
			 | 
		
	
		
			
			| 
				338
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				339
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				340
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				341
			 | 
			
				
			 | 
			
			
				-    # get the api 
			 | 
		
	
		
			
			| 
				342
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/api ]; then 
			 | 
		
	
		
			
			| 
				343
			 | 
			
				
			 | 
			
			
				-        git_clone $TURTL_API_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs/api 
			 | 
		
	
		
			
			| 
				344
			 | 
			
				
			 | 
			
			
				-        if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/api ]; then 
			 | 
		
	
		
			
			| 
				345
			 | 
			
				
			 | 
			
			
				-            echo $'Unable to clone turtl api repo' 
			 | 
		
	
		
			
			| 
				346
			 | 
			
				
			 | 
			
			
				-            exit 473843 
			 | 
		
	
		
			
			| 
				347
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				348
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				349
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				350
			 | 
			
				
			 | 
			
			
				-    # check that default config files exist 
			 | 
		
	
		
			
			| 
				351
			 | 
			
				
			 | 
			
			
				-    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.default.lisp ]; then 
			 | 
		
	
		
			
			| 
				352
			 | 
			
				
			 | 
			
			
				-        echo $'No default turtl api config found' 
			 | 
		
	
		
			
			| 
				353
			 | 
			
				
			 | 
			
			
				-        exit 825328 
			 | 
		
	
		
			
			| 
				354
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				355
			 | 
			
				
			 | 
			
			
				-    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default ]; then 
			 | 
		
	
		
			
			| 
				356
			 | 
			
				
			 | 
			
			
				-        echo $'No default turtl config found' 
			 | 
		
	
		
			
			| 
				357
			 | 
			
				
			 | 
			
			
				-        exit 783524 
			 | 
		
	
		
			
			| 
				358
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				359
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				360
			 | 
			
				
			 | 
			
			
				-    # directory where uploads are stored 
			 | 
		
	
		
			
			| 
				361
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /var/www/$TURTL_DOMAIN_NAME/htdocs/data ]; then 
			 | 
		
	
		
			
			| 
				362
			 | 
			
				
			 | 
			
			
				-        mkdir -p /var/www/$TURTL_DOMAIN_NAME/htdocs/data 
			 | 
		
	
		
			
			| 
				363
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				364
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				365
			 | 
			
				
			 | 
			
			
				-    # create config files 
			 | 
		
	
		
			
			| 
				366
			 | 
			
				
			 | 
			
			
				-    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.default.lisp /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				367
			 | 
			
				
			 | 
			
			
				-    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				368
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				369
			 | 
			
				
			 | 
			
			
				-    # app config file settings 
			 | 
		
	
		
			
			| 
				370
			 | 
			
				
			 | 
			
			
				-    sed -i "s|api_url.*|api_url: 'https://api.${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				371
			 | 
			
				
			 | 
			
			
				-    sed -i "s|site_url.*|api_url: 'https://${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				372
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				373
			 | 
			
				
			 | 
			
			
				-    # api config file settings 
			 | 
		
	
		
			
			| 
				374
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *admin-email* \".*|defvar *admin-email* \"$MY_EMAIL_ADDRESS\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				375
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *email-from* \".*|defvar *email-from* \"noreply@$DEFAULT_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				376
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *site-url* \".*|defvar *site-url* \"https://$TURTL_DOMAIN_NAME\"|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				377
			 | 
			
				
			 | 
			
			
				-    sed -i "s|defvar *analytics* '(:enabled.*|defvar *analytics* '(:enabled f|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				378
			 | 
			
				
			 | 
			
			
				-    sed -i 's|http://turtl.dev:8181|https://$TURTL_DOMAIN_NAME|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				379
			 | 
			
				
			 | 
			
			
				-    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 
			 | 
		
	
		
			
			| 
				380
			 | 
			
				
			 | 
			
			
				-    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 
			 | 
		
	
		
			
			| 
				381
			 | 
			
				
			 | 
			
			
				-    sed -i 's|defparameter *storage-invite-credit*.*|defparameter *storage-invite-credit* 0|g' /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				382
			 | 
			
				
			 | 
			
			
				-    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 
			 | 
		
	
		
			
			| 
				383
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				384
			 | 
			
				
			 | 
			
			
				-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				385
			 | 
			
				
			 | 
			
			
				-    git checkout $TURTL_COMMIT -b $TURTL_COMMIT 
			 | 
		
	
		
			
			| 
				386
			 | 
			
				
			 | 
			
			
				-    set_completion_param "turtl commit" "$TURTL_COMMIT" 
			 | 
		
	
		
			
			| 
				387
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				388
			 | 
			
				
			 | 
			
			
				-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs/api 
			 | 
		
	
		
			
			| 
				389
			 | 
			
				
			 | 
			
			
				-    git checkout $TURTL_API_COMMIT -b $TURTL_API_COMMIT 
			 | 
		
	
		
			
			| 
				390
			 | 
			
				
			 | 
			
			
				-    set_completion_param "turtl api commit" "$TURTL_API_COMMIT" 
			 | 
		
	
		
			
			| 
				391
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				392
			 | 
			
				
			 | 
			
			
				-    function_check install_libuv 
			 | 
		
	
		
			
			| 
				393
			 | 
			
				
			 | 
			
			
				-    install_libuv 
			 | 
		
	
		
			
			| 
				394
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				395
			 | 
			
				
			 | 
			
			
				-    function_check install_rethinkdb 
			 | 
		
	
		
			
			| 
				396
			 | 
			
				
			 | 
			
			
				-    install_rethinkdb 
			 | 
		
	
		
			
			| 
				397
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				398
			 | 
			
				
			 | 
			
			
				-    function_check install_common_lisp 
			 | 
		
	
		
			
			| 
				399
			 | 
			
				
			 | 
			
			
				-    install_common_lisp 
			 | 
		
	
		
			
			| 
				400
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				401
			 | 
			
				
			 | 
			
			
				-    function_check install_quicklisp 
			 | 
		
	
		
			
			| 
				402
			 | 
			
				
			 | 
			
			
				-    install_quicklisp 
			 | 
		
	
		
			
			| 
				403
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				404
			 | 
			
				
			 | 
			
			
				-    function_check install_nodejs 
			 | 
		
	
		
			
			| 
				405
			 | 
			
				
			 | 
			
			
				-    install_nodejs turtl 
			 | 
		
	
		
			
			| 
				406
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				407
			 | 
			
				
			 | 
			
			
				-    function_check add_ddns_domain 
			 | 
		
	
		
			
			| 
				408
			 | 
			
				
			 | 
			
			
				-    add_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				409
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				410
			 | 
			
				
			 | 
			
			
				-    sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl 
			 | 
		
	
		
			
			| 
				411
			 | 
			
				
			 | 
			
			
				-    sed -i 's|CCL_DEFAULT_DIRECTORY=.*|CCL_DEFAULT_DIRECTORY=/usr/local/src/ccl|g' /usr/bin/ccl64 
			 | 
		
	
		
			
			| 
				412
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				413
			 | 
			
				
			 | 
			
			
				-    adduser --disabled-login --home=/var/www/$TURTL_DOMAIN_NAME/htdocs --gecos 'turtl' turtl 
			 | 
		
	
		
			
			| 
				414
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				415
			 | 
			
				
			 | 
			
			
				-    cp /usr/local/src/asdf.lisp /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				416
			 | 
			
				
			 | 
			
			
				-    cp /usr/local/src/quicklisp.lisp /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				417
			 | 
			
				
			 | 
			
			
				-    echo '(load (compile-file "asdf.lisp"))' > /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				418
			 | 
			
				
			 | 
			
			
				-    echo '(load (compile-file "quicklisp.lisp"))' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				419
			 | 
			
				
			 | 
			
			
				-    echo '(quicklisp-quickstart:install)' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				420
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				421
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				422
			 | 
			
				
			 | 
			
			
				-    echo '(ql:system-apropos "vecto")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				423
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "alexandria")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				424
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "babel")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				425
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "blackbird")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				426
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "bordeaux-threads")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				427
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cffi")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				428
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "chipz")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				429
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "chunga")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				430
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-annot")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				431
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-async")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				432
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-async-future")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				433
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-base64")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				434
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-fad")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				435
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-libuv")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				436
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-mongo-id")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				437
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-ppcre")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				438
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-rethinkdb")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				439
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-smtp")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				440
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl+ssl")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				441
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-syntax")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				442
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-utilities")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				443
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "cl-vectors")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				444
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "do-urlencode")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				445
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "drakma")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				446
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "drakma-async")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				447
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "event-glue")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				448
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "fast-http")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				449
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "fast-io")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				450
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "flexi-streams")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				451
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "ironclad")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				452
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "jonathan")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				453
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "local-time")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				454
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "md5")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				455
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "named-readtables")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				456
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "nibbles")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				457
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "proc-parse")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				458
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "puri")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				459
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "quri")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				460
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "salza2")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				461
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "secure-random")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				462
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "smart-buffer")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				463
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "split-sequence")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				464
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "static-vectors")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				465
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "trivial-backtrace")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				466
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "trivial-features")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				467
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "trivial-garbage")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				468
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "trivial-gray-streams")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				469
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "trivial-types")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				470
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "usocket")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				471
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "vecto")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				472
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "vom")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				473
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "wookie")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				474
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "xmls")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				475
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "xsubseq")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				476
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "yason")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				477
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "zpb-ttf")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				478
			 | 
			
				
			 | 
			
			
				-    echo '(ql:quickload "zpng")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				479
			 | 
			
				
			 | 
			
			
				-    echo '(ql:add-to-init-file)' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/install.lisp 
			 | 
		
	
		
			
			| 
				480
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				481
			 | 
			
				
			 | 
			
			
				-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				482
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				483
			 | 
			
				
			 | 
			
			
				-    check_architecture=$(uname -a) 
			 | 
		
	
		
			
			| 
				484
			 | 
			
				
			 | 
			
			
				-    if [[ "$check_architecture" == *"64"* && "$check_architecture" != *"arm"* ]]; then 
			 | 
		
	
		
			
			| 
				485
			 | 
			
				
			 | 
			
			
				-        su -c '/usr/bin/ccl64 --load install.lisp --eval "(ccl::quit)"' - turtl 
			 | 
		
	
		
			
			| 
				486
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				487
			 | 
			
				
			 | 
			
			
				-        su -c '/usr/bin/ccl --load install.lisp --eval "(ccl::quit)"' - turtl 
			 | 
		
	
		
			
			| 
				488
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				489
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				490
			 | 
			
				
			 | 
			
			
				-    echo "(pushnew \"./\" asdf:*central-registry* :test #'equal)" > /var/www/$TURTL_DOMAIN_NAME/htdocs/api/launch.lisp 
			 | 
		
	
		
			
			| 
				491
			 | 
			
				
			 | 
			
			
				-    echo '(load "start")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/api/launch.lisp 
			 | 
		
	
		
			
			| 
				492
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				493
			 | 
			
				
			 | 
			
			
				-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs/quicklisp/local-projects 
			 | 
		
	
		
			
			| 
				494
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/cl-hash-util 
			 | 
		
	
		
			
			| 
				495
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/vom 
			 | 
		
	
		
			
			| 
				496
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/cl-async 
			 | 
		
	
		
			
			| 
				497
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/cffi 
			 | 
		
	
		
			
			| 
				498
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/wookie 
			 | 
		
	
		
			
			| 
				499
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/cl-rethinkdb 
			 | 
		
	
		
			
			| 
				500
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/cl-libuv 
			 | 
		
	
		
			
			| 
				501
			 | 
			
				
			 | 
			
			
				-    git clone git://github.com/orthecreedence/drakma-async 
			 | 
		
	
		
			
			| 
				502
			 | 
			
				
			 | 
			
			
				-    git clone https://github.com/Inaimathi/cl-cwd.git 
			 | 
		
	
		
			
			| 
				503
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				504
			 | 
			
				
			 | 
			
			
				-    echo '#-quicklisp' > /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				505
			 | 
			
				
			 | 
			
			
				-    echo '(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				506
			 | 
			
				
			 | 
			
			
				-    echo '  (when (probe-file quicklisp-init)' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				507
			 | 
			
				
			 | 
			
			
				-    echo '    (load quicklisp-init)))' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				508
			 | 
			
				
			 | 
			
			
				-    echo '(cwd "~/api")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				509
			 | 
			
				
			 | 
			
			
				-    echo '(load "~/api/launch")' >> /var/www/$TURTL_DOMAIN_NAME/htdocs/.ccl-init.lisp 
			 | 
		
	
		
			
			| 
				510
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				511
			 | 
			
				
			 | 
			
			
				-    chmod a+w /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				512
			 | 
			
				
			 | 
			
			
				-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				513
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				514
			 | 
			
				
			 | 
			
			
				-    # install the app 
			 | 
		
	
		
			
			| 
				515
			 | 
			
				
			 | 
			
			
				-    cd /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				516
			 | 
			
				
			 | 
			
			
				-    npm install 
			 | 
		
	
		
			
			| 
				517
			 | 
			
				
			 | 
			
			
				-    make minify 
			 | 
		
	
		
			
			| 
				518
			 | 
			
				
			 | 
			
			
				-    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/index.html ]; then 
			 | 
		
	
		
			
			| 
				519
			 | 
			
				
			 | 
			
			
				-        echo $'Failed to install turtl app' 
			 | 
		
	
		
			
			| 
				520
			 | 
			
				
			 | 
			
			
				-        exit 823652 
			 | 
		
	
		
			
			| 
				521
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				522
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				523
			 | 
			
				
			 | 
			
			
				-    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				524
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				525
			 | 
			
				
			 | 
			
			
				-    echo '[Unit]' > /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				526
			 | 
			
				
			 | 
			
			
				-    echo 'Description=Note taking service' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				527
			 | 
			
				
			 | 
			
			
				-    echo 'Documentation=http://turtl.it' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				528
			 | 
			
				
			 | 
			
			
				-    echo 'Requires=network.target' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				529
			 | 
			
				
			 | 
			
			
				-    echo 'Requires=rethinkdb.service' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				530
			 | 
			
				
			 | 
			
			
				-    echo 'After=network.target' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				531
			 | 
			
				
			 | 
			
			
				-    echo 'After=rethinkdb.service' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				532
			 | 
			
				
			 | 
			
			
				-    echo '' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				533
			 | 
			
				
			 | 
			
			
				-    echo '[Service]' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				534
			 | 
			
				
			 | 
			
			
				-    echo 'Type=simple' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				535
			 | 
			
				
			 | 
			
			
				-    echo 'User=turtl' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				536
			 | 
			
				
			 | 
			
			
				-    echo 'Group=turtl' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				537
			 | 
			
				
			 | 
			
			
				-    echo "WorkingDirectory=/var/www/$TURTL_DOMAIN_NAME/htdocs/api/" >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				538
			 | 
			
				
			 | 
			
			
				-    check_architecture=$(uname -a) 
			 | 
		
	
		
			
			| 
				539
			 | 
			
				
			 | 
			
			
				-    if [[ "$check_architecture" == *"64"* && "$check_architecture" != *"arm"* ]]; then 
			 | 
		
	
		
			
			| 
				540
			 | 
			
				
			 | 
			
			
				-        echo "ExecStart=/usr/bin/ccl64 -Q -b --load start.lisp" >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				541
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				542
			 | 
			
				
			 | 
			
			
				-        echo "ExecStart=/usr/bin/ccl -Q -b --load start.lisp" >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				543
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				544
			 | 
			
				
			 | 
			
			
				-    echo '' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				545
			 | 
			
				
			 | 
			
			
				-    echo '[Install]' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				546
			 | 
			
				
			 | 
			
			
				-    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				547
			 | 
			
				
			 | 
			
			
				-    chmod +x /etc/systemd/system/turtl.service 
			 | 
		
	
		
			
			| 
				548
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				549
			 | 
			
				
			 | 
			
			
				-    TURTL_ONION_HOSTNAME=$(add_onion_service turtl 80 ${TURTL_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				550
			 | 
			
				
			 | 
			
			
				-    TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				551
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				552
			 | 
			
				
			 | 
			
			
				-    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				553
			 | 
			
				
			 | 
			
			
				-    if [[ $ONION_ONLY == "no" ]]; then 
			 | 
		
	
		
			
			| 
				554
			 | 
			
				
			 | 
			
			
				-        function_check nginx_http_redirect 
			 | 
		
	
		
			
			| 
				555
			 | 
			
				
			 | 
			
			
				-        nginx_http_redirect $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				556
			 | 
			
				
			 | 
			
			
				-        echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				557
			 | 
			
				
			 | 
			
			
				-        echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				558
			 | 
			
				
			 | 
			
			
				-        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				559
			 | 
			
				
			 | 
			
			
				-        echo "  server_name api.${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				560
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				561
			 | 
			
				
			 | 
			
			
				-        echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				562
			 | 
			
				
			 | 
			
			
				-        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				563
			 | 
			
				
			 | 
			
			
				-        nginx_ssl $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				564
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				565
			 | 
			
				
			 | 
			
			
				-        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				566
			 | 
			
				
			 | 
			
			
				-        nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				567
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				568
			 | 
			
				
			 | 
			
			
				-        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				569
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				570
			 | 
			
				
			 | 
			
			
				-        echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				571
			 | 
			
				
			 | 
			
			
				-        echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				572
			 | 
			
				
			 | 
			
			
				-        echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				573
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				574
			 | 
			
				
			 | 
			
			
				-        echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				575
			 | 
			
				
			 | 
			
			
				-        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs/api;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				576
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				577
			 | 
			
				
			 | 
			
			
				-        echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				578
			 | 
			
				
			 | 
			
			
				-        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				579
			 | 
			
				
			 | 
			
			
				-        nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				580
			 | 
			
				
			 | 
			
			
				-        echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				581
			 | 
			
				
			 | 
			
			
				-        echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				582
			 | 
			
				
			 | 
			
			
				-        echo '    proxy_buffering   off;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				583
			 | 
			
				
			 | 
			
			
				-        echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				584
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				585
			 | 
			
				
			 | 
			
			
				-        echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				586
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				587
			 | 
			
				
			 | 
			
			
				-        echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				588
			 | 
			
				
			 | 
			
			
				-        echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				589
			 | 
			
				
			 | 
			
			
				-        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				590
			 | 
			
				
			 | 
			
			
				-        echo "  server_name ${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				591
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				592
			 | 
			
				
			 | 
			
			
				-        echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				593
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				594
			 | 
			
				
			 | 
			
			
				-        echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				595
			 | 
			
				
			 | 
			
			
				-        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				596
			 | 
			
				
			 | 
			
			
				-        nginx_ssl $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				597
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				598
			 | 
			
				
			 | 
			
			
				-        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				599
			 | 
			
				
			 | 
			
			
				-        nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				600
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				601
			 | 
			
				
			 | 
			
			
				-        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				602
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				603
			 | 
			
				
			 | 
			
			
				-        echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				604
			 | 
			
				
			 | 
			
			
				-        echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				605
			 | 
			
				
			 | 
			
			
				-        echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				606
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				607
			 | 
			
				
			 | 
			
			
				-        echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				608
			 | 
			
				
			 | 
			
			
				-        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				609
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				610
			 | 
			
				
			 | 
			
			
				-        echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				611
			 | 
			
				
			 | 
			
			
				-        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				612
			 | 
			
				
			 | 
			
			
				-        nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				613
			 | 
			
				
			 | 
			
			
				-        echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				614
			 | 
			
				
			 | 
			
			
				-        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				615
			 | 
			
				
			 | 
			
			
				-        echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				616
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				617
			 | 
			
				
			 | 
			
			
				-        echo -n '' > $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				618
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				619
			 | 
			
				
			 | 
			
			
				-    echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				620
			 | 
			
				
			 | 
			
			
				-    echo "  listen 127.0.0.1:${TURTL_API_ONION_PORT};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				621
			 | 
			
				
			 | 
			
			
				-    echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				622
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				623
			 | 
			
				
			 | 
			
			
				-    function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				624
			 | 
			
				
			 | 
			
			
				-    nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				625
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				626
			 | 
			
				
			 | 
			
			
				-    echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				627
			 | 
			
				
			 | 
			
			
				-    echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				628
			 | 
			
				
			 | 
			
			
				-    echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				629
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				630
			 | 
			
				
			 | 
			
			
				-    echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				631
			 | 
			
				
			 | 
			
			
				-    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs/api;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				632
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				633
			 | 
			
				
			 | 
			
			
				-    echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				634
			 | 
			
				
			 | 
			
			
				-    function_check nginx_limits 
			 | 
		
	
		
			
			| 
				635
			 | 
			
				
			 | 
			
			
				-    nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				636
			 | 
			
				
			 | 
			
			
				-    echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				637
			 | 
			
				
			 | 
			
			
				-    echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				638
			 | 
			
				
			 | 
			
			
				-    echo '    proxy_buffering   off;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				639
			 | 
			
				
			 | 
			
			
				-    echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				640
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				641
			 | 
			
				
			 | 
			
			
				-    echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				642
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				643
			 | 
			
				
			 | 
			
			
				-    echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				644
			 | 
			
				
			 | 
			
			
				-    echo "  listen 127.0.0.1:$TURTL_ONION_PORT default_server;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				645
			 | 
			
				
			 | 
			
			
				-    echo "  server_name $TURTL_ONION_HOSTNAME;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				646
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				647
			 | 
			
				
			 | 
			
			
				-    echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				648
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				649
			 | 
			
				
			 | 
			
			
				-    function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				650
			 | 
			
				
			 | 
			
			
				-    nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				651
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				652
			 | 
			
				
			 | 
			
			
				-    echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				653
			 | 
			
				
			 | 
			
			
				-    echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				654
			 | 
			
				
			 | 
			
			
				-    echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				655
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				656
			 | 
			
				
			 | 
			
			
				-    echo '  # Root' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				657
			 | 
			
				
			 | 
			
			
				-    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				658
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				659
			 | 
			
				
			 | 
			
			
				-    echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				660
			 | 
			
				
			 | 
			
			
				-    function_check nginx_limits 
			 | 
		
	
		
			
			| 
				661
			 | 
			
				
			 | 
			
			
				-    nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				662
			 | 
			
				
			 | 
			
			
				-    echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				663
			 | 
			
				
			 | 
			
			
				-    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				664
			 | 
			
				
			 | 
			
			
				-    echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				665
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				666
			 | 
			
				
			 | 
			
			
				-    function_check create_site_certificate 
			 | 
		
	
		
			
			| 
				667
			 | 
			
				
			 | 
			
			
				-    create_site_certificate $TURTL_DOMAIN_NAME 'yes' 
			 | 
		
	
		
			
			| 
				668
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				669
			 | 
			
				
			 | 
			
			
				-    if [ -f /etc/ssl/certs/${TURTL_DOMAIN_NAME}.crt ]; then 
			 | 
		
	
		
			
			| 
				670
			 | 
			
				
			 | 
			
			
				-        mv /etc/ssl/certs/${TURTL_DOMAIN_NAME}.crt /etc/ssl/certs/${TURTL_DOMAIN_NAME}.pem 
			 | 
		
	
		
			
			| 
				671
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				672
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				673
			 | 
			
				
			 | 
			
			
				-    function_check nginx_ensite 
			 | 
		
	
		
			
			| 
				674
			 | 
			
				
			 | 
			
			
				-    nginx_ensite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				675
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				676
			 | 
			
				
			 | 
			
			
				-    if [[ $ONION_ONLY != 'no' ]]; then 
			 | 
		
	
		
			
			| 
				677
			 | 
			
				
			 | 
			
			
				-        sed -i "s|https://${TURTL_DOMAIN_NAME}|http://${TURTL_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				678
			 | 
			
				
			 | 
			
			
				-        sed -i "s|https://api.${TURTL_DOMAIN_NAME}|http://${TURTL_API_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/api/config/config.lisp 
			 | 
		
	
		
			
			| 
				679
			 | 
			
				
			 | 
			
			
				-        sed -i "s|https://${TURTL_DOMAIN_NAME}|http://${TURTL_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				680
			 | 
			
				
			 | 
			
			
				-        sed -i "s|https://api.${TURTL_DOMAIN_NAME}|http://${TURTL_API_ONION_HOSTNAME}|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				681
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				682
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				683
			 | 
			
				
			 | 
			
			
				-    ${PROJECT_NAME}-pass -u $MY_USERNAME -a turtl -p "$TURTL_ADMIN_PASSWORD" 
			 | 
		
	
		
			
			| 
				684
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				685
			 | 
			
				
			 | 
			
			
				-    function_check add_ddns_domain 
			 | 
		
	
		
			
			| 
				686
			 | 
			
				
			 | 
			
			
				-    add_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				687
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				688
			 | 
			
				
			 | 
			
			
				-    set_completion_param "turtl domain" "$TURTL_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				689
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				690
			 | 
			
				
			 | 
			
			
				-    systemctl enable turtl 
			 | 
		
	
		
			
			| 
				691
			 | 
			
				
			 | 
			
			
				-    systemctl daemon-reload 
			 | 
		
	
		
			
			| 
				692
			 | 
			
				
			 | 
			
			
				-    systemctl start turtl 
			 | 
		
	
		
			
			| 
				693
			 | 
			
				
			 | 
			
			
				-    systemctl restart nginx 
			 | 
		
	
		
			
			| 
				694
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				695
			 | 
			
				
			 | 
			
			
				-    APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+    function_check remove_onion_service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				300
			 | 
			
			
				+    remove_onion_service turtl ${TURTL_ONION_PORT} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				301
			 | 
			
			
				+    remove_onion_service turtlapi ${TURTL_API_ONION_PORT} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+    function_check remove_ddns_domain 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+    remove_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+    rm -rf /etc/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+    rm -rf /var/lib/rethinkdb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+    rm -rf $TURTL_BASE_DIR 
			 | 
		
	
		
			
			| 
				696
			 | 
			
				307
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				697
			 | 
			
				308
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				698
			 | 
			
				310
			 | 
			
			
				 function turtl_setup { 
			 | 
		
	
		
			
			| 
				699
			 | 
			
				311
			 | 
			
			
				     PIDFILE=${PIDFILE:-nil} 
			 | 
		
	
		
			
			| 
				700
			 | 
			
				312
			 | 
			
			
				     BINDADDR=${BINDADDR:-0.0.0.0} 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -896,7 +508,8 @@ __ENDCONFIG__ 
			 | 
		
	
		
			
			| 
				896
			 | 
			
				508
			 | 
			
			
				     git clone $TURTL_API_REPO $TURTL_BASE_DIR/api 
			 | 
		
	
		
			
			| 
				897
			 | 
			
				509
			 | 
			
			
				     cd $TURTL_BASE_DIR/api 
			 | 
		
	
		
			
			| 
				898
			 | 
			
				510
			 | 
			
			
				     git checkout $TURTL_API_COMMIT -b $TURTL_API_COMMIT 
			 | 
		
	
		
			
			| 
				899
			 | 
			
				
			 | 
			
			
				-    cd /root/quicklisp/local-projects 
			 | 
		
	
		
			
			| 
				
			 | 
			
				511
			 | 
			
			
				+    set_completion_param "turtl api commit" "$TURTL_API_COMMIT" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				512
			 | 
			
			
				+    cd $TURTL_BASE_DIR/quicklisp/local-projects 
			 | 
		
	
		
			
			| 
				900
			 | 
			
				513
			 | 
			
			
				     git clone git://github.com/orthecreedence/cl-hash-util 
			 | 
		
	
		
			
			| 
				901
			 | 
			
				514
			 | 
			
			
				     if [[ "$check_architecture" != *"arm"* ]]; then 
			 | 
		
	
		
			
			| 
				902
			 | 
			
				515
			 | 
			
			
				         if [[ "$check_architecture" == *"64"* ]]; then 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -933,14 +546,167 @@ __ENDCONFIG__ 
			 | 
		
	
		
			
			| 
				933
			 | 
			
				546
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				934
			 | 
			
				547
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				935
			 | 
			
				548
			 | 
			
			
				 function install_turtl_app { 
			 | 
		
	
		
			
			| 
				936
			 | 
			
				
			 | 
			
			
				-    echo -n '' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				549
			 | 
			
			
				+    function_check install_nodejs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				550
			 | 
			
			
				+    install_nodejs turtl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				551
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				552
			 | 
			
			
				+    if [ -d /var/www/$TURTL_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				553
			 | 
			
			
				+        rm -rf /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				554
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				555
			 | 
			
			
				+    mkdir -p /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				556
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				557
			 | 
			
			
				+    if [ -f $IMAGE_PASSWORD_FILE ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				558
			 | 
			
			
				+        TURTL_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				559
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				560
			 | 
			
			
				+        if [ ! $TURTL_ADMIN_PASSWORD ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				561
			 | 
			
			
				+            TURTL_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				562
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				563
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				564
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				565
			 | 
			
			
				+    cd /var/www/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				566
			 | 
			
			
				+    git_clone $TURTL_REPO /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				567
			 | 
			
			
				+    git checkout $TURTL_COMMIT -b $TURTL_COMMIT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				568
			 | 
			
			
				+    set_completion_param "turtl commit" "$TURTL_COMMIT" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				569
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				570
			 | 
			
			
				+    if [ ! -f /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				571
			 | 
			
			
				+        echo $'turtl app config file not found' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				572
			 | 
			
			
				+        exit 737223 
			 | 
		
	
		
			
			| 
				
			 | 
			
				573
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				574
			 | 
			
			
				+    cp /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js.default /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				575
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				576
			 | 
			
			
				+    # change settings 
			 | 
		
	
		
			
			| 
				
			 | 
			
				577
			 | 
			
			
				+    sed -i "s|api_url.*|api_url: 'https://api.${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				578
			 | 
			
			
				+    sed -i "s|site_url.*|api_url: 'https://${TURTL_DOMAIN_NAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				579
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				580
			 | 
			
			
				+    chown -R turtl:turtl /var/www/$TURTL_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				581
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				582
			 | 
			
			
				+    TURTL_ONION_HOSTNAME=$(add_onion_service turtl 80 ${TURTL_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				583
			 | 
			
			
				+    TURTL_API_ONION_HOSTNAME=$(add_onion_service turtlapi 80 ${TURTL_API_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				584
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				585
			 | 
			
			
				+    turtl_nginx_site=/etc/nginx/sites-available/$TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				586
			 | 
			
			
				+    if [[ $ONION_ONLY == "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				587
			 | 
			
			
				+        function_check nginx_http_redirect 
			 | 
		
	
		
			
			| 
				
			 | 
			
				588
			 | 
			
			
				+        nginx_http_redirect $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				589
			 | 
			
			
				+        echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				590
			 | 
			
			
				+        echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				591
			 | 
			
			
				+        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				592
			 | 
			
			
				+        echo "  server_name api.${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				593
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				594
			 | 
			
			
				+        echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				595
			 | 
			
			
				+        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				596
			 | 
			
			
				+        nginx_ssl $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				597
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				598
			 | 
			
			
				+        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				599
			 | 
			
			
				+        nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				600
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				601
			 | 
			
			
				+        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				602
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				603
			 | 
			
			
				+        echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				604
			 | 
			
			
				+        echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				605
			 | 
			
			
				+        echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				606
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				607
			 | 
			
			
				+        echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				608
			 | 
			
			
				+        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				609
			 | 
			
			
				+        nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				610
			 | 
			
			
				+        echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				611
			 | 
			
			
				+        echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				612
			 | 
			
			
				+        echo '    proxy_buffering   off;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				613
			 | 
			
			
				+        echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				614
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				615
			 | 
			
			
				+        echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				616
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				617
			 | 
			
			
				+        echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				618
			 | 
			
			
				+        echo '  listen 443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				619
			 | 
			
			
				+        echo '  listen [::]:443 ssl;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				620
			 | 
			
			
				+        echo "  server_name ${TURTL_DOMAIN_NAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				621
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				622
			 | 
			
			
				+        echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				623
			 | 
			
			
				+        echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				624
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				625
			 | 
			
			
				+        echo '  # Security' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				626
			 | 
			
			
				+        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				627
			 | 
			
			
				+        nginx_ssl $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				628
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				629
			 | 
			
			
				+        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				630
			 | 
			
			
				+        nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				631
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				632
			 | 
			
			
				+        echo '  add_header Strict-Transport-Security max-age=15768000;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				633
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				634
			 | 
			
			
				+        echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				635
			 | 
			
			
				+        echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				636
			 | 
			
			
				+        echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				637
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				638
			 | 
			
			
				+        echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				639
			 | 
			
			
				+        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				640
			 | 
			
			
				+        nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				641
			 | 
			
			
				+        echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				642
			 | 
			
			
				+        echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				643
			 | 
			
			
				+        echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				644
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				645
			 | 
			
			
				+        sed -i "s|api_url.*|api_url: 'http://${TURTL_API_ONION_HOSTNAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				646
			 | 
			
			
				+        sed -i "s|site_url.*|api_url: 'http://${TURTL_ONION_HOSTNAME}'|g" /var/www/$TURTL_DOMAIN_NAME/htdocs/config/config.js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				647
			 | 
			
			
				+        echo -n '' > $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				648
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				649
			 | 
			
			
				+    echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				650
			 | 
			
			
				+    echo "  listen 127.0.0.1:${TURTL_API_ONION_PORT};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				651
			 | 
			
			
				+    echo "  server_name ${TURTL_API_ONION_HOSTNAME};" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				652
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				653
			 | 
			
			
				+    function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				654
			 | 
			
			
				+    nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				655
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				656
			 | 
			
			
				+    echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				657
			 | 
			
			
				+    echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				658
			 | 
			
			
				+    echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				659
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				660
			 | 
			
			
				+    echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				661
			 | 
			
			
				+    function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				662
			 | 
			
			
				+    nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				663
			 | 
			
			
				+    echo "    proxy_pass        http://localhost:${TURTL_PORT}/;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				664
			 | 
			
			
				+    echo '    proxy_set_header  Host $host;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				665
			 | 
			
			
				+    echo '    proxy_buffering   off;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				666
			 | 
			
			
				+    echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				667
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				668
			 | 
			
			
				+    echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				669
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				670
			 | 
			
			
				+    echo 'server {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				671
			 | 
			
			
				+    echo "  listen 127.0.0.1:$TURTL_ONION_PORT default_server;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				672
			 | 
			
			
				+    echo "  server_name $TURTL_ONION_HOSTNAME;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				673
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				674
			 | 
			
			
				+    echo '  index index.html;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				675
			 | 
			
			
				+    echo "  root /var/www/$TURTL_DOMAIN_NAME/htdocs;" >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				676
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				677
			 | 
			
			
				+    function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				678
			 | 
			
			
				+    nginx_disable_sniffing $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				679
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				680
			 | 
			
			
				+    echo '  # Logs' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				681
			 | 
			
			
				+    echo '  access_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				682
			 | 
			
			
				+    echo '  error_log /dev/null;' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				683
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				684
			 | 
			
			
				+    echo '  location / {' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				685
			 | 
			
			
				+    function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				686
			 | 
			
			
				+    nginx_limits $TURTL_DOMAIN_NAME '15m' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				687
			 | 
			
			
				+    echo '  }' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				688
			 | 
			
			
				+    echo '' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				689
			 | 
			
			
				+    echo '}' >> $turtl_nginx_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				690
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				691
			 | 
			
			
				+    ${PROJECT_NAME}-pass -u $MY_USERNAME -a turtl -p "$TURTL_ADMIN_PASSWORD" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				692
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				693
			 | 
			
			
				+    function_check add_ddns_domain 
			 | 
		
	
		
			
			| 
				
			 | 
			
				694
			 | 
			
			
				+    add_ddns_domain $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				695
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				696
			 | 
			
			
				+    set_completion_param "turtl domain" "$TURTL_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				697
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				698
			 | 
			
			
				+    function_check create_site_certificate 
			 | 
		
	
		
			
			| 
				
			 | 
			
				699
			 | 
			
			
				+    create_site_certificate $TURTL_DOMAIN_NAME 'yes' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				700
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				701
			 | 
			
			
				+    function_check nginx_ensite 
			 | 
		
	
		
			
			| 
				
			 | 
			
				702
			 | 
			
			
				+    nginx_ensite $TURTL_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				703
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				704
			 | 
			
			
				+    systemctl restart nginx 
			 | 
		
	
		
			
			| 
				937
			 | 
			
				705
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				938
			 | 
			
				706
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				939
			 | 
			
				707
			 | 
			
			
				 function install_turtl { 
			 | 
		
	
		
			
			| 
				940
			 | 
			
				708
			 | 
			
			
				     install_turtl_api 
			 | 
		
	
		
			
			| 
				941
			 | 
			
				709
			 | 
			
			
				     install_turtl_app 
			 | 
		
	
		
			
			| 
				942
			 | 
			
				710
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				943
			 | 
			
				
			 | 
			
			
				-    #systemctl restart nginx 
			 | 
		
	
		
			
			| 
				944
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				945
			 | 
			
				711
			 | 
			
			
				     APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				946
			 | 
			
				712
			 | 
			
			
				 } 
			 |