Przeglądaj źródła

Use a known set of prosody modules

Helps to ensure stability and reduce chances of security problems
Bob Mottram 8 lat temu
rodzic
commit
b3825d1602

BIN
image_build/prosody-modules-20170514.tar.gz Wyświetl plik


+ 40
- 20
src/freedombone-app-xmpp Wyświetl plik

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
17
 #
17
 #
18
 # This program is free software: you can redistribute it and/or modify
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
19
 # it under the terms of the GNU Affero General Public License as published by
45
 prosody_nightly_hash='770f1a0466f2361184eebffac9f50c102ad842cd855190db6c7f42f2f09884f5'
45
 prosody_nightly_hash='770f1a0466f2361184eebffac9f50c102ad842cd855190db6c7f42f2f09884f5'
46
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
46
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
47
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
47
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
48
-prosody_modules_repo='https://hg.prosody.im/prosody-modules/'
48
+
49
+# From https://hg.prosody.im/prosody-modules
50
+prosody_modules_filename='prosody-modules-20170514.tar.gz'
51
+prosody_modules_hash='ef404c203317cc0de6da7aaec4f21765a57f630adfbf082cf2dd92b881c15f86'
49
 
52
 
50
 LIBMESODE_REPO="https://github.com/boothj5/libmesode"
53
 LIBMESODE_REPO="https://github.com/boothj5/libmesode"
51
 LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
54
 LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
283
 }
286
 }
284
 
287
 
285
 function update_prosody_modules {
288
 function update_prosody_modules {
286
-    if [ ! -d /var/lib/prosody/prosody-modules ]; then
287
-        return
289
+    if [ ! $1 ]; then
290
+        if [ ! -d /var/lib/prosody/prosody-modules ]; then
291
+            return
292
+        fi
288
     fi
293
     fi
289
     if [ ! -d /usr/lib/prosody ]; then
294
     if [ ! -d /usr/lib/prosody ]; then
290
         return
295
         return
291
     fi
296
     fi
292
 
297
 
293
-    hg clone $prosody_modules_repo /var/lib/prosody/prosody-modules-new
294
-    if [ -d /var/lib/prosody/prosody-modules-new ]; then
295
-        rm -rf /var/lib/prosody/prosody-modules
296
-        mv /var/lib/prosody/prosody-modules-new /var/lib/prosody/prosody-modules
297
-        chown -R prosody:prosody /var/lib/prosody/prosody-modules
298
+    if [ ! -f $INSTALL_DIR/$prosody_modules_filename ]; then
299
+        # Obtain the modules
300
+        if [ -f ~/freedombone/image_build/$prosody_modules_filename ]; then
301
+            cp ~/freedombone/image_build/$prosody_modules_filename $INSTALL_DIR
302
+        else
303
+            if [ -f /home/$MY_USERNAME/freedombone/image_build/$prosody_modules_filename ]; then
304
+                cp /home/$MY_USERNAME/freedombone/image_build/$prosody_modules_filename $INSTALL_DIR
305
+            fi
306
+        fi
307
+
308
+        if [ -f $INSTALL_DIR/$prosody_modules_filename ]; then
309
+            cd $INSTALL_DIR
310
+
311
+            # Check the hash
312
+            curr_hash=$(sha256sum $INSTALL_DIR/$prosody_modules_filename | awk -F ' ' '{print $1}')
313
+            if [[ "$curr_hash" != "$prosody_modules_hash" ]]; then
314
+                echo $'Prosody modules hash does not match'
315
+            else
316
+                # Extract the modules
317
+                if [ -d prosody-modules ]; then
318
+                    rm -rf prosody-modules
319
+                fi
320
+                tar -xzvf $prosody_modules_filename
321
+                if [ -d prosody-modules ]; then
322
+                    cp -r prosody-modules/* /var/lib/prosody/prosody-modules
323
+                    chown -R prosody:prosody /var/lib/prosody/prosody-modules
324
+                fi
325
+            fi
326
+        fi
298
     fi
327
     fi
299
 
328
 
300
     # change to using pep rather than profile modules
329
     # change to using pep rather than profile modules
835
         mkdir /etc/prosody/conf.d
864
         mkdir /etc/prosody/conf.d
836
     fi
865
     fi
837
 
866
 
838
-    # obtain the prosody modules
839
-    if [ ! -d /var/lib/prosody/prosody-modules ]; then
840
-        hg clone $prosody_modules_repo /var/lib/prosody/prosody-modules
841
-    fi
842
-    if [ ! -d /var/lib/prosody/prosody-modules/mod_onions ]; then
843
-        echo $'mod_onions prosody module could not be found'
844
-        exit 73254
845
-    fi
846
-
847
     chmod -R 700 /etc/prosody/conf.d
867
     chmod -R 700 /etc/prosody/conf.d
848
     chown -R prosody /var/lib/prosody
868
     chown -R prosody /var/lib/prosody
849
     chown -R prosody /etc/prosody/conf.d
869
     chown -R prosody /etc/prosody/conf.d
850
 
870
 
851
-    # install the onions module
852
-    update_prosody_modules
871
+    # install modules
872
+    update_prosody_modules initial
853
 
873
 
854
     # create a certificate
874
     # create a certificate
855
     if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
875
     if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then