| 
				
			 | 
			
			
				@@ -0,0 +1,583 @@ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1
			 | 
			
			
				+#!/bin/bash 
			 | 
		
	
		
			
			| 
				
			 | 
			
				2
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				3
			 | 
			
			
				+# .---.                  .              . 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				+# |                      |              | 
			 | 
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				6
			 | 
			
			
				+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				7
			 | 
			
			
				+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				8
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+#                    Freedom in the Cloud 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+# Friendica application 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				+# License 
			 | 
		
	
		
			
			| 
				
			 | 
			
				14
			 | 
			
			
				+# ======= 
			 | 
		
	
		
			
			| 
				
			 | 
			
				15
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				17
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				18
			 | 
			
			
				+# This program is free software: you can redistribute it and/or modify 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+# it under the terms of the GNU Affero General Public License as published by 
			 | 
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				+# the Free Software Foundation, either version 3 of the License, or 
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+# (at your option) any later version. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+# This program is distributed in the hope that it will be useful, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+# but WITHOUT ANY WARRANTY; without even the implied warranty of 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+# GNU Affero General Public License for more details. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+# 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+# You should have received a copy of the GNU Affero General Public License 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+VARIANTS='full full-vim social' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				+IN_DEFAULT_INSTALL=0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+SHOW_ON_ABOUT=1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+FRIENDICA_DOMAIN_NAME= 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+FRIENDICA_CODE= 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+FRIENDICA_ONION_PORT=8114 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+FRIENDICA_REPO="https://github.com/friendica/friendica" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+FRIENDICA_ADDONS_REPO="https://github.com/friendica/friendica-addons" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+FRIENDICA_ADMIN_PASSWORD= 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+FRIENDICA_COMMIT='b5a42c5b31fae5315bacd37769eba20ab2345aaa' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+FRIENDICA_ADDONS_COMMIT='7cb9dbdda7f227462895c07be3c968405561d40e' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+friendica_variables=(ONION_ONLY 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+                     FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+                     FRIENDICA_CODE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+                     DDNS_PROVIDER 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+                     MY_USERNAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+                     FRIENDICA_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+                     FRIENDICA_ADDONS_REPO) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+function remove_user_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    remove_username="$1" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+    ${PROJECT_NAME}-pass -u $remove_username --rmapp friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+function add_user_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+    if [[ $(app_is_installed friendica) == "0" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+        echo '0' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+    new_username="$1" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+    new_user_password="$2" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+    ${PROJECT_NAME}-pass -u $new_username -a friendica -p "$new_user_password" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+    echo '0' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+function friendica_renew_cert { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+    dialog --title $"Renew SSL certificate" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+           --backtitle $"Freedombone Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+           --yesno $"\nThis will renew a letsencrypt certificate. Select 'yes' to continue" 16 60 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+    sel=$? 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+    case $sel in 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+        1) return;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+        255) return;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+    esac 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+    FRIENDICA_DOMAIN_NAME=$(get_completion_param "friendica domain") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+    if [ ! -d /var/www/$FRIENDICA_DOMAIN_NAME/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+        dialog --title $"Renew SSL certificate" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+               --msgbox $"Friendica install directory not found" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+    ${PROJECT_NAME}-renew-cert -h $FRIENDICA_DOMAIN_NAME -p 'letsencrypt' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+    if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+        any_key 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+        dialog --title $"Renew SSL certificate" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+               --msgbox $"Friendica certificate has been renewed" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+function friendica_channel_directory_server { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+    if ! grep -q "friendica domain" $COMPLETION_FILE; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+        dialog --title $"Friendica channel directory server" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+               --msgbox $"Friendica is not installed on this system" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+    FRIENDICA_DOMAIN_NAME=$(get_completion_param "friendica domain") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    if [ ! -d /var/www/$FRIENDICA_DOMAIN_NAME/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+        dialog --title $"Friendica channel directory server" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+               --msgbox $"Friendica install directory not found" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+    data=$(tempfile 2>/dev/null) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+    trap "rm -f $data" 0 1 2 5 15 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+    dialog --title $"Friendica channel directory server" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+           --backtitle $"Freedombone Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+           --inputbox $"When you click on 'channel directory' this is where Friendica will obtain its list from" 8 60 2>$data 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+    sel=$? 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+    case $sel in 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+        0) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+            friendica_domain_server=$(<$data) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+            if [[ $friendica_domain_server != *"."* ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+                return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+            if [[ $friendica_domain_server != "https"* ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+                dialog --title $"Friendica channel directory server" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+                       --msgbox $"Invalid domain - include the https://" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				+                return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				+            ./var/www/$FRIENDICA_DOMAIN_NAME/htdocs/util/config system directory_server $friendica_domain_server 
			 | 
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				+            dialog --title $"Friendica channel directory server" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				126
			 | 
			
			
				+                   --msgbox $"Domain channel directory server changed to $friendica_domain_server" 6 40 
			 | 
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				+            ;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				+    esac 
			 | 
		
	
		
			
			| 
				
			 | 
			
				129
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				130
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				131
			 | 
			
			
				+function configure_interactive_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+    while true 
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+    do 
			 | 
		
	
		
			
			| 
				
			 | 
			
				134
			 | 
			
			
				+        data=$(tempfile 2>/dev/null) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				135
			 | 
			
			
				+        trap "rm -f $data" 0 1 2 5 15 
			 | 
		
	
		
			
			| 
				
			 | 
			
				136
			 | 
			
			
				+        dialog --backtitle $"Freedombone Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				137
			 | 
			
			
				+               --title $"Friendica" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				138
			 | 
			
			
				+               --radiolist $"Choose an operation:" 13 70 4 \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				139
			 | 
			
			
				+               1 $"Set channel directory server" off \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				+               2 $"Renew SSL certificate" off \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				+               3 $"Back to main menu" on 2> $data 
			 | 
		
	
		
			
			| 
				
			 | 
			
				142
			 | 
			
			
				+        sel=$? 
			 | 
		
	
		
			
			| 
				
			 | 
			
				143
			 | 
			
			
				+        case $sel in 
			 | 
		
	
		
			
			| 
				
			 | 
			
				144
			 | 
			
			
				+            1) break;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				+            255) break;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				146
			 | 
			
			
				+        esac 
			 | 
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				+        case $(cat $data) in 
			 | 
		
	
		
			
			| 
				
			 | 
			
				148
			 | 
			
			
				+            1) friendica_channel_directory_server;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				149
			 | 
			
			
				+            2) friendica_renew_cert;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				150
			 | 
			
			
				+            3) break;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				151
			 | 
			
			
				+        esac 
			 | 
		
	
		
			
			| 
				
			 | 
			
				152
			 | 
			
			
				+    done 
			 | 
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				+function install_interactive_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				+    if [[ $ONION_ONLY != "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				159
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				160
			 | 
			
			
				+    function_check interactive_site_details 
			 | 
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				+    interactive_site_details friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				163
			 | 
			
			
				+    APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				164
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				165
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				166
			 | 
			
			
				+function change_password_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				167
			 | 
			
			
				+    FRIENDICA_USERNAME="$1" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				168
			 | 
			
			
				+    FRIENDICA_PASSWORD="$2" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				169
			 | 
			
			
				+    if [ ${#FRIENDICA_PASSWORD} -lt 8 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				170
			 | 
			
			
				+        echo $'Friendica password is too short' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				171
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				172
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				173
			 | 
			
			
				+    # TODO: This doesn't actually change the password 
			 | 
		
	
		
			
			| 
				
			 | 
			
				174
			 | 
			
			
				+    #${PROJECT_NAME}-pass -u $FRIENDICA_USERNAME -a friendica -p "$FRIENDICA_PASSWORD" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				175
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				176
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				177
			 | 
			
			
				+function friendica_create_database { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				178
			 | 
			
			
				+    if [ -f $IMAGE_PASSWORD_FILE ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				179
			 | 
			
			
				+        FRIENDICA_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				180
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				181
			 | 
			
			
				+    if [ ! $FRIENDICA_ADMIN_PASSWORD ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				182
			 | 
			
			
				+        FRIENDICA_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				183
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				184
			 | 
			
			
				+    ${PROJECT_NAME}-pass -u $MY_USERNAME -a friendica -p "$FRIENDICA_ADMIN_PASSWORD" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				185
			 | 
			
			
				+    if [ ! $FRIENDICA_ADMIN_PASSWORD ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				186
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				187
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				188
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				189
			 | 
			
			
				+    function_check create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				190
			 | 
			
			
				+    create_database friendica "$FRIENDICA_ADMIN_PASSWORD" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				191
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				192
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				193
			 | 
			
			
				+function reconfigure_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				194
			 | 
			
			
				+    echo -n '' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				196
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				197
			 | 
			
			
				+function upgrade_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				198
			 | 
			
			
				+    FRIENDICA_PATH=/var/www/$FRIENDICA_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				199
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				200
			 | 
			
			
				+    function_check set_repo_commit 
			 | 
		
	
		
			
			| 
				
			 | 
			
				201
			 | 
			
			
				+    set_repo_commit $FRIENDICA_PATH "friendica commit" "$FRIENDICA_COMMIT" $FRIENDICA_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				202
			 | 
			
			
				+    set_repo_commit $FRIENDICA_PATH/addon "friendica addons commit" "$FRIENDICA_ADDONS_COMMIT" $FRIENDICA_ADDONS_REPO 
			 | 
		
	
		
			
			| 
				
			 | 
			
				203
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				204
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				205
			 | 
			
			
				+function backup_local_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				206
			 | 
			
			
				+    friendica_path=/var/www/${FRIENDICA_DOMAIN_NAME}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				207
			 | 
			
			
				+    if [ -d $friendica_path ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				208
			 | 
			
			
				+        function_check backup_database_to_usb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				209
			 | 
			
			
				+        backup_database_to_usb friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				210
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				211
			 | 
			
			
				+        backup_directory_to_usb $friendica_path friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				212
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				213
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				214
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				215
			 | 
			
			
				+function restore_local_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				216
			 | 
			
			
				+    temp_restore_dir=/root/tempfriendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				217
			 | 
			
			
				+    friendica_dir=/var/www/${FRIENDICA_DOMAIN_NAME}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				218
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				219
			 | 
			
			
				+    function_check friendica_create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				220
			 | 
			
			
				+    friendica_create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				221
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				222
			 | 
			
			
				+    restore_database friendica ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				223
			 | 
			
			
				+    if [ -d $USB_MOUNT/backup/friendica ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				224
			 | 
			
			
				+        if [ ! -d $friendica_dir/store/[data]/smarty3 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				225
			 | 
			
			
				+            mkdir -p $friendica_dir/store/[data]/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				226
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				227
			 | 
			
			
				+        chmod 777 $friendica_dir/store/[data]/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				228
			 | 
			
			
				+        chown -R www-data:www-data $friendica_dir/* 
			 | 
		
	
		
			
			| 
				
			 | 
			
				229
			 | 
			
			
				+        if [ -d $temp_restore_dir ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				230
			 | 
			
			
				+            rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				
			 | 
			
				231
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				232
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				233
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				234
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				235
			 | 
			
			
				+function backup_remote_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				236
			 | 
			
			
				+    temp_backup_dir=/var/www/${FRIENDICA_DOMAIN_NAME}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				237
			 | 
			
			
				+    if [ -d $temp_backup_dir ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				238
			 | 
			
			
				+        suspend_site ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				239
			 | 
			
			
				+        backup_database_to_friend friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				240
			 | 
			
			
				+        echo "Backing up Friendica installation" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				241
			 | 
			
			
				+        backup_directory_to_friend $temp_backup_dir friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				242
			 | 
			
			
				+        restart_site 
			 | 
		
	
		
			
			| 
				
			 | 
			
				243
			 | 
			
			
				+        echo "Backup of Friendica complete" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				244
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				245
			 | 
			
			
				+        echo $"Friendica domain specified but not found in /var/www/${FRIENDICA_DOMAIN_NAME}" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				246
			 | 
			
			
				+        exit 2578 
			 | 
		
	
		
			
			| 
				
			 | 
			
				247
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				248
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				249
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				250
			 | 
			
			
				+function restore_remote_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				251
			 | 
			
			
				+    function_check restore_database_from_friend 
			 | 
		
	
		
			
			| 
				
			 | 
			
				252
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				253
			 | 
			
			
				+    function_check friendica_create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				254
			 | 
			
			
				+    friendica_create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				255
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				256
			 | 
			
			
				+    restore_database_from_friend friendica ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				257
			 | 
			
			
				+    if [ -d $SERVER_DIRECTORY/backup/friendica ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				258
			 | 
			
			
				+        if [ ! -d /var/www/${FRIENDICA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				259
			 | 
			
			
				+            mkdir -p /var/www/${FRIENDICA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				260
			 | 
			
			
				+        fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				261
			 | 
			
			
				+        chmod 777 /var/www/${FRIENDICA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				262
			 | 
			
			
				+        chown -R www-data:www-data /var/www/${FRIENDICA_DOMAIN_NAME}/htdocs/* 
			 | 
		
	
		
			
			| 
				
			 | 
			
				263
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				264
			 | 
			
			
				+    if [ -d /root/tempfriendica ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				265
			 | 
			
			
				+        rm -rf /root/tempfriendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				266
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				267
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				268
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				269
			 | 
			
			
				+function remove_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				270
			 | 
			
			
				+    if [ ${#FRIENDICA_DOMAIN_NAME} -eq 0 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				271
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				272
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				273
			 | 
			
			
				+    nginx_dissite $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				274
			 | 
			
			
				+    remove_certs ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				275
			 | 
			
			
				+    if [ -d /var/www/$FRIENDICA_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				276
			 | 
			
			
				+        rm -rf /var/www/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				277
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				278
			 | 
			
			
				+    if [ -f /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				279
			 | 
			
			
				+        rm /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				280
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				281
			 | 
			
			
				+    function_check drop_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				282
			 | 
			
			
				+    drop_database friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				283
			 | 
			
			
				+    function_check remove_onion_service 
			 | 
		
	
		
			
			| 
				
			 | 
			
				284
			 | 
			
			
				+    remove_onion_service friendica ${FRIENDICA_ONION_PORT} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				285
			 | 
			
			
				+    sed -i '/friendica/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				286
			 | 
			
			
				+    sed -i '/poller.php/d' /etc/crontab 
			 | 
		
	
		
			
			| 
				
			 | 
			
				287
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				288
			 | 
			
			
				+    function_check remove_ddns_domain 
			 | 
		
	
		
			
			| 
				
			 | 
			
				289
			 | 
			
			
				+    remove_ddns_domain $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				290
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				291
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				292
			 | 
			
			
				+function install_friendica { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				293
			 | 
			
			
				+    if [ ! $FRIENDICA_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				294
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				295
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				296
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				297
			 | 
			
			
				+    if [[ $ONION_ONLY != "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				298
			 | 
			
			
				+        return 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				300
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				301
			 | 
			
			
				+    FRIENDICA_PATH=/var/www/$FRIENDICA_DOMAIN_NAME/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+    function_check install_mariadb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+    install_mariadb 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+    function_check get_mariadb_password 
			 | 
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				+    get_mariadb_password 
			 | 
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				+    function_check repair_databases_script 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+    repair_databases_script 
			 | 
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				+    apt-get -yq install php5-common php5-cli php5-curl php5-gd php5-mysql php5-mcrypt git 
			 | 
		
	
		
			
			| 
				
			 | 
			
				313
			 | 
			
			
				+    apt-get -yq install php5-dev imagemagick php5-imagick 
			 | 
		
	
		
			
			| 
				
			 | 
			
				314
			 | 
			
			
				+    apt-get -yq install php5-memcached 
			 | 
		
	
		
			
			| 
				
			 | 
			
				315
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				316
			 | 
			
			
				+    if [ ! -d /var/www/$FRIENDICA_DOMAIN_NAME ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				317
			 | 
			
			
				+        mkdir /var/www/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				318
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				319
			 | 
			
			
				+    if [ ! -d $FRIENDICA_PATH ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				320
			 | 
			
			
				+        mkdir $FRIENDICA_PATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				321
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				322
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				323
			 | 
			
			
				+    if [ ! -f $FRIENDICA_PATH/index.php ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				324
			 | 
			
			
				+        cd $INSTALL_DIR 
			 | 
		
	
		
			
			| 
				
			 | 
			
				325
			 | 
			
			
				+        function_check git_clone 
			 | 
		
	
		
			
			| 
				
			 | 
			
				326
			 | 
			
			
				+        git_clone $FRIENDICA_REPO friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				327
			 | 
			
			
				+        git checkout $FRIENDICA_COMMIT -b $FRIENDICA_COMMIT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				328
			 | 
			
			
				+        set_completion_param "friendica commit" "$FRIENDICA_COMMIT" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				329
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				330
			 | 
			
			
				+        rm -rf $FRIENDICA_PATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				331
			 | 
			
			
				+        mv friendica $FRIENDICA_PATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				332
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				333
			 | 
			
			
				+        git_clone $FRIENDICA_ADDONS_REPO $FRIENDICA_PATH/addon 
			 | 
		
	
		
			
			| 
				
			 | 
			
				334
			 | 
			
			
				+        cd $FRIENDICA_PATH/addon 
			 | 
		
	
		
			
			| 
				
			 | 
			
				335
			 | 
			
			
				+        git checkout $FRIENDICA_ADDONS_COMMIT -b $FRIENDICA_ADDONS_COMMIT 
			 | 
		
	
		
			
			| 
				
			 | 
			
				336
			 | 
			
			
				+        set_completion_param "friendica addons commit" "$FRIENDICA_ADDONS_COMMIT" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				337
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				338
			 | 
			
			
				+        chown -R www-data:www-data $FRIENDICA_PATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				339
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				340
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				341
			 | 
			
			
				+    FRIENDICA_ONION_HOSTNAME= 
			 | 
		
	
		
			
			| 
				
			 | 
			
				342
			 | 
			
			
				+    if [[ $ONION_ONLY != "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				343
			 | 
			
			
				+        FRIENDICA_ONION_HOSTNAME=$(add_onion_service friendica 80 ${FRIENDICA_ONION_PORT}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				345
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				346
			 | 
			
			
				+    friendica_create_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				347
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				348
			 | 
			
			
				+    if ! grep -q "$FRIENDICA_PATH" /etc/crontab; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				349
			 | 
			
			
				+        echo "12,22,32,42,52 * *   *   *   root cd $FRIENDICA_PATH; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab 
			 | 
		
	
		
			
			| 
				
			 | 
			
				350
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				351
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				352
			 | 
			
			
				+    function_check add_ddns_domain 
			 | 
		
	
		
			
			| 
				
			 | 
			
				353
			 | 
			
			
				+    add_ddns_domain $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				354
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				355
			 | 
			
			
				+    if [[ $ONION_ONLY == "no" ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				356
			 | 
			
			
				+        function_check nginx_http_redirect 
			 | 
		
	
		
			
			| 
				
			 | 
			
				357
			 | 
			
			
				+        nginx_http_redirect $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				358
			 | 
			
			
				+        echo 'server {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				359
			 | 
			
			
				+        echo '    listen 443 ssl;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				360
			 | 
			
			
				+        echo '    listen [::]:443 ssl;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				361
			 | 
			
			
				+        echo "    root $FRIENDICA_PATH;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				362
			 | 
			
			
				+        echo "    server_name $FRIENDICA_DOMAIN_NAME;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				363
			 | 
			
			
				+        echo "    error_log /dev/null;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				364
			 | 
			
			
				+        echo '    index index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				365
			 | 
			
			
				+        echo '    charset utf-8;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				366
			 | 
			
			
				+        echo '    access_log /dev/null;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				367
			 | 
			
			
				+        function_check nginx_ssl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				368
			 | 
			
			
				+        nginx_ssl $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				369
			 | 
			
			
				+        function_check nginx_disable_sniffing 
			 | 
		
	
		
			
			| 
				
			 | 
			
				370
			 | 
			
			
				+        nginx_disable_sniffing $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				371
			 | 
			
			
				+        echo '    add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				372
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				373
			 | 
			
			
				+        echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				374
			 | 
			
			
				+        echo '    location / {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				375
			 | 
			
			
				+        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				376
			 | 
			
			
				+        nginx_limits $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				377
			 | 
			
			
				+        echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				378
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				379
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				380
			 | 
			
			
				+        nginx_keybase ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				381
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				382
			 | 
			
			
				+        echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				383
			 | 
			
			
				+        echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				384
			 | 
			
			
				+        echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				385
			 | 
			
			
				+        echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				386
			 | 
			
			
				+        echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				387
			 | 
			
			
				+        echo '        expires 30d;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				388
			 | 
			
			
				+        echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				389
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				390
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				391
			 | 
			
			
				+        echo '    # block these file types' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				392
			 | 
			
			
				+        echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				393
			 | 
			
			
				+        echo '        deny all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				394
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				395
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				396
			 | 
			
			
				+        echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				397
			 | 
			
			
				+        echo '    # or a unix socket' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				398
			 | 
			
			
				+        echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				399
			 | 
			
			
				+        function_check nginx_limits 
			 | 
		
	
		
			
			| 
				
			 | 
			
				400
			 | 
			
			
				+        nginx_limits $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				401
			 | 
			
			
				+        echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				402
			 | 
			
			
				+        echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				403
			 | 
			
			
				+        echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				404
			 | 
			
			
				+        echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				405
			 | 
			
			
				+        echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				406
			 | 
			
			
				+        echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				407
			 | 
			
			
				+        echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				408
			 | 
			
			
				+        echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				409
			 | 
			
			
				+        echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				410
			 | 
			
			
				+        echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				411
			 | 
			
			
				+        echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				412
			 | 
			
			
				+        echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				413
			 | 
			
			
				+        echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				414
			 | 
			
			
				+        echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				415
			 | 
			
			
				+        echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				416
			 | 
			
			
				+        echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				417
			 | 
			
			
				+        echo '        fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				418
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				419
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				420
			 | 
			
			
				+        echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				421
			 | 
			
			
				+        echo '    location ~ /\. {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				422
			 | 
			
			
				+        echo '        deny all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				423
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				424
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				425
			 | 
			
			
				+        echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				426
			 | 
			
			
				+        echo '      deny  all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				427
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				428
			 | 
			
			
				+        echo '}' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				429
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				430
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				431
			 | 
			
			
				+        echo 'server {' > /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				432
			 | 
			
			
				+        echo "    listen 127.0.0.1:${FRIENDICA_ONION_PORT} default_server;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				433
			 | 
			
			
				+        echo "    root $FRIENDICA_PATH;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				434
			 | 
			
			
				+        echo "    server_name $FRIENDICA_ONION_HOSTNAME;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				435
			 | 
			
			
				+        echo "    error_log /dev/null;" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				436
			 | 
			
			
				+        echo '    index index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				437
			 | 
			
			
				+        echo '    charset utf-8;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				438
			 | 
			
			
				+        echo '    access_log /dev/null;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				439
			 | 
			
			
				+        echo '    add_header Strict-Transport-Security max-age=15768000;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				440
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				441
			 | 
			
			
				+        echo '    # rewrite to front controller as default rule' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				442
			 | 
			
			
				+        echo '    location / {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				443
			 | 
			
			
				+        nginx_limits $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				444
			 | 
			
			
				+        nginx_disable_sniffing $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				445
			 | 
			
			
				+        echo '        rewrite ^/(.*) /index.php?q=$uri&$args last;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				446
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				447
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				448
			 | 
			
			
				+        nginx_keybase ${FRIENDICA_DOMAIN_NAME} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				449
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				450
			 | 
			
			
				+        echo '    # statically serve these file types when possible' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				451
			 | 
			
			
				+        echo '    # otherwise fall back to front controller' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				452
			 | 
			
			
				+        echo '    # allow browser to cache them' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				453
			 | 
			
			
				+        echo '    # added .htm for advanced source code editor library' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				454
			 | 
			
			
				+        echo '    location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				455
			 | 
			
			
				+        echo '        expires 30d;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				456
			 | 
			
			
				+        echo '        try_files $uri /index.php?q=$uri&$args;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				457
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				458
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				459
			 | 
			
			
				+        echo '    # block these file types' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				460
			 | 
			
			
				+        echo '    location ~* \.(tpl|md|tgz|log|out)$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				461
			 | 
			
			
				+        echo '        deny all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				462
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				463
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				464
			 | 
			
			
				+        echo '    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				465
			 | 
			
			
				+        echo '    # or a unix socket' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				466
			 | 
			
			
				+        echo '    location ~* \.php$ {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				467
			 | 
			
			
				+        nginx_limits $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				468
			 | 
			
			
				+        nginx_disable_sniffing $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				469
			 | 
			
			
				+        echo '        # Zero-day exploit defense.' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				470
			 | 
			
			
				+        echo '        # http://forum.nginx.org/read.php?2,88845,page=3' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				471
			 | 
			
			
				+        echo "        # Won't work properly (404 error) if the file is not stored on this" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				472
			 | 
			
			
				+        echo "        # server, which is entirely possible with php-fpm/php-fcgi." >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				473
			 | 
			
			
				+        echo "        # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on" >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				474
			 | 
			
			
				+        echo "        # another machine. And then cross your fingers that you won't get hacked." >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				475
			 | 
			
			
				+        echo '        try_files $uri $uri/ /index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				476
			 | 
			
			
				+        echo '        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				477
			 | 
			
			
				+        echo '        fastcgi_split_path_info ^(.+\.php)(/.+)$;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				478
			 | 
			
			
				+        echo '        # With php5-cgi alone:' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				479
			 | 
			
			
				+        echo '        # fastcgi_pass 127.0.0.1:9000;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				480
			 | 
			
			
				+        echo '        # With php5-fpm:' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				481
			 | 
			
			
				+        echo '        fastcgi_pass unix:/var/run/php5-fpm.sock;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				482
			 | 
			
			
				+        echo '        include fastcgi_params;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				483
			 | 
			
			
				+        echo '        fastcgi_index index.php;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				484
			 | 
			
			
				+        echo '        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				485
			 | 
			
			
				+        echo '        fastcgi_read_timeout 300;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				486
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				487
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				488
			 | 
			
			
				+        echo '    # deny access to all dot files' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				489
			 | 
			
			
				+        echo '    location ~ /\. {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				490
			 | 
			
			
				+        echo '        deny all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				491
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				492
			 | 
			
			
				+        echo '' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				493
			 | 
			
			
				+        echo '    location ~ /\.ht {' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				494
			 | 
			
			
				+        echo '      deny  all;' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				495
			 | 
			
			
				+        echo '    }' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				496
			 | 
			
			
				+        echo '}' >> /etc/nginx/sites-available/$FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				497
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				498
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				499
			 | 
			
			
				+    function_check configure_php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				500
			 | 
			
			
				+    configure_php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				501
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				502
			 | 
			
			
				+    function_check create_site_certificate 
			 | 
		
	
		
			
			| 
				
			 | 
			
				503
			 | 
			
			
				+    create_site_certificate $FRIENDICA_DOMAIN_NAME 'yes' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				504
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				505
			 | 
			
			
				+    if [ ! -d $FRIENDICA_PATH/view/tpl/smarty3 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				506
			 | 
			
			
				+        mkdir $FRIENDICA_PATH/view/tpl/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				507
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				508
			 | 
			
			
				+    if [ ! -d "$FRIENDICA_PATH/store" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				509
			 | 
			
			
				+        mkdir "$FRIENDICA_PATH/store" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				510
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				511
			 | 
			
			
				+    if [ ! -d "$FRIENDICA_PATH/store/[data]" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				512
			 | 
			
			
				+        mkdir "$FRIENDICA_PATH/store/[data]" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				513
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				514
			 | 
			
			
				+    if [ ! -d "$FRIENDICA_PATH/store/[data]/smarty3" ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				515
			 | 
			
			
				+        mkdir "$FRIENDICA_PATH/store/[data]/smarty3" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				516
			 | 
			
			
				+        chmod 777 "$FRIENDICA_PATH/store/[data]/smarty3" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				517
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				518
			 | 
			
			
				+    chmod 777 $FRIENDICA_PATH/view/tpl 
			 | 
		
	
		
			
			| 
				
			 | 
			
				519
			 | 
			
			
				+    chown -R www-data:www-data "$FRIENDICA_PATH/store" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				520
			 | 
			
			
				+    chmod 777 $FRIENDICA_PATH/view/tpl/smarty3 
			 | 
		
	
		
			
			| 
				
			 | 
			
				521
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				522
			 | 
			
			
				+    # Ensure that the database gets backed up locally, if remote 
			 | 
		
	
		
			
			| 
				
			 | 
			
				523
			 | 
			
			
				+    # backups are not being used 
			 | 
		
	
		
			
			| 
				
			 | 
			
				524
			 | 
			
			
				+    function_check backup_databases_script_header 
			 | 
		
	
		
			
			| 
				
			 | 
			
				525
			 | 
			
			
				+    backup_databases_script_header 
			 | 
		
	
		
			
			| 
				
			 | 
			
				526
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				527
			 | 
			
			
				+    function_check backup_database_local 
			 | 
		
	
		
			
			| 
				
			 | 
			
				528
			 | 
			
			
				+    backup_database_local friendica 
			 | 
		
	
		
			
			| 
				
			 | 
			
				529
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				530
			 | 
			
			
				+    chown -R www-data:www-data $FRIENDICA_PATH 
			 | 
		
	
		
			
			| 
				
			 | 
			
				531
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				532
			 | 
			
			
				+    function_check nginx_ensite 
			 | 
		
	
		
			
			| 
				
			 | 
			
				533
			 | 
			
			
				+    nginx_ensite $FRIENDICA_DOMAIN_NAME 
			 | 
		
	
		
			
			| 
				
			 | 
			
				534
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				535
			 | 
			
			
				+    # initialize the database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				536
			 | 
			
			
				+    if [ ! -f $FRIENDICA_PATH/install/schema_mysql.sql ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				537
			 | 
			
			
				+        echo $'No database schema found for friendica' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				538
			 | 
			
			
				+        exit 252782 
			 | 
		
	
		
			
			| 
				
			 | 
			
				539
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				540
			 | 
			
			
				+    function_check initialise_database 
			 | 
		
	
		
			
			| 
				
			 | 
			
				541
			 | 
			
			
				+    initialise_database friendica $FRIENDICA_PATH/install/schema_mysql.sql 
			 | 
		
	
		
			
			| 
				
			 | 
			
				542
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				543
			 | 
			
			
				+    # create the config file 
			 | 
		
	
		
			
			| 
				
			 | 
			
				544
			 | 
			
			
				+    echo '<?php' > $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				545
			 | 
			
			
				+    echo "\$db_host = 'localhost';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				546
			 | 
			
			
				+    echo "\$db_user = 'root';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				547
			 | 
			
			
				+    echo "\$db_pass = '${MARIADB_PASSWORD}';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				548
			 | 
			
			
				+    echo "\$db_data = 'friendica';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				549
			 | 
			
			
				+    echo "\$default_timezone = 'Europe/London';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				550
			 | 
			
			
				+    if [[ $ONION_ONLY == 'no' ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				551
			 | 
			
			
				+        echo "\$a->config['system']['baseurl'] = 'https://${FRIENDICA_DOMAIN_NAME}';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				552
			 | 
			
			
				+    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				553
			 | 
			
			
				+        echo "\$a->config['system']['baseurl'] = 'http://${FRIENDICA_ONION_HOSTNAME}';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				554
			 | 
			
			
				+    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				555
			 | 
			
			
				+    echo "\$a->config['system']['sitename'] = \"Friendica\";" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				556
			 | 
			
			
				+    echo "\$a->config['system']['register_policy'] = REGISTER_OPEN;" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				557
			 | 
			
			
				+    echo "\$a->config['system']['register_text'] = '';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				558
			 | 
			
			
				+    echo "\$a->config['system']['admin_email'] = '${MY_EMAIL_ADDRESS}';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				559
			 | 
			
			
				+    echo "\$a->config['system']['no_regfullname'] = true;" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				560
			 | 
			
			
				+    echo "\$a->config['system']['max_import_size'] = 200000;" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				561
			 | 
			
			
				+    echo "$a->config['system']['maximagesize'] = 800000;" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				562
			 | 
			
			
				+    echo "\$a->config['system']['php_path'] = '/usr/bin/php';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				563
			 | 
			
			
				+    echo "\$a->config['system']['directory'] = 'http://dir.friendi.ca';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				564
			 | 
			
			
				+    echo "\$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero,smoothly';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				565
			 | 
			
			
				+    echo "\$a->config['system']['theme'] = 'vier';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				566
			 | 
			
			
				+    echo "\$a->config['system']['huburl'] = '[internal]';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				567
			 | 
			
			
				+    echo "\$a->config['system']['language'] = 'en';" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				568
			 | 
			
			
				+    echo "\$a->config['system']['rino_encrypt'] = 2;" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				569
			 | 
			
			
				+    echo "\$a->config['system']['allowed_link_protocols'] = array('mailto', 'cid');" >> $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				570
			 | 
			
			
				+    chown www-data:www-data $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				571
			 | 
			
			
				+    chmod 755 $FRIENDICA_PATH/.htconfig.php 
			 | 
		
	
		
			
			| 
				
			 | 
			
				572
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				573
			 | 
			
			
				+    systemctl restart php5-fpm 
			 | 
		
	
		
			
			| 
				
			 | 
			
				574
			 | 
			
			
				+    systemctl restart nginx 
			 | 
		
	
		
			
			| 
				
			 | 
			
				575
			 | 
			
			
				+    systemctl restart cron 
			 | 
		
	
		
			
			| 
				
			 | 
			
				576
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				577
			 | 
			
			
				+    ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$FRIENDICA_DOMAIN_NAME" -g friendica --public no 
			 | 
		
	
		
			
			| 
				
			 | 
			
				578
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				579
			 | 
			
			
				+    set_completion_param "friendica domain" "${FRIENDICA_DOMAIN_NAME}" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				580
			 | 
			
			
				+    APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				581
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				582
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				583
			 | 
			
			
				+# NOTE: deliberately there is no "exit 0" 
			 |