瀏覽代碼

Enable or disable pleroma registrations

Bob Mottram 7 年之前
父節點
當前提交
c1ef4567bf
共有 1 個檔案被更改,包括 31 行新增5 行删除
  1. 31
    5
      src/freedombone-app-pleroma

+ 31
- 5
src/freedombone-app-pleroma 查看文件

@@ -62,6 +62,17 @@ pleroma_variables=(ONION_ONLY
62 62
                    MY_EMAIL_ADDRESS
63 63
                    MY_USERNAME)
64 64
 
65
+function pleroma_recompile {
66
+    # necessary after parameter changes
67
+    sudo -u pleroma mix clean
68
+    sudo -u pleroma mix deps.compile
69
+    sudo -u pleroma mix compile
70
+
71
+    if [ -f /etc/systemd/system/pleroma.service ]; then
72
+        systemctl restart pleroma
73
+    fi
74
+}
75
+
65 76
 function logging_on_pleroma {
66 77
     echo -n ''
67 78
 }
@@ -344,6 +355,19 @@ function pleroma_set_expire_months {
344 355
     rm $data
345 356
 }
346 357
 
358
+function pleroma_disable_registrations {
359
+    dialog --title $"Disable new Pleroma user registrations" \
360
+           --backtitle $"Freedombone Control Panel" \
361
+           --yesno $"\nDo you wish to disable new registrations?" 10 60
362
+    sel=$?
363
+    case $sel in
364
+        0) sed -i 's|registrations_open:.*|registrations_open: false|g' $PLEROMA_DIR/config/config.exs;;
365
+        1) sed -i 's|registrations_open:.*|registrations_open: true|g' $PLEROMA_DIR/config/config.exs;;
366
+        255) return;;
367
+    esac
368
+    pleroma_recompile
369
+}
370
+
347 371
 function configure_interactive_pleroma {
348 372
     read_config_param PLEROMA_EXPIRE_MONTHS
349 373
     while true
@@ -352,11 +376,12 @@ function configure_interactive_pleroma {
352 376
         trap "rm -f $data" 0 1 2 5 15
353 377
         dialog --backtitle $"Freedombone Control Panel" \
354 378
                --title $"Pleroma" \
355
-               --radiolist $"Choose an operation:" 13 70 4 \
379
+               --radiolist $"Choose an operation:" 14 70 5 \
356 380
                1 $"Set a background image" off \
357 381
                2 $"Set the title" off \
358
-               3 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)" off \
359
-               4 $"Exit" on 2> $data
382
+               3 $"Disable new account registrations" off \
383
+               4 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)" off \
384
+               5 $"Exit" on 2> $data
360 385
         sel=$?
361 386
         case $sel in
362 387
             1) return;;
@@ -365,8 +390,9 @@ function configure_interactive_pleroma {
365 390
         case $(cat $data) in
366 391
             1) pleroma_set_background_image;;
367 392
             2) pleroma_set_title;;
368
-            3) pleroma_set_expire_months;;
369
-            4) break;;
393
+            3) pleroma_disable_registrations;;
394
+            4) pleroma_set_expire_months;;
395
+            5) break;;
370 396
         esac
371 397
         rm $data
372 398
     done