Преглед на файлове

Fix mediagoblin verification emails

Bob Mottram преди 8 години
родител
ревизия
9eca2e1e37
променени са 1 файла, в които са добавени 22 реда и са изтрити 1 реда
  1. 22
    1
      src/freedombone-app-mediagoblin

+ 22
- 1
src/freedombone-app-mediagoblin Целия файл

@@ -48,6 +48,21 @@ mediagoblin_variables=(ONION_ONLY
48 48
                        DEFAULT_DOMAIN_NAME
49 49
                        DDNS_PROVIDER)
50 50
 
51
+function mediagoblin_fix_email {
52
+    # This is a crude hack and there may be a better solution
53
+    # The cause of verification problems might be that the mediagoblin user
54
+    # does not have mail access
55
+    read_config_param 'MEDIAGOBLIN_DOMAIN_NAME'
56
+    MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
57
+    mgfile=$MEDIAGOBLIN_BASE_DIR/mediagoblin/tools/mail.py
58
+    if ! grep 'import os' $mgfile; then
59
+        sed -i '/import sys/a import os' $mgfile
60
+    fi
61
+    replacestr='return mhost.sendmail(from_addr, to_addrs, message.as_string())'
62
+    newstr="return os.system(\"echo '\" + message_body + \"' | mail -s '\" + message['Subject'] + \"' \" + message['To'])"
63
+    sed -i "s|${replacestr}|${newstr}|g" $mgfile
64
+}
65
+
51 66
 function install_interactive_mediagoblin {
52 67
     if [[ $ONION_ONLY != "no" ]]; then
53 68
         MEDIAGOBLIN_DOMAIN_NAME='mediagoblin.local'
@@ -113,6 +128,7 @@ function reconfigure_mediagoblin {
113 128
 function upgrade_mediagoblin {
114 129
     MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
115 130
     su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && ./bin/python setup.py develop --upgrade && ./bin/gmg dbupdate" - mediagoblin
131
+    mediagoblin_fix_email
116 132
     echo "0"
117 133
 }
118 134
 
@@ -411,6 +427,9 @@ function install_mediagoblin {
411 427
     sed -i "s|email_sender_address.*|email_sender_address = \"noreply@${DEFAULT_DOMAIN_NAME}\"|g" $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin.ini
412 428
     sed -i "s|email_sender_address.*|email_sender_address = \"noreply@${DEFAULT_DOMAIN_NAME}\"|g" $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
413 429
 
430
+    sed -i 's|allow_reporting.*|allow_reporting = false|g' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin.ini
431
+    sed -i 's|allow_reporting.*|allow_reporting = false|g' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
432
+
414 433
     if ! grep 'email_smtp_host' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin.ini; then
415 434
         sed -i '/email_sender_address/a email_smtp_host = localhost' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin.ini
416 435
     else
@@ -418,7 +437,7 @@ function install_mediagoblin {
418 437
     fi
419 438
 
420 439
     if ! grep 'email_smtp_host' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini; then
421
-        sed -i '/email_sender_address/a email_smtp_host = localhost' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
440
+        sed -i '/email_sender_address/a email_smtp_host = localhost' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin.ini
422 441
     else
423 442
         sed -i 's|email_smtp_host.*|email_smtp_host = localhost|g' $MEDIAGOBLIN_BASE_DIR/mediagoblin/mediagoblin_local.ini
424 443
     fi
@@ -427,6 +446,8 @@ function install_mediagoblin {
427 446
     systemctl daemon-reload
428 447
     systemctl start mediagoblin
429 448
 
449
+    mediagoblin_fix_email
450
+
430 451
     function_check create_site_certificate
431 452
     create_site_certificate $MEDIAGOBLIN_DOMAIN_NAME
432 453