Browse Source

Add xmpp address to email headers

Bob Mottram 8 years ago
parent
commit
0df2c9ca7a
3 changed files with 497 additions and 476 deletions
  1. 61
    61
      src/freedombone-adduser
  2. 22
    15
      src/freedombone-addxmpp
  3. 414
    400
      src/freedombone-app-xmpp

+ 61
- 61
src/freedombone-adduser View File

@@ -75,30 +75,30 @@ fi
75 75
 
76 76
 if [ "$SSH_PUBLIC_KEY" ]; then
77 77
     if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
78
-	if [ -f "$SSH_PUBLIC_KEY" ]; then
79
-	    mkdir /home/$MY_USERNAME/.ssh
80
-	    cp $SSH_PUBLIC_KEY /home/$MY_USERNAME/.ssh/authorized_keys
81
-	    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
82
-	    echo $'ssh public key installed'
83
-	else
84
-	    if [[ "$SSH_PUBLIC_KEY" == "ssh-"* ]]; then
85
-		mkdir /home/$MY_USERNAME/.ssh
86
-		echo "$SSH_PUBLIC_KEY" > /home/$MY_USERNAME/.ssh/authorized_keys
87
-		chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
88
-		echo $'ssh public key installed'
89
-	    else
90
-		echo $'The second parameter does not look like an ssh key'
91
-		exit 5
92
-	    fi
93
-	fi
78
+        if [ -f "$SSH_PUBLIC_KEY" ]; then
79
+            mkdir /home/$MY_USERNAME/.ssh
80
+            cp $SSH_PUBLIC_KEY /home/$MY_USERNAME/.ssh/authorized_keys
81
+            chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
82
+            echo $'ssh public key installed'
83
+        else
84
+            if [[ "$SSH_PUBLIC_KEY" == "ssh-"* ]]; then
85
+                mkdir /home/$MY_USERNAME/.ssh
86
+                echo "$SSH_PUBLIC_KEY" > /home/$MY_USERNAME/.ssh/authorized_keys
87
+                chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
88
+                echo $'ssh public key installed'
89
+            else
90
+                echo $'The second parameter does not look like an ssh key'
91
+                exit 5
92
+            fi
93
+        fi
94 94
     fi
95 95
 fi
96 96
 
97 97
 if [ -d /home/$MY_USERNAME/Maildir ]; then
98 98
     if grep -q "set from=" /home/$MY_USERNAME/.muttrc; then
99
-	sed -i "s|set from=.*|set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'|g" /home/$MY_USERNAME/.muttrc
99
+        sed -i "s|set from=.*|set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'|g" /home/$MY_USERNAME/.muttrc
100 100
     else
101
-	echo "set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'" >> /home/$MY_USERNAME/.muttrc
101
+        echo "set from='$MY_USERNAME <$MY_USERNAME@$HOSTNAME>'" >> /home/$MY_USERNAME/.muttrc
102 102
     fi
103 103
 
104 104
     USERN='$USER@'
@@ -154,17 +154,17 @@ monkeysphere-authentication update-users
154 154
 if [ -f /home/$MY_USERNAME/.muttrc ]; then
155 155
     # encrypt outgoing mail to the "sent" folder
156 156
     if ! grep -q "pgp_encrypt_only_command" /home/$MY_USERNAME/.muttrc; then
157
-	echo '' >> /home/$MY_USERNAME/.muttrc
158
-	echo $'# Encrypt items in the Sent folder' >> /home/$MY_USERNAME/.muttrc
159
-	echo "set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc
157
+        echo '' >> /home/$MY_USERNAME/.muttrc
158
+        echo $'# Encrypt items in the Sent folder' >> /home/$MY_USERNAME/.muttrc
159
+        echo "set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc
160 160
     else
161
-	sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
161
+        sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
162 162
     fi
163 163
 
164 164
     if ! grep -q "pgp_encrypt_sign_command" /home/$MY_USERNAME/.muttrc; then
165
-	echo "set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc
165
+        echo "set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"" >> /home/$MY_USERNAME/.muttrc
166 166
     else
167
-	sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
167
+        sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x$MY_GPG_PUBLIC_KEY_ID -- -r %r -- %f\"|g" /home/$MY_USERNAME/.muttrc
168 168
     fi
169 169
 fi
170 170
 
@@ -203,9 +203,9 @@ if grep -q "install_xmpp" $COMPLETION_FILE; then
203 203
     echo $"Adding an XMPP account for $MY_USERNAME"
204 204
     ${PROJECT_NAME}-addxmpp -e "$MY_USERNAME@$HOSTNAME" -p "$NEW_USER_PASSWORD"
205 205
     if [ ! "$?" = "0" ]; then
206
-	echo $"XMPP account not created"
207
-	userdel -r $MY_USERNAME
208
-	exit 8
206
+        echo $"XMPP account not created"
207
+        userdel -r $MY_USERNAME
208
+        exit 8
209 209
     fi
210 210
 fi
211 211
 
@@ -214,10 +214,10 @@ if grep -q "install_xmpp_client" $COMPLETION_FILE; then
214 214
     XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
215 215
     XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
216 216
     if [ ! -d $XMPP_CLIENT_DIR ]; then
217
-	mkdir -p $XMPP_CLIENT_DIR
217
+        mkdir -p $XMPP_CLIENT_DIR
218 218
     fi
219 219
     if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
220
-	mkdir -p /home/$MY_USERNAME/.config/profanity
220
+        mkdir -p /home/$MY_USERNAME/.config/profanity
221 221
     fi
222 222
     echo "[${MY_USERNAME}@${HOSTNAME}]" > $XMPP_CLIENT_ACCOUNTS
223 223
     echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
@@ -243,17 +243,17 @@ fi
243 243
 if grep -q "Blog domain" $COMPLETION_FILE; then
244 244
     FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
245 245
     if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users ]; then
