Browse Source

Abstract out the sharings plugin

Bob Mottram 7 years ago
parent
commit
955142b382
3 changed files with 136 additions and 135 deletions
  1. 2
    134
      src/freedombone-app-gnusocial
  2. 2
    1
      src/freedombone-app-postactiv
  3. 132
    0
      src/freedombone-utils-gnusocialtools

+ 2
- 134
src/freedombone-app-gnusocial View File

@@ -44,12 +44,6 @@ GNUSOCIAL_BACKGROUND_IMAGE_URL=
44 44
 GNUSOCIAL_MARKDOWN_REPO="https://git.gnu.io/chimo/markdown.git"
45 45
 GNUSOCIAL_MARKDOWN_COMMIT='03c53942f94b3376f0946e6e1fe566cc21ccf232'
46 46
 
47
-# Sharings plugin for gnusocial
48
-SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings"
49
-SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4'
50
-SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme"
51
-SHARINGS_THEME_COMMIT='7106c7ef03'
52
-
53 47
 GNUSOCIAL_TITLE='Pleroma FE'
54 48
 
55 49
 # Number of months after which posts expire
@@ -61,10 +55,7 @@ gnusocial_variables=(ONION_ONLY
61 55
                      GNUSOCIAL_WELCOME_MESSAGE
62 56
                      GNUSOCIAL_BACKGROUND_IMAGE_URL
63 57
                      DDNS_PROVIDER
64
-                     GNUSOCIAL_MARKDOWN_REPO
65 58
                      GNUSOCIAL_MARKDOWN_COMMIT
66
-                     SHARINGS_REPO
67
-                     SHARINGS_THEME_REPO
68 59
                      GNUSOCIAL_TITLE
69 60
                      GNUSOCIAL_EXPIRE_MONTHS
70 61
                      MY_USERNAME)
@@ -797,129 +788,6 @@ function install_gnusocial_main {
797 788
     install_completed gnusocial_main
798 789
 }
799 790
 
