浏览代码

Switch from git to gogs to maintain consistency

Bob Mottram 6 年前
父节点
当前提交
989c48f88b
共有 3 个文件被更改,包括 58 次插入59 次删除
  1. 54
    55
      src/freedombone-app-gogs
  2. 2
    2
      src/freedombone-config
  3. 2
    2
      src/freedombone-utils-onion

+ 54
- 55
src/freedombone-app-gogs 查看文件

@@ -34,8 +34,8 @@ SHOW_ON_ABOUT=1
34 34
 GOGS_USERNAME='gogs'
35 35
 GOGS_VERSION='0.11.29'
36 36
 
37
-GIT_DOMAIN_NAME=
38
-GIT_CODE=
37
+GOGS_DOMAIN_NAME=
38
+GOGS_CODE=
39 39
 GIT_ONION_PORT=8090
40 40
 GIT_ADMIN_PASSWORD=
41 41
 GOGS_BIN=
@@ -47,9 +47,8 @@ GOGS_MOBILE_APP_URL=
47 47
 
48 48
 gogs_variables=(ONION_ONLY
49 49
                 GIT_ADMIN_PASSWORD
50
-                GIT_DOMAIN_NAME
51
-                GIT_CODE
52
-                GIT_ONION_PORT
50
+                GOGS_DOMAIN_NAME
51
+                GOGS_CODE
53 52
                 MY_USERNAME
54 53
                 DDNS_PROVIDER
55 54
                 ARCHITECTURE)