246
-	echo $'Blog users directory not found'
247
-	if grep -q "install_xmpp" $COMPLETION_FILE; then
248
-	    ${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
249
-	fi
250
-	userdel -r $MY_USERNAME
251
-	exit 9
246
+        echo $'Blog users directory not found'
247
+        if grep -q "install_xmpp" $COMPLETION_FILE; then
248
+            ${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
249
+        fi
250
+        userdel -r $MY_USERNAME
251
+        exit 9
252 252
     fi
253 253
     NEW_USER_PASSWORD_HASH=$(${PROJECT_NAME}-sec --bloghash "$NEW_USER_PASSWORD")
254 254
     if [ ${#NEW_USER_PASSWORD_HASH} -lt 8 ]; then
255
-	echo $'Blog admin password could not be hashed'
256
-	exit 783528
255
+        echo $'Blog admin password could not be hashed'
256
+        exit 783528
257 257
     fi
258 258
     echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
259 259
     echo "password = $NEW_USER_PASSWORD_HASH" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
@@ -267,46 +267,46 @@ if grep -q "install_sip" $COMPLETION_FILE; then
267 267
     SIP_EXTENSION=$(${PROJECT_NAME}-sipfreeext)
268 268
     ${PROJECT_NAME}-addsipuser -u $MY_USERNAME -e $SIP_EXTENSION -p "$NEW_USER_PASSWORD"
269 269
     if [ ! "$?" = "0" ]; then
270
-	echo $'SIP user could not be added. Ensure that extension numbers are in order and do no exceed 299'
271
-	if grep -q "install_xmpp" $COMPLETION_FILE; then
272
-	    ${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
273
-	fi
274
-	if grep -q "Blog domain" $COMPLETION_FILE; then
275
-	    if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
276
-		rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
277
-	    fi
278
-	fi
279
-	userdel -r $MY_USERNAME
280
-	exit 10
270
+        echo $'SIP user could not be added. Ensure that extension numbers are in order and do no exceed 299'
271
+        if grep -q "install_xmpp" $COMPLETION_FILE; then
272
+            ${PROJECT_NAME}-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
273
+        fi
274
+        if grep -q "Blog domain" $COMPLETION_FILE; then
275
+            if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
276
+                rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
277
+            fi
278
+        fi
279
+        userdel -r $MY_USERNAME
280
+        exit 10
281 281
     fi
282 282
 fi
283 283
 
284 284
 if grep -q "install_gnusocial" $COMPLETION_FILE; then
285 285
     MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
286 286
     if [ -d /var/www/$MICROBLOG_DOMAIN_NAME ]; then
287
-	cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
288
-	php scripts/registeruser.php -n $MY_USERNAME -w "$NEW_USER_PASSWORD" -e "$MY_USERNAME@$HOSTNAME"
289
-	${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$MICROBLOG_DOMAIN_NAME" -g gnusocial --public no
290
-	echo $'Created GNU Social user'
287
+        cd /var/www/$MICROBLOG_DOMAIN_NAME/htdocs
288
+        php scripts/registeruser.php -n $MY_USERNAME -w "$NEW_USER_PASSWORD" -e "$MY_USERNAME@$HOSTNAME"
289
+        ${PROJECT_NAME}-addemail -u $MY_USERNAME -e "noreply@$MICROBLOG_DOMAIN_NAME" -g gnusocial --public no
290
+        echo $'Created GNU Social user'
291 291
     else
292
-	echo $"Unable to find GNU Social installation at /var/www/$MICROBLOG_DOMAIN_NAME/htdocs"
293
-	userdel -r $MY_USERNAME
294
-	exit 11
292
+        echo $"Unable to find GNU Social installation at /var/www/$MICROBLOG_DOMAIN_NAME/htdocs"
293
+        userdel -r $MY_USERNAME
294
+        exit 11
295 295
     fi
296 296
 fi
297 297
 
298 298
 if grep -q "install_irc_client" $COMPLETION_FILE; then
299 299
     IRC_PORT=6697
300 300
     if grep -q "IRC_PORT" $CONFIGURATION_FILE; then
301
-	IRC_PORT=$(grep "IRC_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
301
+        IRC_PORT=$(grep "IRC_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
302 302
     fi
303 303
     IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
304 304
     if [ ${#IRC_PASSWORD} -lt 2 ]; then
305
-	IRC_PASSWORD=
305
+        IRC_PASSWORD=
306 306
     fi
307 307
 
308 308
     if [ ! -d /home/$MY_USERNAME/.irssi ]; then
309
-	mkdir /home/$MY_USERNAME/.irssi
309
+        mkdir /home/$MY_USERNAME/.irssi
310 310
     fi
311 311
 
312 312
     echo 'servers = (' > /home/$MY_USERNAME/.irssi/config
@@ -369,7 +369,7 @@ fi
369 369
 
370 370
 if [ -f /etc/nginx/.htpasswd ]; then
371 371
     if ! grep "${MY_USERNAME}:" /etc/nginx/.htpasswd; then
372
-	echo "$NEW_USER_PASSWORD" | htpasswd -i -s /etc/nginx/.htpasswd $MY_USERNAME
372
+        echo "$NEW_USER_PASSWORD" | htpasswd -i -s /etc/nginx/.htpasswd $MY_USERNAME
373 373
     fi
374 374
 fi
375 375
 
@@ -381,8 +381,8 @@ fi
381 381
 # add user for SIP STUN/TURN
382 382
 if [ -d /etc/turnserver ]; then
383 383
     if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then
384
-	DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
385
-	echo "${MY_USERNAME}:${NEW_USER_PASSWORD}:${DEFAULT_DOMAIN_NAME}:authorized" >> /etc/turnserver/turnusers.txt
384
+        DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
385
+        echo "${MY_USERNAME}:${NEW_USER_PASSWORD}:${DEFAULT_DOMAIN_NAME}:authorized" >> /etc/turnserver/turnusers.txt
386 386
     fi
387 387
 fi
388 388
 

+ 22
- 15
src/freedombone-addxmpp View File

@@ -49,20 +49,20 @@ do
49 49
     key="$1"
50 50
 
51 51
     case $key in
52
-	-h|--help)
53
-	    show_help
54
-	    ;;
55
-	-e|--email)
56
-	    shift
57
-	    EMAIL_ADDRESS="$1"
58
-	    ;;
59
-	-p|--password|--passphrase)
60
-	    shift
61
-	    NEW_USER_PASSWORD="$1"
62
-	    ;;
63
-	*)
64
-	    # unknown option
65
-	    ;;
52
+        -h|--help)
53
+            show_help
54
+            ;;
55
+        -e|--email)
56
+            shift
57
+            EMAIL_ADDRESS="$1"
58
+            ;;
59
+        -p|--password|--passphrase)
60
+            shift
61
+            NEW_USER_PASSWORD="$1"
62
+            ;;
63
+        *)
64
+            # unknown option
65
+            ;;
66 66
     esac
67 67
     shift
68 68
 done
@@ -84,7 +84,14 @@ else
84 84
     DOMAIN_NAME=$(echo $EMAIL_ADDRESS | awk -F '@' '{print $2}')
85 85
     prosodyctl register $USERNAME $DOMAIN_NAME "$NEW_USER_PASSWORD"
86 86
     if [ ! "$?" = "0" ]; then
87
-	exit 2
87
+        exit 2
88
+    fi
89
+fi
90
+
91
+# add the xmpp address to email headers
92
+if [ -f /home/$USERNAME/.muttrc ]; then
93
+    if ! grep -q "Jabber-ID" /home/$USERNAME/.muttrc; then
94
+        echo "my_hdr Jabber-ID: ${USERNAME}@${HOSTNAME}" >> /home/$USERNAME/.muttrc
88 95
     fi
89 96
 fi
90 97
 

+ 414
- 400
src/freedombone-app-xmpp View File

@@ -38,444 +38,458 @@ XMPP_CIPHERS='"EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+
38 38
 XMPP_ECC_CURVE='"secp384r1"'
39 39
 
40 40
 function reconfigure_xmpp {
41
-	echo -n ''
41
+    echo -n ''
42 42
 }
43 43
 
44 44
 function update_prosody_modules {
45
-	if [ ! -d $INSTALL_DIR/prosody-modules ]; then
46
-		return
47
-	fi
48
-	if [ ! -d /usr/lib/prosody ]; then
49
-		return
50
-	fi
51
-
52
-	cd $INSTALL_DIR/prosody-modules
53
-	hg pull
54
-	hg update
55
-
56
-	# support onion addresses
57
-	if [ -f $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua ]; then
58
-		cp $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua /usr/lib/prosody/modules/mod_onions.lua
59
-	fi
60
-
61
-	# XEP-0313 message archive management
62
-	# https://modules.prosody.im/mod_mam.html
63
-	# Allows you to download your previous messages onto a new client
64
-	# This only applies if you are not using forward secret crypto
65
-	# such as OTR or OMEMO (eg. OpenPGP)
66
-	if [ -d $INSTALL_DIR/prosody-modules/mod_mam ]; then
67
-		cp $INSTALL_DIR/prosody-modules/mod_mam/*.lua /usr/lib/prosody/modules
68
-	fi
69
-
70
-	# XEP-0352 Client State Indication
71
-	# Notifies the server if the app is in the background or not
72
-	if [ -d $INSTALL_DIR/prosody-modules/mod_csi ]; then
73
-		cp $INSTALL_DIR/prosody-modules/mod_csi/*.lua /usr/lib/prosody/modules
74
-	fi
75
-
76
-	# XEP-0280 Message Carbons
77
-	# Ensures all messages get delivered to all clients (if you have a mobile and desktop client)
78
-	if [ -d $INSTALL_DIR/prosody-modules/mod_carbons ]; then
79
-		cp $INSTALL_DIR/prosody-modules/mod_carbons/*.lua /usr/lib/prosody/modules
80
-	fi
81
-
82
-	# XEP-0198 Stream management
83
-	# Helps mobile apps recover when a device switches networks.
84
-	if [ -d $INSTALL_DIR/prosody-modules/mod_smacks ]; then
85
-		cp $INSTALL_DIR/prosody-modules/mod_smacks/*.lua /usr/lib/prosody/modules
86
-	fi
87
-	if [ -d $INSTALL_DIR/prosody-modules/mod_smacks_offline ]; then
88
-		cp $INSTALL_DIR/prosody-modules/mod_smacks_offline/*.lua /usr/lib/prosody/modules
89
-	fi
90
-
91
-	# XEP-0191: blocking
92
-	if [ -d $INSTALL_DIR/prosody-modules/mod_blocking ]; then
93
-		cp $INSTALL_DIR/prosody-modules/mod_blocking/*.lua /usr/lib/prosody/modules
94
-	fi
95
-
96
-	# XEP-0016 Privacy lists
97
-	if [ -d $INSTALL_DIR/prosody-modules/mod_privacy_lists ]; then
98
-		cp $INSTALL_DIR/prosody-modules/mod_privacy_lists/*.lua /usr/lib/prosody/modules
99
-	fi
45
+    if [ ! -d $INSTALL_DIR/prosody-modules ]; then
46
+        return
47
+    fi
48
+    if [ ! -d /usr/lib/prosody ]; then
49
+        return
50
+    fi
51
+
52
+    cd $INSTALL_DIR/prosody-modules
53
+    hg pull
54
+    hg update
55
+
56
+    # support onion addresses
57
+    if [ -f $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua ]; then
58
+        cp $INSTALL_DIR/prosody-modules/mod_onions/mod_onions.lua /usr/lib/prosody/modules/mod_onions.lua
59
+    fi
60
+
61
+    # XEP-0313 message archive management
62
+    # https://modules.prosody.im/mod_mam.html
63
+    # Allows you to download your previous messages onto a new client
64
+    # This only applies if you are not using forward secret crypto
65
+    # such as OTR or OMEMO (eg. OpenPGP)
66
+    if [ -d $INSTALL_DIR/prosody-modules/mod_mam ]; then
67
+        cp $INSTALL_DIR/prosody-modules/mod_mam/*.lua /usr/lib/prosody/modules
68
+    fi
69
+
70
+    # XEP-0352 Client State Indication
71
+    # Notifies the server if the app is in the background or not
72
+    if [ -d $INSTALL_DIR/prosody-modules/mod_csi ]; then
73
+        cp $INSTALL_DIR/prosody-modules/mod_csi/*.lua /usr/lib/prosody/modules
74
+    fi
75
+
76
+    # XEP-0280 Message Carbons
77
+    # Ensures all messages get delivered to all clients (if you have a mobile and desktop client)
78
+    if [ -d $INSTALL_DIR/prosody-modules/mod_carbons ]; then
79
+        cp $INSTALL_DIR/prosody-modules/mod_carbons/*.lua /usr/lib/prosody/modules
80
+    fi
81
+
82
+    # XEP-0198 Stream management
83
+    # Helps mobile apps recover when a device switches networks.
84
+    if [ -d $INSTALL_DIR/prosody-modules/mod_smacks ]; then
85
+        cp $INSTALL_DIR/prosody-modules/mod_smacks/*.lua /usr/lib/prosody/modules
86
+    fi
87
+    if [ -d $INSTALL_DIR/prosody-modules/mod_smacks_offline ]; then
88
+        cp $INSTALL_DIR/prosody-modules/mod_smacks_offline/*.lua /usr/lib/prosody/modules
89
+    fi
90
+
91
+    # XEP-0191: blocking
92
+    if [ -d $INSTALL_DIR/prosody-modules/mod_blocking ]; then
93
+        cp $INSTALL_DIR/prosody-modules/mod_blocking/*.lua /usr/lib/prosody/modules
94
+    fi
95
+
96
+    # XEP-0016 Privacy lists
97
+    if [ -d $INSTALL_DIR/prosody-modules/mod_privacy_lists ]; then
98
+        cp $INSTALL_DIR/prosody-modules/mod_privacy_lists/*.lua /usr/lib/prosody/modules
99
+    fi
100 100
 }
101 101
 
102 102
 function upgrade_xmpp {
103
-	if ! grep -Fxq "install_xmpp_main" $COMPLETION_FILE; then
104
-		return
105
-	fi
106
-	function_check update_prosody_modules
107
-	update_prosody_modules
103
+    if ! grep -Fxq "install_xmpp_main" $COMPLETION_FILE; then
104
+        return
105
+    fi
106
+    function_check update_prosody_modules
107
+    update_prosody_modules
108 108
 }
109 109
 
110 110
 function backup_local_xmpp {
111
-	source_directory=/var/lib/prosody xmpp
112
-	if [ -d $source_directory ]; then
113
-		dest_directory=xmpp
114
-		echo $"Backing up $source_directory to $dest_directory"
111
+    source_directory=/var/lib/prosody xmpp
112
+    if [ -d $source_directory ]; then
113
+        dest_directory=xmpp
114
+        echo $"Backing up $source_directory to $dest_directory"
115 115
 
116
-		function_check backup_directory_to_usb
117
-		backup_directory_to_usb $source_directory $dest_directory
116
+        function_check backup_directory_to_usb
117
+        backup_directory_to_usb $source_directory $dest_directory
118 118
 
119
-		echo $"Backup to $dest_directory complete"
120
-	fi
119
+        echo $"Backup to $dest_directory complete"
120
+    fi
121 121
 }
122 122
 
123 123
 function restore_local_xmpp {
124
-	if [ -d /var/lib/prosody ]; then
125
-		echo $"Restoring XMPP settings"
126
-		temp_restore_dir=/root/tempxmpp
127
-		function_check restore_directory_from_usb
128
-		restore_directory_from_usb $temp_restore_dir xmpp
129
-		cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
130
-		if [ ! "$?" = "0" ]; then
131
-			function_check set_user_permissions
132
-			set_user_permissions
133
-			function_check backup_unmount_drive
134
-			backup_unmount_drive
135
-			exit 725
136
-		fi
137
-		rm -rf $temp_restore_dir
138
-		service prosody restart
139
-		chown -R prosody:prosody /var/lib/prosody/*
140
-		echo $"Restore of XMPP settings complete"
141
-	fi
124
+    if [ -d /var/lib/prosody ]; then
125
+        echo $"Restoring XMPP settings"
126
+        temp_restore_dir=/root/tempxmpp
127
+        function_check restore_directory_from_usb
128
+        restore_directory_from_usb $temp_restore_dir xmpp
129
+        cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
130
+        if [ ! "$?" = "0" ]; then
131
+            function_check set_user_permissions
132
+            set_user_permissions
133
+            function_check backup_unmount_drive
134
+            backup_unmount_drive
135
+            exit 725
136
+        fi
137
+        rm -rf $temp_restore_dir
138
+        service prosody restart
139
+        chown -R prosody:prosody /var/lib/prosody/*
140
+        echo $"Restore of XMPP settings complete"
141
+    fi
142 142
 }
143 143
 
144 144
 function backup_remote_xmpp {
145
-	if [ -d /var/lib/prosody ]; then
146
-		echo $"Backing up the XMPP settings"
147
-		backup_directory_to_friend /var/lib/prosody xmpp
148
-		echo $"Backup of XMPP settings complete"
149
-	fi
145
+    if [ -d /var/lib/prosody ]; then
146
+        echo $"Backing up the XMPP settings"
147
+        backup_directory_to_friend /var/lib/prosody xmpp
148
+        echo $"Backup of XMPP settings complete"
149
+    fi
150 150
 }
151 151
 
152 152
 function restore_remote_xmpp {
153
-	if [ -d /var/lib/prosody ]; then
154
-		echo $"Restoring XMPP settings"
155
-		temp_restore_dir=/root/tempxmpp
156
-		function_check restore_directory_from_friend
157
-		restore_directory_from_friend $temp_restore_dir xmpp
158
-		cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
159
-		if [ ! "$?" = "0" ]; then
160
-			exit 725
161
-		fi
162
-		rm -rf $temp_restore_dir
163
-		service prosody restart
164
-		chown -R prosody:prosody /var/lib/prosody/*
165
-		echo $"Restore of XMPP settings complete"
166
-	fi
153
+    if [ -d /var/lib/prosody ]; then
154
+        echo $"Restoring XMPP settings"
155
+        temp_restore_dir=/root/tempxmpp
156
+        function_check restore_directory_from_friend
157
+        restore_directory_from_friend $temp_restore_dir xmpp
158
+        cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
159
+        if [ ! "$?" = "0" ]; then
160
+            exit 725
161
+        fi
162
+        rm -rf $temp_restore_dir
163
+        service prosody restart
164
+        chown -R prosody:prosody /var/lib/prosody/*
165
+        echo $"Restore of XMPP settings complete"
166
+    fi
167 167
 }
168 168
 
169 169
 function configure_firewall_for_xmpp {
170
-	if [ ! -d /etc/prosody ]; then
171
-		return
172
-	fi
173
-	if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
174
-		return
175
-	fi
176
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
177
-		# docker does its own firewalling
178
-		return
179
-	fi
180
-	if [[ $ONION_ONLY != "no" ]]; then
181
-		return
182
-	fi
183
-	iptables -A INPUT -p tcp --dport 5222:5223 -j ACCEPT
184
-	iptables -A INPUT -p tcp --dport 5269 -j ACCEPT
185
-	iptables -A INPUT -p tcp --dport 5280:5281 -j ACCEPT
186
-	function_check save_firewall_settings
187
-	save_firewall_settings
188
-
189
-	OPEN_PORTS+=('XMPP     5222-5223')
190
-	OPEN_PORTS+=('XMPP     5269')
191
-	OPEN_PORTS+=('XMPP     5280-5281')
192
-	echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
170
+    if [ ! -d /etc/prosody ]; then
171
+        return
172
+    fi
173
+    if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
174
+        return
175
+    fi
176
+    if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
177
+        # docker does its own firewalling
178
+        return
179
+    fi
180
+    if [[ $ONION_ONLY != "no" ]]; then
181
+        return
182
+    fi
183
+    iptables -A INPUT -p tcp --dport 5222:5223 -j ACCEPT
184
+    iptables -A INPUT -p tcp --dport 5269 -j ACCEPT
185
+    iptables -A INPUT -p tcp --dport 5280:5281 -j ACCEPT
186
+    function_check save_firewall_settings
187
+    save_firewall_settings
188
+
189
+    OPEN_PORTS+=('XMPP     5222-5223')
190
+    OPEN_PORTS+=('XMPP     5269')
191
+    OPEN_PORTS+=('XMPP     5280-5281')
192
+    echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
193 193
 }
194 194
 
195 195
 function remove_xmpp_client {
196
-	if ! grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
197
-		return
198
-	fi
199
-	apt-get -y remove --purge profanity
200
-	sed '/install_xmpp_client/d' $COMPLETION_FILE
196
+    if ! grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
197
+        return
198
+    fi
199
+    apt-get -y remove --purge profanity
200
+    sed '/install_xmpp_client/d' $COMPLETION_FILE
201 201
 }
202 202
 
203 203
 function remove_xmpp {
204
-	remove_xmpp_client
205
-	if ! grep -Fxq "install_xmpp" $COMPLETION_FILE; then
206
-		return
207
-	fi
208
-	iptables -D INPUT -p tcp --dport 5222:5223 -j ACCEPT
209
-	iptables -D INPUT -p tcp --dport 5269 -j ACCEPT
210
-	iptables -D INPUT -p tcp --dport 5280:5281 -j ACCEPT
211
-	function_check save_firewall_settings
212
-	save_firewall_settings
213
-
214
-	function_check remove_onion_service
215
-	remove_onion_service xmpp 5222 5223 5269
216
-
217
-	apt-get -y remove --purge prosody prosody-modules
218
-	if [ -d $INSTALL_DIR/prosody-modules ]; then
219
-		rm -rf $INSTALL_DIR/prosody-modules
220
-	fi
221
-	if [ -d /etc/prosody ]; then
222
-		rm -rf /etc/prosody
223
-	fi
224
-
225
-	sed '/install_xmpp/d' $COMPLETION_FILE
226
-	sed '/XMPP /d' $COMPLETION_FILE
204
+    remove_xmpp_client
205
+    if ! grep -Fxq "install_xmpp" $COMPLETION_FILE; then
206
+        return
207
+    fi
208
+    iptables -D INPUT -p tcp --dport 5222:5223 -j ACCEPT
209
+    iptables -D INPUT -p tcp --dport 5269 -j ACCEPT
210
+    iptables -D INPUT -p tcp --dport 5280:5281 -j ACCEPT
211
+    function_check save_firewall_settings
212
+    save_firewall_settings
213
+
214
+    function_check remove_onion_service
215
+    remove_onion_service xmpp 5222 5223 5269
216
+
217
+    apt-get -y remove --purge prosody prosody-modules
218
+    if [ -d $INSTALL_DIR/prosody-modules ]; then
219
+        rm -rf $INSTALL_DIR/prosody-modules
220
+    fi
221
+    if [ -d /etc/prosody ]; then
222
+        rm -rf /etc/prosody
223
+    fi
224
+
225
+    sed '/install_xmpp/d' $COMPLETION_FILE
226
+    sed '/XMPP /d' $COMPLETION_FILE
227
+}
228
+
229
+function xmpp_email_headers {
230
+    for d in /home/*/ ; do
231
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
232
+        if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
233
+            if [ -f /home/$USERNAME/.muttrc ]; then
234
+                if ! grep -q "Jabber-ID" /home/$USERNAME/.muttrc; then
235
+                    echo "my_hdr Jabber-ID: ${USERNAME}@${HOSTNAME}" >> /home/$USERNAME/.muttrc
236
+                fi
237
+            fi
238
+        fi
239
+    done
227 240
 }
228 241
 
229 242
 function install_xmpp_main {
230
-	update_prosody_modules
231
-
232
-	if grep -Fxq "install_xmpp_main" $COMPLETION_FILE; then
233
-		return
234
-	fi
235
-	apt-get -y install lua-sec lua-bitop
236
-	apt-get -y install prosody prosody-modules mercurial
237
-
238
-	if [ ! -d /etc/prosody ]; then
239
-		echo $"ERROR: prosody does not appear to have installed. $CHECK_MESSAGE"
240
-		exit 52
241
-	fi
242
-
243
-	# obtain the prosody modules
244
-	cd $INSTALL_DIR
245
-	hg clone https://hg.prosody.im/prosody-modules/ prosody-modules
246
-	if [ ! -d $INSTALL_DIR/prosody-modules/mod_onions ]; then
247
-		echo $'mod_onions prosody module could not be found'
248
-		exit 73254
249
-	fi
250
-
251
-	# install the onions module
252
-	update_prosody_modules
253
-	if [ ! -f /usr/lib/prosody/modules/mod_onions.lua ]; then
254
-		echo $'mod_onions.lua could not be copied to the prosody modules directory'
255
-		exit 63952
256
-	fi
257
-
258
-	# create a certificate
259
-	if [ ! -f /etc/ssl/certs/xmpp.dhparam ]; then
260
-		${PROJECT_NAME}-addcert -h xmpp --dhkey $DH_KEYLENGTH
261
-		check_certificates xmpp
262
-	fi
263
-	chown prosody:prosody /etc/ssl/private/xmpp.key
264
-	chown prosody:prosody /etc/ssl/certs/xmpp.*
265
-	cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
266
-
267
-	sed -i 's|/etc/prosody/certs/example.com.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/conf.avail/xmpp.cfg.lua
268
-	sed -i 's|/etc/prosody/certs/example.com.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/conf.avail/xmpp.cfg.lua
269
-	if ! grep -q "xmpp.dhparam" /etc/prosody/conf.avail/xmpp.cfg.lua; then
270
-		sed -i '/certificate =/a\        dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/conf.avail/xmpp.cfg.lua
271
-	fi
272
-	if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/conf.avail/xmpp.cfg.lua; then
273
-		sed -i '/certificate =/a\        options = {"no_sslv2", "no_sslv3" };' /etc/prosody/conf.avail/xmpp.cfg.lua
274
-	fi
275
-	if ! grep -q 'ciphers =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
276
-		sed -i "/certificate =/a\        ciphers = $XMPP_CIPHERS;" /etc/prosody/conf.avail/xmpp.cfg.lua
277
-	fi
278
-	if ! grep -q 'depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua; then
279
-		sed -i '/certificate =/a\        depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua
280
-	fi
281
-	if ! grep -q 'curve =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
282
-		sed -i "/certificate =/a\        curve = $XMPP_ECC_CURVE;" /etc/prosody/conf.avail/xmpp.cfg.lua
283
-	fi
284
-
285
-	sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/conf.avail/xmpp.cfg.lua
286
-	sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/conf.avail/xmpp.cfg.lua
287
-
288
-	if ! grep -q "modules_enabled" /etc/prosody/conf.avail/xmpp.cfg.lua; then
289
-		echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
290
-		echo 'modules_enabled = {' >> /etc/prosody/conf.avail/xmpp.cfg.lua
291
-		echo '  "bosh"; -- Enable mod_bosh' >> /etc/prosody/conf.avail/xmpp.cfg.lua
292
-		echo '  "tls"; -- Enable mod_tls' >> /etc/prosody/conf.avail/xmpp.cfg.lua
293
-		echo '  "saslauth"; -- Enable mod_saslauth' >> /etc/prosody/conf.avail/xmpp.cfg.lua
294
-		echo '  "onions"; -- Enable chat via onion service' >> /etc/prosody/conf.avail/xmpp.cfg.lua
295
-		echo '  "mam"; -- Message archive management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
296
-		echo '  "csi"; -- Client state indication' >> /etc/prosody/conf.avail/xmpp.cfg.lua
297
-		echo '  "carbons"; -- Message carbons' >> /etc/prosody/conf.avail/xmpp.cfg.lua
298
-		echo '  "smacks"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
299
-		echo '  "smacks_offline"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
300
-		echo '  "pep"; -- Personal Eventing Protocol (to support OMEMO)' >> /etc/prosody/conf.avail/xmpp.cfg.lua
301
-		echo '  "privacy"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
302
-		echo '  "privacy_lists"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
303
-		echo '  "blocking"; -- Blocking command' >> /etc/prosody/conf.avail/xmpp.cfg.lua
304
-		echo '  "roster"; -- Roster versioning' >> /etc/prosody/conf.avail/xmpp.cfg.lua
305
-		echo '}' >> /etc/prosody/conf.avail/xmpp.cfg.lua
306
-		echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
307
-		echo 'c2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
308
-		echo 's2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
309
-		echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
310
-	fi
311
-	ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
312
-
313
-	sed -i 's|/etc/prosody/certs/localhost.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/prosody.cfg.lua
314
-	sed -i 's|/etc/prosody/certs/localhost.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/prosody.cfg.lua
315
-	if ! grep -q "xmpp.dhparam" /etc/prosody/prosody.cfg.lua; then
316
-		sed -i '/certificate =/a\    dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/prosody.cfg.lua
317
-	fi
318
-	if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/prosody.cfg.lua; then
319
-		sed -i '/certificate =/a\    options = {"no_sslv2", "no_sslv3" };' /etc/prosody/prosody.cfg.lua
320
-	fi
321
-	if ! grep -q 'ciphers =' /etc/prosody/prosody.cfg.lua; then
322
-		sed -i "/certificate =/a\    ciphers = $XMPP_CIPHERS;" /etc/prosody/prosody.cfg.lua
323
-	fi
324
-	if ! grep -q 'depth = "1";' /etc/prosody/prosody.cfg.lua; then
325
-		sed -i '/certificate =/a\    depth = "1";' /etc/prosody/prosody.cfg.lua
326
-	fi
327
-	if ! grep -q 'curve =' /etc/prosody/prosody.cfg.lua; then
328
-		sed -i "/certificate =/a\    curve = $XMPP_ECC_CURVE;" /etc/prosody/prosody.cfg.lua
329
-	fi
330
-	sed -i 's/c2s_require_encryption = false/c2s_require_encryption = true/g' /etc/prosody/prosody.cfg.lua
331
-	if ! grep -q "s2s_require_encryption" /etc/prosody/prosody.cfg.lua; then
332
-		sed -i '/c2s_require_encryption/a\s2s_require_encryption = true' /etc/prosody/prosody.cfg.lua
333
-	fi
334
-	if ! grep -q "allow_unencrypted_plain_auth" /etc/prosody/prosody.cfg.lua; then
335
-		echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
336
-	fi
337
-	sed -i 's/--"bosh";/"bosh";/g' /etc/prosody/prosody.cfg.lua
338
-	sed -i 's/authentication = "internal_plain"/authentication = "internal_hashed"/g' /etc/prosody/prosody.cfg.lua
339
-	sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/prosody.cfg.lua
340
-	sed -i 's|key = "/etc/prosody/certs/example.com.key"|key = "/etc/ssl/private/xmpp.key"|g' /etc/prosody/prosody.cfg.lua
341
-	sed -i 's|certificate = "/etc/prosody/certs/example.com.crt"|certificate = "/etc/ssl/certs/xmpp.crt"|g' /etc/prosody/prosody.cfg.lua
342
-	sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/prosody.cfg.lua
343
-
344
-	systemctl restart prosody
345
-	touch /home/$MY_USERNAME/README
346
-
347
-	if [ ! -d /var/lib/tor ]; then
348
-		echo $'No Tor installation found. XMPP onion site cannot be configured.'
349
-		exit 877367
350
-	fi
351
-	if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
352
-		echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
353
-		echo "HiddenServicePort 5222 127.0.0.1:5222" >> /etc/tor/torrc
354
-		echo "HiddenServicePort 5269 127.0.0.1:5269" >> /etc/tor/torrc
355
-		echo $'Added onion site for XMPP chat'
356
-	fi
357
-
358
-	systemctl restart tor
359
-	wait_for_onion_service 'xmpp'
360
-
361
-	if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
362
-		echo $'XMPP onion site hostname not found'
363
-		exit 65349
364
-	fi
365
-	XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
366
-	if ! grep -q "${XMPP_ONION_HOSTNAME}" /etc/prosody/conf.avail/xmpp.cfg.lua; then
367
-		echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
368
-		echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/conf.avail/xmpp.cfg.lua
369
-		echo '    modules_enabled = { "onions" };' >> /etc/prosody/conf.avail/xmpp.cfg.lua
370
-	fi
371
-	if ! grep -q "XMPP onion domain" $COMPLETION_FILE; then
372
-		echo "XMPP onion domain:${XMPP_ONION_HOSTNAME}" >> $COMPLETION_FILE
373
-	else
374
-		sed -i "s|XMPP onion domain.*|XMPP onion domain:${XMPP_ONION_HOSTNAME}|g" $COMPLETION_FILE
375
-	fi
376
-
377
-	if ! grep -q "Your XMPP password is" /home/$MY_USERNAME/README; then
378
-		if [ ${#XMPP_PASSWORD} -lt 8 ]; then
379
-			if [ -f $IMAGE_PASSWORD_FILE ]; then
380
-				XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
381
-			else
382
-				XMPP_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
383
-			fi
384
-		fi
385
-		prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
386
-		echo '' >> /home/$MY_USERNAME/README
387
-		echo '' >> /home/$MY_USERNAME/README
388
-		echo $'XMPP' >> /home/$MY_USERNAME/README
389
-		echo '====' >> /home/$MY_USERNAME/README
390
-		echo $"XMPP onion domain: ${XMPP_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
391
-		echo $"Your XMPP password is: $XMPP_PASSWORD" >> /home/$MY_USERNAME/README
392
-		echo $'You can change it with: ' >> /home/$MY_USERNAME/README
393
-		echo '' >> /home/$MY_USERNAME/README
394
-		echo "    prosodyctl passwd $MY_EMAIL_ADDRESS" >> /home/$MY_USERNAME/README
395
-		chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
396
-		chmod 600 /home/$MY_USERNAME/README
397
-	fi
398
-
399
-	function_check configure_firewall_for_xmpp
400
-	configure_firewall_for_xmpp
401
-
402
-	echo 'install_xmpp_main' >> $COMPLETION_FILE
243
+    update_prosody_modules
244
+
245
+    if grep -Fxq "install_xmpp_main" $COMPLETION_FILE; then
246
+        return
247
+    fi
248
+    apt-get -y install lua-sec lua-bitop
249
+    apt-get -y install prosody prosody-modules mercurial
250
+
251
+    if [ ! -d /etc/prosody ]; then
252
+        echo $"ERROR: prosody does not appear to have installed. $CHECK_MESSAGE"
253
+        exit 52
254
+    fi
255
+
256
+    # obtain the prosody modules
257
+    cd $INSTALL_DIR
258
+    hg clone https://hg.prosody.im/prosody-modules/ prosody-modules
259
+    if [ ! -d $INSTALL_DIR/prosody-modules/mod_onions ]; then
260
+        echo $'mod_onions prosody module could not be found'
261
+        exit 73254
262
+    fi
263
+
264
+    # install the onions module
265
+    update_prosody_modules
266
+    if [ ! -f /usr/lib/prosody/modules/mod_onions.lua ]; then
267
+        echo $'mod_onions.lua could not be copied to the prosody modules directory'
268
+        exit 63952
269
+    fi
270
+
271
+    # create a certificate
272
+    if [ ! -f /etc/ssl/certs/xmpp.dhparam ]; then
273
+        ${PROJECT_NAME}-addcert -h xmpp --dhkey $DH_KEYLENGTH
274
+        check_certificates xmpp
275
+    fi
276
+    chown prosody:prosody /etc/ssl/private/xmpp.key
277
+    chown prosody:prosody /etc/ssl/certs/xmpp.*
278
+    cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
279
+
280
+    sed -i 's|/etc/prosody/certs/example.com.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/conf.avail/xmpp.cfg.lua
281
+    sed -i 's|/etc/prosody/certs/example.com.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/conf.avail/xmpp.cfg.lua
282
+    if ! grep -q "xmpp.dhparam" /etc/prosody/conf.avail/xmpp.cfg.lua; then
283
+        sed -i '/certificate =/a\        dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/conf.avail/xmpp.cfg.lua
284
+    fi
285
+    if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/conf.avail/xmpp.cfg.lua; then
286
+        sed -i '/certificate =/a\        options = {"no_sslv2", "no_sslv3" };' /etc/prosody/conf.avail/xmpp.cfg.lua
287
+    fi
288
+    if ! grep -q 'ciphers =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
289
+        sed -i "/certificate =/a\        ciphers = $XMPP_CIPHERS;" /etc/prosody/conf.avail/xmpp.cfg.lua
290
+    fi
291
+    if ! grep -q 'depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua; then
292
+        sed -i '/certificate =/a\        depth = "1";' /etc/prosody/conf.avail/xmpp.cfg.lua
293
+    fi
294
+    if ! grep -q 'curve =' /etc/prosody/conf.avail/xmpp.cfg.lua; then
295
+        sed -i "/certificate =/a\        curve = $XMPP_ECC_CURVE;" /etc/prosody/conf.avail/xmpp.cfg.lua
296
+    fi
297
+
298
+    sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/conf.avail/xmpp.cfg.lua
299
+    sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/conf.avail/xmpp.cfg.lua
300
+
301
+    if ! grep -q "modules_enabled" /etc/prosody/conf.avail/xmpp.cfg.lua; then
302
+        echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
303
+        echo 'modules_enabled = {' >> /etc/prosody/conf.avail/xmpp.cfg.lua
304
+        echo '  "bosh"; -- Enable mod_bosh' >> /etc/prosody/conf.avail/xmpp.cfg.lua
305
+        echo '  "tls"; -- Enable mod_tls' >> /etc/prosody/conf.avail/xmpp.cfg.lua
306
+        echo '  "saslauth"; -- Enable mod_saslauth' >> /etc/prosody/conf.avail/xmpp.cfg.lua
307
+        echo '  "onions"; -- Enable chat via onion service' >> /etc/prosody/conf.avail/xmpp.cfg.lua
308
+        echo '  "mam"; -- Message archive management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
309
+        echo '  "csi"; -- Client state indication' >> /etc/prosody/conf.avail/xmpp.cfg.lua
310
+        echo '  "carbons"; -- Message carbons' >> /etc/prosody/conf.avail/xmpp.cfg.lua
311
+        echo '  "smacks"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
312
+        echo '  "smacks_offline"; -- Stream management' >> /etc/prosody/conf.avail/xmpp.cfg.lua
313
+        echo '  "pep"; -- Personal Eventing Protocol (to support OMEMO)' >> /etc/prosody/conf.avail/xmpp.cfg.lua
314
+        echo '  "privacy"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
315
+        echo '  "privacy_lists"; -- Privacy lists' >> /etc/prosody/conf.avail/xmpp.cfg.lua
316
+        echo '  "blocking"; -- Blocking command' >> /etc/prosody/conf.avail/xmpp.cfg.lua
317
+        echo '  "roster"; -- Roster versioning' >> /etc/prosody/conf.avail/xmpp.cfg.lua
318
+        echo '}' >> /etc/prosody/conf.avail/xmpp.cfg.lua
319
+        echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
320
+        echo 'c2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
321
+        echo 's2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua
322
+        echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
323
+    fi
324
+    ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua
325
+
326
+    sed -i 's|/etc/prosody/certs/localhost.key|/etc/ssl/private/xmpp.key|g' /etc/prosody/prosody.cfg.lua
327
+    sed -i 's|/etc/prosody/certs/localhost.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/prosody.cfg.lua
328
+    if ! grep -q "xmpp.dhparam" /etc/prosody/prosody.cfg.lua; then
329
+        sed -i '/certificate =/a\    dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/prosody.cfg.lua
330
+    fi
331
+    if ! grep -q 'options = {"no_sslv2", "no_sslv3" }' /etc/prosody/prosody.cfg.lua; then
332
+        sed -i '/certificate =/a\    options = {"no_sslv2", "no_sslv3" };' /etc/prosody/prosody.cfg.lua
333
+    fi
334
+    if ! grep -q 'ciphers =' /etc/prosody/prosody.cfg.lua; then
335
+        sed -i "/certificate =/a\    ciphers = $XMPP_CIPHERS;" /etc/prosody/prosody.cfg.lua
336
+    fi
337
+    if ! grep -q 'depth = "1";' /etc/prosody/prosody.cfg.lua; then
338
+        sed -i '/certificate =/a\    depth = "1";' /etc/prosody/prosody.cfg.lua
339
+    fi
340
+    if ! grep -q 'curve =' /etc/prosody/prosody.cfg.lua; then
341
+        sed -i "/certificate =/a\    curve = $XMPP_ECC_CURVE;" /etc/prosody/prosody.cfg.lua
342
+    fi
343
+    sed -i 's/c2s_require_encryption = false/c2s_require_encryption = true/g' /etc/prosody/prosody.cfg.lua
344
+    if ! grep -q "s2s_require_encryption" /etc/prosody/prosody.cfg.lua; then
345
+        sed -i '/c2s_require_encryption/a\s2s_require_encryption = true' /etc/prosody/prosody.cfg.lua
346
+    fi
347
+    if ! grep -q "allow_unencrypted_plain_auth" /etc/prosody/prosody.cfg.lua; then
348
+        echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua
349
+    fi
350
+    sed -i 's/--"bosh";/"bosh";/g' /etc/prosody/prosody.cfg.lua
351
+    sed -i 's/authentication = "internal_plain"/authentication = "internal_hashed"/g' /etc/prosody/prosody.cfg.lua
352
+    sed -i 's/enabled = false -- Remove this line to enable this host//g' /etc/prosody/prosody.cfg.lua
353
+    sed -i 's|key = "/etc/prosody/certs/example.com.key"|key = "/etc/ssl/private/xmpp.key"|g' /etc/prosody/prosody.cfg.lua
354
+    sed -i 's|certificate = "/etc/prosody/certs/example.com.crt"|certificate = "/etc/ssl/certs/xmpp.crt"|g' /etc/prosody/prosody.cfg.lua
355
+    sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/prosody.cfg.lua
356
+
357
+    systemctl restart prosody
358
+    touch /home/$MY_USERNAME/README
359
+
360
+    if [ ! -d /var/lib/tor ]; then
361
+        echo $'No Tor installation found. XMPP onion site cannot be configured.'
362
+        exit 877367
363
+    fi
364
+    if ! grep -q "hidden_service_xmpp" /etc/tor/torrc; then
365
+        echo 'HiddenServiceDir /var/lib/tor/hidden_service_xmpp/' >> /etc/tor/torrc
366
+        echo "HiddenServicePort 5222 127.0.0.1:5222" >> /etc/tor/torrc
367
+        echo "HiddenServicePort 5269 127.0.0.1:5269" >> /etc/tor/torrc
368
+        echo $'Added onion site for XMPP chat'
369
+    fi
370
+
371
+    systemctl restart tor
372
+    wait_for_onion_service 'xmpp'
373
+
374
+    if [ ! -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
375
+        echo $'XMPP onion site hostname not found'
376
+        exit 65349
377
+    fi
378
+    XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
379
+    if ! grep -q "${XMPP_ONION_HOSTNAME}" /etc/prosody/conf.avail/xmpp.cfg.lua; then
380
+        echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua
381
+        echo "VirtualHost \"${XMPP_ONION_HOSTNAME}\"" >> /etc/prosody/conf.avail/xmpp.cfg.lua
382
+        echo '    modules_enabled = { "onions" };' >> /etc/prosody/conf.avail/xmpp.cfg.lua
383
+    fi
384
+    if ! grep -q "XMPP onion domain" $COMPLETION_FILE; then
385
+        echo "XMPP onion domain:${XMPP_ONION_HOSTNAME}" >> $COMPLETION_FILE
386
+    else
387
+        sed -i "s|XMPP onion domain.*|XMPP onion domain:${XMPP_ONION_HOSTNAME}|g" $COMPLETION_FILE
388
+    fi
389
+
390
+    if ! grep -q "Your XMPP password is" /home/$MY_USERNAME/README; then
391
+        if [ ${#XMPP_PASSWORD} -lt 8 ]; then
392
+            if [ -f $IMAGE_PASSWORD_FILE ]; then
393
+                XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
394
+            else
395
+                XMPP_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
396
+            fi
397
+        fi
398
+        prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
399
+        echo '' >> /home/$MY_USERNAME/README
400
+        echo '' >> /home/$MY_USERNAME/README
401
+        echo $'XMPP' >> /home/$MY_USERNAME/README
402
+        echo '====' >> /home/$MY_USERNAME/README
403
+        echo $"XMPP onion domain: ${XMPP_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
404
+        echo $"Your XMPP password is: $XMPP_PASSWORD" >> /home/$MY_USERNAME/README
405
+        echo $'You can change it with: ' >> /home/$MY_USERNAME/README
406
+        echo '' >> /home/$MY_USERNAME/README
407
+        echo "    prosodyctl passwd $MY_EMAIL_ADDRESS" >> /home/$MY_USERNAME/README
408
+        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
409
+        chmod 600 /home/$MY_USERNAME/README
410
+    fi
411
+
412
+    function_check configure_firewall_for_xmpp
413
+    configure_firewall_for_xmpp
414
+    xmpp_email_headers
415
+
416
+    echo 'install_xmpp_main' >> $COMPLETION_FILE
403 417
 }
404 418
 
405 419
 function install_xmpp_client {
406
-	if grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
407
-		return
408
-	fi
409
-	apt-get -y install profanity
410
-
411
-	XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
412
-	XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
413
-	if [ ! -d $XMPP_CLIENT_DIR ]; then
414
-		mkdir -p $XMPP_CLIENT_DIR
415
-	fi
416
-
417
-	if [[ $ONION_ONLY == 'no' ]]; then
418
-		echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]" > $XMPP_CLIENT_ACCOUNTS
419
-		echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
420
-		echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
421
-		echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
422
-		echo "muc.service=conference.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
423
-		echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
424
-		echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
425
-		echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
426
-		echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
427
-		echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
428
-		echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
429
-		echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
430
-		echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
431
-		if [ ${#XMPP_PASSWORD} -gt 2 ]; then
432
-			echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
433
-		fi
434
-	fi
435
-
436
-	if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
437
-		XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
438
-		echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> $XMPP_CLIENT_ACCOUNTS
439
-		if [[ $ONION_ONLY == 'no' ]]; then
440
-			echo 'enabled=false' >> $XMPP_CLIENT_ACCOUNTS
441
-		else
442
-			echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
443
-		fi
444
-		echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
445
-		echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
446
-		echo "muc.service=conference.${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
447
-		echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
448
-		echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
449
-		echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
450
-		echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
451
-		echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
452
-		echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
453
-		echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
454
-		echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
455
-		if [ ${#XMPP_PASSWORD} -gt 2 ]; then
456
-			echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
457
-		fi
458
-	fi
459
-
460
-	if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
461
-		mkdir /home/$MY_USERNAME/.config/profanity
462
-	fi
463
-	echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
464
-	echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
465
-
466
-	chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
467
-	chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
468
-
469
-	echo 'install_xmpp_client' >> $COMPLETION_FILE
420
+    if grep -Fxq "install_xmpp_client" $COMPLETION_FILE; then
421
+        return
422
+    fi
423
+    apt-get -y install profanity
424
+
425
+    XMPP_CLIENT_DIR=/home/$MY_USERNAME/.local/share/profanity
426
+    XMPP_CLIENT_ACCOUNTS=$XMPP_CLIENT_DIR/accounts
427
+    if [ ! -d $XMPP_CLIENT_DIR ]; then
428
+        mkdir -p $XMPP_CLIENT_DIR
429
+    fi
430
+
431
+    if [[ $ONION_ONLY == 'no' ]]; then
432
+        echo "[${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}]" > $XMPP_CLIENT_ACCOUNTS
433
+        echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
434
+        echo "jid=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
435
+        echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
436
+        echo "muc.service=conference.${DEFAULT_DOMAIN_NAME}" >> $XMPP_CLIENT_ACCOUNTS
437
+        echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
438
+        echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
439
+        echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
440
+        echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
441
+        echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
442
+        echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
443
+        echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
444
+        echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
445
+        if [ ${#XMPP_PASSWORD} -gt 2 ]; then
446
+            echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
447
+        fi
448
+    fi
449
+
450
+    if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
451
+        XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname)
452
+        echo "[${MY_USERNAME}@${XMPP_ONION_HOSTNAME}]" >> $XMPP_CLIENT_ACCOUNTS
453
+        if [[ $ONION_ONLY == 'no' ]]; then
454
+            echo 'enabled=false' >> $XMPP_CLIENT_ACCOUNTS
455
+        else
456
+            echo 'enabled=true' >> $XMPP_CLIENT_ACCOUNTS
457
+        fi
458
+        echo "jid=${MY_USERNAME}@${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
459
+        echo 'resource=profanity' >> $XMPP_CLIENT_ACCOUNTS
460
+        echo "muc.service=conference.${XMPP_ONION_HOSTNAME}" >> $XMPP_CLIENT_ACCOUNTS
461
+        echo "muc.nick=${MY_USERNAME}" >> $XMPP_CLIENT_ACCOUNTS
462
+        echo 'presence.last=online' >> $XMPP_CLIENT_ACCOUNTS
463
+        echo 'presence.login=online' >> $XMPP_CLIENT_ACCOUNTS
464
+        echo 'priority.online=0' >> $XMPP_CLIENT_ACCOUNTS
465
+        echo 'priority.chat=0' >> $XMPP_CLIENT_ACCOUNTS
466
+        echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
467
+        echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
468
+        echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
469
+        if [ ${#XMPP_PASSWORD} -gt 2 ]; then
470
+            echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
471
+        fi
472
+    fi
473
+
474
+    if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
475
+        mkdir /home/$MY_USERNAME/.config/profanity
476
+    fi
477
+    echo '[connection]' > /home/$MY_USERNAME/.config/profanity/profrc
478
+    echo "account=${MY_USERNAME}@${DEFAULT_DOMAIN_NAME}" >> /home/$MY_USERNAME/.config/profanity/profrc
479
+
480
+    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.local
481
+    chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
482
+
483
+    echo 'install_xmpp_client' >> $COMPLETION_FILE
470 484
 }
471 485
 
472 486
 function install_xmpp {
473
-	if grep -Fxq "install_xmpp" $COMPLETION_FILE; then
474
-		return
475
-	fi
476
-	install_xmpp_main
477
-	install_xmpp_client
478
-	echo 'install_xmpp' >> $COMPLETION_FILE
487
+    if grep -Fxq "install_xmpp" $COMPLETION_FILE; then
488
+        return
489
+    fi
490
+    install_xmpp_main
491
+    install_xmpp_client
492
+    echo 'install_xmpp' >> $COMPLETION_FILE
479 493
 }
480 494
 
481 495
 # NOTE: deliberately no exit 0