Browse Source

Switch from git to gogs to maintain consistency

Bob Mottram 6 years ago
parent
commit
989c48f88b
3 changed files with 58 additions and 59 deletions
  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 View File

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

+ 2
- 2
src/freedombone-config View File

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

+ 2
- 2
src/freedombone-utils-onion View File

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