@@ -69,8 +68,8 @@ function change_password_gogs {
69 68
 
70 69
 function install_interactive_gogs {
71 70
     if [[ $ONION_ONLY != "no" ]]; then
72
-        GIT_DOMAIN_NAME='gogs.local'
73
-        write_config_param "GIT_DOMAIN_NAME" "$GIT_DOMAIN_NAME"
71
+        GOGS_DOMAIN_NAME='gogs.local'
72
+        write_config_param "GOGS_DOMAIN_NAME" "$GOGS_DOMAIN_NAME"
74 73
     else
75 74
         function_check interactive_site_details
76 75
         interactive_site_details git
@@ -160,8 +159,8 @@ function upgrade_gogs {
160 159
     # Change port number if necessary
161 160
     if ! grep -q "HTTP_PORT = ${GOGS_PORT}" "${GOGS_CONFIG_FILE}"; then
162 161
         sed -i "s|HTTP_PORT =.*|HTTP_PORT = ${GOGS_PORT}|g" "${GOGS_CONFIG_FILE}"
163
-        read_config_param GIT_DOMAIN_NAME
164
-        sed -i "s|proxy_pass .*|proxy_pass http://localhost:${GOGS_PORT};|g" "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
162
+        read_config_param GOGS_DOMAIN_NAME
163
+        sed -i "s|proxy_pass .*|proxy_pass http://localhost:${GOGS_PORT};|g" "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
165 164
         systemctl restart gogs
166 165
         systemctl restart nginx
167 166
     fi
@@ -272,7 +271,7 @@ function restore_local_gogs {
272 271
         return
273 272
     fi
274 273
 
275
-    if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then
274
+    if [ ${#GOGS_DOMAIN_NAME} -gt 2 ]; then
276 275
         function_check gogs_create_database
277 276
         gogs_create_database
278 277
 
@@ -280,7 +279,7 @@ function restore_local_gogs {
280 279
         GOGS_CONFIG_FILE="${GOGS_CONFIG_PATH}/app.ini"
281 280
 
282 281
         function_check restore_database
283
-        restore_database gogs "${GIT_DOMAIN_NAME}"
282
+        restore_database gogs "${GOGS_DOMAIN_NAME}"
284 283
         temp_restore_dir=/root/tempgogs
285 284
         if [ -d "${USB_MOUNT}/backup/gogs" ]; then
286 285
             echo $"Restoring Gogs settings"
@@ -354,7 +353,7 @@ function restore_local_gogs {
354 353
 function backup_remote_gogs {
355 354
     if [ -d /home/$GOGS_USERNAME ]; then
356 355
         function_check suspend_site
357
-        suspend_site ${GIT_DOMAIN_NAME}
356
+        suspend_site ${GOGS_DOMAIN_NAME}
358 357
 
359 358
         function_check backup_database_to_friend
360 359
         backup_database_to_friend gogs
@@ -383,7 +382,7 @@ function backup_remote_gogs {
383 382
 
384 383
 function restore_remote_gogs {
385 384
     if grep -q "gogs domain" "$COMPLETION_FILE"; then
386
-        GIT_DOMAIN_NAME=$(get_completion_param "gogs domain")
385
+        GOGS_DOMAIN_NAME=$(get_completion_param "gogs domain")
387 386
 
388 387
         function_check gogs_create_database
389 388
         gogs_create_database
@@ -392,7 +391,7 @@ function restore_remote_gogs {
392 391
         GOGS_CONFIG_FILE=${GOGS_CONFIG_PATH}/app.ini
393 392
 
394 393
         function_check restore_database_from_friend
395
-        restore_database_from_friend gogs "${GIT_DOMAIN_NAME}"
394
+        restore_database_from_friend gogs "${GOGS_DOMAIN_NAME}"
396 395
         if [ -d "${SERVER_DIRECTORY}/backup/gogs" ]; then
397 396
             if [ ! -d $GOGS_CONFIG_PATH ]; then
398 397
                 mkdir -p $GOGS_CONFIG_PATH
@@ -449,19 +448,19 @@ function restore_remote_gogs {
449 448
 }
450 449
 
451 450
 function remove_gogs {
452
-    if [ ${#GIT_DOMAIN_NAME} -eq 0 ]; then
451
+    if [ ${#GOGS_DOMAIN_NAME} -eq 0 ]; then
453 452
         return
454 453
     fi
455 454
     systemctl stop gogs
456 455
     systemctl disable gogs
457 456
 
458
-    nginx_dissite "${GIT_DOMAIN_NAME}"
459
-    remove_certs "${GIT_DOMAIN_NAME}"
460
-    if [ -d "/var/www/${GIT_DOMAIN_NAME}" ]; then
461
-        rm -rf "/var/www/${GIT_DOMAIN_NAME}"
457
+    nginx_dissite "${GOGS_DOMAIN_NAME}"
458
+    remove_certs "${GOGS_DOMAIN_NAME}"
459
+    if [ -d "/var/www/${GOGS_DOMAIN_NAME}" ]; then
460
+        rm -rf "/var/www/${GOGS_DOMAIN_NAME}"
462 461
     fi
463
-    if [ -f "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}" ]; then
464
-        rm "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
462
+    if [ -f "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}" ]; then
463
+        rm "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
465 464
     fi
466 465
     function_check drop_database
467 466
     drop_database gogs
@@ -477,11 +476,11 @@ function remove_gogs {
477 476
     userdel -r gogs
478 477
 
479 478
     function_check remove_ddns_domain
480
-    remove_ddns_domain "$GIT_DOMAIN_NAME"
479
+    remove_ddns_domain "$GOGS_DOMAIN_NAME"
481 480
 }
482 481
 
483 482
 function install_gogs {
484
-    if [ ! "$GIT_DOMAIN_NAME" ]; then
483
+    if [ ! "$GOGS_DOMAIN_NAME" ]; then
485 484
         return
486 485
     fi
487 486
 
@@ -584,33 +583,33 @@ function install_gogs {
584 583
     systemctl daemon-reload
585 584
     systemctl start gogs
586 585
 
587
-    if [ ! -d "/var/www/${GIT_DOMAIN_NAME}" ]; then
588
-        mkdir "/var/www/${GIT_DOMAIN_NAME}"
586
+    if [ ! -d "/var/www/${GOGS_DOMAIN_NAME}" ]; then
587
+        mkdir "/var/www/${GOGS_DOMAIN_NAME}"
589 588
     fi
590
-    if [ -d "/var/www/${GIT_DOMAIN_NAME}/htdocs" ]; then
591
-        rm -rf "/var/www/${GIT_DOMAIN_NAME}/htdocs"
589
+    if [ -d "/var/www/${GOGS_DOMAIN_NAME}/htdocs" ]; then
590
+        rm -rf "/var/www/${GOGS_DOMAIN_NAME}/htdocs"
592 591
     fi
593 592
 
594 593
     if [[ "${ONION_ONLY}" == "no" ]]; then
595 594
         function_check nginx_http_redirect
596
-        nginx_http_redirect "${GIT_DOMAIN_NAME}"
595
+        nginx_http_redirect "${GOGS_DOMAIN_NAME}"
597 596
         { echo 'server {';
598 597
           echo '    listen 443 ssl;';
599 598
           echo '    #listen [::]:443 ssl;';
600
-          echo "    root /var/www/${GIT_DOMAIN_NAME}/htdocs;";
601
-          echo "    server_name ${GIT_DOMAIN_NAME};";
599
+          echo "    root /var/www/${GOGS_DOMAIN_NAME}/htdocs;";
600
+          echo "    server_name ${GOGS_DOMAIN_NAME};";
602 601
           echo '    access_log /dev/null;';
603 602
           echo "    error_log /dev/null;";
604
-          echo ''; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
603
+          echo ''; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
605 604
         function_check nginx_ssl
606
-        nginx_ssl "${GIT_DOMAIN_NAME}"
605
+        nginx_ssl "${GOGS_DOMAIN_NAME}"
607 606
         function_check nginx_security_options
608
-        nginx_security_options "${GIT_DOMAIN_NAME}"
607
+        nginx_security_options "${GOGS_DOMAIN_NAME}"
609 608
         { echo '    add_header Strict-Transport-Security max-age=0;';
610 609
           echo '';
611
-          echo '    location / {'; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
610
+          echo '    location / {'; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
612 611
         function_check nginx_limits
613
-        nginx_limits "${GIT_DOMAIN_NAME}" '10G'
612
+        nginx_limits "${GOGS_DOMAIN_NAME}" '10G'
614 613
         { echo "        proxy_pass http://localhost:${GOGS_PORT};";
615 614
           echo '    }';
616 615
           echo '';
@@ -625,24 +624,24 @@ function install_gogs {
625 624
           echo '        access_log /dev/null;';
626 625
           echo '    }';
627 626
           echo '}';
628
-          echo ''; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
627
+          echo ''; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
629 628
     else
630
-        echo -n '' > "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
629
+        echo -n '' > "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
631 630
     fi
632 631
     { echo 'server {';
633 632
       echo "    listen 127.0.0.1:${GIT_ONION_PORT} default_server;";
634
-      echo "    root /var/www/$GIT_DOMAIN_NAME/htdocs;";
635
-      echo "    server_name $GIT_DOMAIN_NAME;";
633
+      echo "    root /var/www/$GOGS_DOMAIN_NAME/htdocs;";
634
+      echo "    server_name $GOGS_DOMAIN_NAME;";
636 635
       echo '    access_log /dev/null;';
637 636
       echo "    error_log /dev/null;";
638
-      echo ''; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
637
+      echo ''; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
639 638
     function_check nginx_security_options
640
-    nginx_security_options "${GIT_DOMAIN_NAME}"
639
+    nginx_security_options "${GOGS_DOMAIN_NAME}"
641 640
     { echo '    add_header Strict-Transport-Security max-age=0;';
642 641
       echo '';
643
-      echo '    location / {'; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
642
+      echo '    location / {'; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
644 643
     function_check nginx_limits
645
-    nginx_limits "${GIT_DOMAIN_NAME}" '10G'
644
+    nginx_limits "${GOGS_DOMAIN_NAME}" '10G'
646 645
     { echo "        proxy_pass http://localhost:${GOGS_PORT};";
647 646
       echo '    }';
648 647
       echo '';
@@ -656,15 +655,15 @@ function install_gogs {
656 655
       echo '        log_not_found off;';
657 656
       echo '        access_log /dev/null;';
658 657
       echo '    }';
659
-      echo '}'; } >> "/etc/nginx/sites-available/${GIT_DOMAIN_NAME}"
658
+      echo '}'; } >> "/etc/nginx/sites-available/${GOGS_DOMAIN_NAME}"
660 659
 
661 660
     function_check configure_php
662 661
     configure_php
663 662
 
664 663
     function_check create_site_certificate
665
-    create_site_certificate "${GIT_DOMAIN_NAME}" 'yes'
664
+    create_site_certificate "${GOGS_DOMAIN_NAME}" 'yes'
666 665
 
667
-    nginx_ensite "${GIT_DOMAIN_NAME}"
666
+    nginx_ensite "${GOGS_DOMAIN_NAME}"
668 667
 
669 668
     if [ ! -d /var/lib/tor ]; then
670 669
         echo $'No Tor installation found. Gogs onion site cannot be configured.'
@@ -689,11 +688,11 @@ function install_gogs {
689 688
     systemctl restart php7.0-fpm
690 689
     systemctl restart nginx
691 690
 
692
-    set_completion_param "gogs domain" "$GIT_DOMAIN_NAME"
691
+    set_completion_param "gogs domain" "$GOGS_DOMAIN_NAME"
693 692
     set_completion_param "gogs onion domain" "$GIT_ONION_HOSTNAME"
694 693
 
695 694
     function_check add_ddns_domain
696
-    add_ddns_domain "${GIT_DOMAIN_NAME}"
695
+    add_ddns_domain "${GOGS_DOMAIN_NAME}"
697 696
 
698 697
     # obtain the secret key
699 698
     GOGS_SECRET_KEY="$(create_password "${MINIMUM_PASSWORD_LENGTH}")"
@@ -722,17 +721,17 @@ function install_gogs {
722 721
       echo '';
723 722
       echo '[server]'; } >> ${GOGS_CONFIG_FILE}
724 723
     if [[ ${ONION_ONLY} == 'no' ]]; then
725
-        echo "DOMAIN = ${GIT_DOMAIN_NAME}" >> ${GOGS_CONFIG_FILE}
726
-        echo "ROOT_URL = https://$GIT_DOMAIN_NAME/" >> ${GOGS_CONFIG_FILE}
724
+        echo "DOMAIN = ${GOGS_DOMAIN_NAME}" >> ${GOGS_CONFIG_FILE}
725
+        echo "ROOT_URL = https://$GOGS_DOMAIN_NAME/" >> ${GOGS_CONFIG_FILE}
727 726
     else
728 727
         echo "DOMAIN = ${GIT_ONION_HOSTNAME}" >> ${GOGS_CONFIG_FILE}
729
-        echo "ROOT_URL = http://$GIT_DOMAIN_NAME/" >> ${GOGS_CONFIG_FILE}
728
+        echo "ROOT_URL = http://$GOGS_DOMAIN_NAME/" >> ${GOGS_CONFIG_FILE}
730 729
     fi
731 730
     { echo "HTTP_PORT = ${GOGS_PORT}";
732 731
       echo "SSH_PORT = $SSH_PORT";
733 732
       echo 'SSH_DOMAIN = %(DOMAIN)s';
734
-      echo "CERT_FILE = /etc/ssl/certs/${GIT_DOMAIN_NAME}.pem";
735
-      echo "KEY_FILE = /etc/ssl/private/${GIT_DOMAIN_NAME}.key";
733
+      echo "CERT_FILE = /etc/ssl/certs/${GOGS_DOMAIN_NAME}.pem";
734
+      echo "KEY_FILE = /etc/ssl/private/${GOGS_DOMAIN_NAME}.key";
736 735
       echo 'DISABLE_ROUTER_LOG = true';
737 736
       echo '';
738 737
       echo '[session]';
@@ -762,9 +761,9 @@ function install_gogs {
762 761
     systemctl restart gogs
763 762
 
764 763
     if ! grep -q "gogs domain:" "${COMPLETION_FILE}"; then
765
-        echo "gogs domain:${GIT_DOMAIN_NAME}" >> "${COMPLETION_FILE}"
764
+        echo "gogs domain:${GOGS_DOMAIN_NAME}" >> "${COMPLETION_FILE}"
766 765
     else
767
-        sed -i "s|gogs domain.*|gogs domain:${GIT_DOMAIN_NAME}|g" "${COMPLETION_FILE}"
766
+        sed -i "s|gogs domain.*|gogs domain:${GOGS_DOMAIN_NAME}|g" "${COMPLETION_FILE}"
768 767
     fi
769 768
 
770 769
     function_check configure_firewall_for_git

+ 2
- 2
src/freedombone-config 查看文件

@@ -74,8 +74,8 @@ GNUSOCIAL_DOMAIN_NAME=
74 74
 GNUSOCIAL_CODE=
75 75
 GNUSOCIAL_WELCOME_MESSAGE=$"<h1>Welcome to \$GNUSOCIAL_DOMAIN_NAME  a federated social network</h1><p>Another $PROJECT_NAME site</p>"
76 76
 GNUSOCIAL_BACKGROUND_IMAGE_URL=
77
-GIT_DOMAIN_NAME=
78
-GIT_CODE=
77
+GOGS_DOMAIN_NAME=
78
+GOGS_CODE=
79 79
 USB_DRIVE=/dev/sdb1
80 80
 HWRNG_TYPE=
81 81
 ENABLE_SOCIAL_KEY_MANAGEMENT=

+ 2
- 2
src/freedombone-utils-onion 查看文件

@@ -211,7 +211,7 @@ function set_default_onion_domains {
211 211
     BLUDIT_DOMAIN_NAME='bludit.local'
212 212
     DOKUWIKI_DOMAIN_NAME='dokuwiki.local'
213 213
     DEFAULT_DOMAIN_NAME="${LOCAL_NAME}.local"
214
-    GIT_DOMAIN_NAME='gogs.local'
214
+    GOGS_DOMAIN_NAME='gogs.local'
215 215
 }
216 216
 
217 217
 function create_avahi_onion_domains {
@@ -229,7 +229,7 @@ function create_avahi_onion_domains {
229 229
         function_check create_avahi_service
230 230
         create_avahi_service blog http tcp "$HTMLY_ONION_PORT"
231 231
     fi
232
-    if [ $GIT_DOMAIN_NAME ]; then
232
+    if [ $GOGS_DOMAIN_NAME ]; then
233 233
         function_check create_avahi_service
234 234
         create_avahi_service git http tcp "$GIT_ONION_PORT"
235 235
     fi