800
-function install_gnusocial_plugin_sharings {
801
-    if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
802
-        echo $'No local/plugins directory found for the gnusocial'
803
-        exit 72945
804
-    fi
805
-
806
-    apt-get -yq install liblocale-msgfmt-perl gettext
807
-
808
-    # update to the next commit
809
-    function_check set_repo_commit
810
-    set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
811
-
812
-    if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then
813
-        return
814
-    fi
815
-
816
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
817
-
818
-    if [ -d /repos/sharings ]; then
819
-        mkdir Sharings
820
-        cp -r -p /repos/sharings/. Sharings
821
-        cd Sharings
822
-        git pull
823
-    else
824
-        function_check git_clone
825
-        git_clone $SHARINGS_REPO Sharings
826
-    fi
827
-
828
-    if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then
829
-        echo $'Unable to clone gnusocial sharings plugin'
830
-        exit 36738
831
-    fi
832
-
833
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
834
-    git stash
835
-    git checkout master
836
-    git branch -D $SHARINGS_COMMIT
837
-    git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
838
-
839
-    # enable the plugin
840
-    if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
841
-        echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
842
-    fi
843
-
844
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
845
-    php scripts/checkschema.php
846
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings
847
-    php scripts/seedsharings.php
848
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
849
-    php scripts/upgrade.php
850
-    php scripts/checkschema.php
851
-
852
-    # Languages
853
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
854
-    msgfmt -o Sharings.mo Sharings.po
855
-    if [ ! -f Sharings.po ]; then
856
-        echo $'English translations for gnusocial sharings plugin were not created'
857
-        exit 84352
858
-    fi
859
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
860
-    msgfmt -o Sharings.mo Sharings.po
861
-    if [ ! -f Sharings.po ]; then
862
-        echo $'English (GB) translations for gnusocial sharings plugin were not created'
863
-        exit 84352
864
-    fi
865
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES
866
-    msgfmt -o Sharings.mo Sharings.po
867
-    if [ ! -f Sharings.po ]; then
868
-        echo $'English (US) translations for gnusocial sharings plugin were not created'
869
-        exit 84352
870
-    fi
871
-
872
-    # Looks like this update function isn't supported by the current php version
873
-    sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php
874
-
875
-    chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
876
-
877
-    set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT"
878
-    install_completed gnusocial_plugin_sharings
879
-}
880
-
881
-function install_gnusocial_plugin_sharings_theme {
882
-    if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then
883
-        echo $'No local/plugins directory found for the gnusocial'
884
-        exit 74458
885
-    fi
886
-
887
-    # update to the next commit
888
-    function_check set_repo_commit
889
-    set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
890
-
891
-    if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then
892
-        return
893
-    fi
894
-
895
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins
896
-    function_check git_clone
897
-    git_clone $SHARINGS_THEME_REPO SharingsTheme
898
-    if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then
899
-        echo $'Unable to clone gnusocial sharings plugin theme'
900
-        exit 639253
901
-    fi
902
-
903
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme
904
-    git stash
905
-    git checkout master
906
-    git branch -D $SHARINGS_THEME_COMMIT
907
-    git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
908
-
909
-    # enable the plugin
910
-    if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then
911
-        echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php
912
-    fi
913
-
914
-    cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
915
-    php scripts/checkschema.php
916
-
917
-    chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
918
-
919
-    set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
920
-    install_completed gnusocial_plugin_sharings_theme
921
-}
922
-
923 791
 function install_gnusocial_markdown {
924 792
     GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
925 793
 
@@ -977,8 +845,8 @@ function install_gnusocial {
977 845
     expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
978 846
     install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
979 847
     install_gnusocial_markdown
980
-    #install_gnusocial_plugin_sharings
981
-    #install_gnusocial_plugin_sharings_theme
848
+    install_gnusocial_plugin_sharings "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
849
+    install_gnusocial_plugin_sharings_theme "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
982 850
 
983 851
     # Currently Pleroma won't install on ARM systems
984 852
     # because it uses node-sass which doesn't support ARM

+ 2
- 1
src/freedombone-app-postactiv View File

@@ -807,7 +807,8 @@ function install_postactiv {
807 807
 
808 808
     install_postactiv_main
809 809
     install_qvitter "$POSTACTIV_DOMAIN_NAME" "postactiv"
810
-
810
+    install_gnusocial_plugin_sharings "$POSTACTIV_DOMAIN_NAME" "postactiv"
811
+    install_gnusocial_plugin_sharings_theme "$POSTACTIV_DOMAIN_NAME" "postactiv"
811 812
     #function_check install_nodejs
812 813
     #install_nodejs pleroma-postactiv
813 814
 

+ 132
- 0
src/freedombone-utils-gnusocialtools View File

@@ -37,6 +37,11 @@ PLEROMA_COMMIT='7d46e3965d06e039537066eeb5fac99ebcab978d'
37 37
 ARMADILLO_REPO="https://git.postactiv.com/maiya/Armadillo"
38 38
 ARMADILLO_COMMIT='ec3938a678f373156c4cbf37926c9a5ab68222c4'
39 39
 
40
+SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings"
41
+SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4'
42
+SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme"
43
+SHARINGS_THEME_COMMIT='7106c7ef03'
44
+
40 45
 function qvitter_update_background {
41 46
     domain_name="$1"
42 47
     ext=$2
@@ -877,4 +882,131 @@ function gnusocial_use_armadillo {
877 882
     systemctl restart nginx
878 883
 }
879 884
 
885
+function install_gnusocial_plugin_sharings {
886
+    domain_name=$1
887
+    social_app_name=$2
888
+
889
+    if [ ! -d /var/www/$domain_name/htdocs/local/plugins ]; then
890
+        mkdir -p /var/www/$domain_name/htdocs/local/plugins
891
+    fi
892
+
893
+    apt-get -yq install liblocale-msgfmt-perl gettext
894
+
895
+    # update to the next commit
896
+    function_check set_repo_commit
897
+    set_repo_commit /var/www/$domain_name/htdocs/local/plugins "$social_app_name sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO
898
+
899
+    if [[ $(app_is_installed ${social_app_name}_plugin_sharings) == "1" ]]; then
900
+        return
901
+    fi
902
+
903
+    cd /var/www/$domain_name/htdocs/local/plugins
904
+
905
+    if [ -d /repos/sharings ]; then
906
+        mkdir Sharings
907
+        cp -r -p /repos/sharings/. Sharings
908
+        cd Sharings
909
+        git pull
910
+    else
911
+        function_check git_clone
912
+        git_clone $SHARINGS_REPO Sharings
913
+    fi
914
+
915
+    if [ ! -d /var/www/$domain_name/htdocs/local/plugins/Sharings ]; then
916
+        echo $"Unable to clone $social_app_name sharings plugin"
917
+        exit 36738
918
+    fi
919
+
920
+    cd /var/www/$domain_name/htdocs/local/plugins/Sharings
921
+    git stash
922
+    git checkout master
923
+    git branch -D $SHARINGS_COMMIT
924
+    git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT
925
+
926
+    # enable the plugin
927
+    if ! grep -q "addPlugin('Sharings');" /var/www/$domain_name/htdocs/config.php; then
928
+        echo "addPlugin('Sharings');" >> /var/www/$domain_name/htdocs/config.php
929
+    fi
930
+
931
+    cd /var/www/$domain_name/htdocs
932
+    php scripts/checkschema.php
933
+    cd /var/www/$domain_name/htdocs/local/plugins/Sharings
934
+    php scripts/seedsharings.php
935
+    cd /var/www/$domain_name/htdocs
936
+    php scripts/upgrade.php
937
+    php scripts/checkschema.php
938
+
939
+    # Languages
940
+    cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES
941
+    msgfmt -o Sharings.mo Sharings.po
942
+    if [ ! -f Sharings.po ]; then
943
+        echo $"English translations for $social_app_name sharings plugin were not created"
944
+        exit 782923
945
+    fi
946
+    cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES
947
+    msgfmt -o Sharings.mo Sharings.po
948
+    if [ ! -f Sharings.po ]; then
949
+        echo $"English (GB) translations for $social_app_name sharings plugin were not created"
950
+        exit 23528
951
+    fi
952
+    cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES
953
+    msgfmt -o Sharings.mo Sharings.po
954
+    if [ ! -f Sharings.po ]; then
955
+        echo $"English (US) translations for $social_app_name sharings plugin were not created"
956
+        exit 567382
957
+    fi
958
+
959
+    # Looks like this update function isn't supported by the current php version
960
+    sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$domain_name/htdocs/local/plugins/Sharings/SharingsPlugin.php
961
+
962
+    chown -R www-data:www-data /var/www/$domain_name/htdocs
963
+
964
+    set_completion_param gnusocial "$social_app_name sharings plugin commit" "$SHARINGS_COMMIT"
965
+    install_completed ${social_app_name}_plugin_sharings
966
+}
967
+
968
+function install_gnusocial_plugin_sharings_theme {
969
+    domain_name=$1
970
+    social_app_name=$2
971
+
972
+    if [ ! -d /var/www/$domain_name/htdocs/local/plugins ]; then
973
+        mkdir -p /var/www/$domain_name/htdocs/local/plugins
974
+    fi
975
+
976
+    # update to the next commit
977
+    function_check set_repo_commit
978
+    set_repo_commit /var/www/$domain_name/htdocs/local/plugins "$social_app_name sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO
979
+
980
+    if [[ $(app_is_installed ${social_app_name}_plugin_sharings_theme) == "1" ]]; then
981
+        return
982
+    fi
983
+
984
+    cd /var/www/$domain_name/htdocs/local/plugins
985
+    function_check git_clone
986
+    git_clone $SHARINGS_THEME_REPO SharingsTheme
987
+    if [ ! -d /var/www/$domain_name/htdocs/local/plugins/SharingsTheme ]; then
988
+        echo $"Unable to clone $social_app_name sharings plugin theme"
989
+        exit 639253
990
+    fi
991
+
992
+    cd /var/www/$domain_name/htdocs/local/plugins/SharingsTheme
993
+    git stash
994
+    git checkout master
995
+    git branch -D $SHARINGS_THEME_COMMIT
996
+    git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT
997
+
998
+    # enable the plugin
999
+    if ! grep -q "addPlugin('SharingsTheme');" /var/www/$domain_name/htdocs/config.php; then
1000
+        echo "addPlugin('SharingsTheme');" >> /var/www/$domain_name/htdocs/config.php
1001
+    fi
1002
+
1003
+    cd /var/www/$domain_name/htdocs
1004
+    php scripts/checkschema.php
1005
+
1006
+    chown -R www-data:www-data /var/www/$domain_name/htdocs
1007
+
1008
+    set_completion_param "$social_app_name sharings plugin theme commit" "$SHARINGS_THEME_COMMIT"
1009
+    install_completed ${social_app_name}_plugin_sharings_theme
1010
+}
1011
+
880 1012
 # NOTE: deliberately there is no "exit 0"