From 955142b3825fe56c18b40be9e55ffe48797d5df2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 18 Jun 2017 12:59:56 +0100 Subject: [PATCH] Abstract out the sharings plugin --- src/freedombone-app-gnusocial | 136 +-------------------------- src/freedombone-app-postactiv | 3 +- src/freedombone-utils-gnusocialtools | 132 ++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 135 deletions(-) diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index c77ee634..f6afd221 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -44,12 +44,6 @@ GNUSOCIAL_BACKGROUND_IMAGE_URL= GNUSOCIAL_MARKDOWN_REPO="https://git.gnu.io/chimo/markdown.git" GNUSOCIAL_MARKDOWN_COMMIT='03c53942f94b3376f0946e6e1fe566cc21ccf232' -# Sharings plugin for gnusocial -SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings" -SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4' -SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme" -SHARINGS_THEME_COMMIT='7106c7ef03' - GNUSOCIAL_TITLE='Pleroma FE' # Number of months after which posts expire @@ -61,10 +55,7 @@ gnusocial_variables=(ONION_ONLY GNUSOCIAL_WELCOME_MESSAGE GNUSOCIAL_BACKGROUND_IMAGE_URL DDNS_PROVIDER - GNUSOCIAL_MARKDOWN_REPO GNUSOCIAL_MARKDOWN_COMMIT - SHARINGS_REPO - SHARINGS_THEME_REPO GNUSOCIAL_TITLE GNUSOCIAL_EXPIRE_MONTHS MY_USERNAME) @@ -797,129 +788,6 @@ function install_gnusocial_main { install_completed gnusocial_main } -function install_gnusocial_plugin_sharings { - if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then - echo $'No local/plugins directory found for the gnusocial' - exit 72945 - fi - - apt-get -yq install liblocale-msgfmt-perl gettext - - # update to the next commit - function_check set_repo_commit - set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO - - if [[ $(app_is_installed gnusocial_plugin_sharings) == "1" ]]; then - return - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins - - if [ -d /repos/sharings ]; then - mkdir Sharings - cp -r -p /repos/sharings/. Sharings - cd Sharings - git pull - else - function_check git_clone - git_clone $SHARINGS_REPO Sharings - fi - - if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings ]; then - echo $'Unable to clone gnusocial sharings plugin' - exit 36738 - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings - git stash - git checkout master - git branch -D $SHARINGS_COMMIT - git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT - - # enable the plugin - if ! grep -q "addPlugin('Sharings');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then - echo "addPlugin('Sharings');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs - php scripts/checkschema.php - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings - php scripts/seedsharings.php - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs - php scripts/upgrade.php - php scripts/checkschema.php - - # Languages - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES - msgfmt -o Sharings.mo Sharings.po - if [ ! -f Sharings.po ]; then - echo $'English translations for gnusocial sharings plugin were not created' - exit 84352 - fi - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES - msgfmt -o Sharings.mo Sharings.po - if [ ! -f Sharings.po ]; then - echo $'English (GB) translations for gnusocial sharings plugin were not created' - exit 84352 - fi - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES - msgfmt -o Sharings.mo Sharings.po - if [ ! -f Sharings.po ]; then - echo $'English (US) translations for gnusocial sharings plugin were not created' - exit 84352 - fi - - # Looks like this update function isn't supported by the current php version - sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/Sharings/SharingsPlugin.php - - chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs - - set_completion_param gnusocial "sharings plugin commit" "$SHARINGS_COMMIT" - install_completed gnusocial_plugin_sharings -} - -function install_gnusocial_plugin_sharings_theme { - if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins ]; then - echo $'No local/plugins directory found for the gnusocial' - exit 74458 - fi - - # update to the next commit - function_check set_repo_commit - set_repo_commit /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins "gnusocial sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO - - if [[ $(app_is_installed gnusocial_plugin_sharings_theme) == "1" ]]; then - return - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins - function_check git_clone - git_clone $SHARINGS_THEME_REPO SharingsTheme - if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme ]; then - echo $'Unable to clone gnusocial sharings plugin theme' - exit 639253 - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/local/plugins/SharingsTheme - git stash - git checkout master - git branch -D $SHARINGS_THEME_COMMIT - git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT - - # enable the plugin - if ! grep -q "addPlugin('SharingsTheme');" /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php; then - echo "addPlugin('SharingsTheme');" >> /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/config.php - fi - - cd /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs - php scripts/checkschema.php - - chown -R www-data:www-data /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs - - set_completion_param "gnusocial sharings plugin theme commit" "$SHARINGS_THEME_COMMIT" - install_completed gnusocial_plugin_sharings_theme -} - function install_gnusocial_markdown { GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs @@ -977,8 +845,8 @@ function install_gnusocial { expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS" install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" install_gnusocial_markdown - #install_gnusocial_plugin_sharings - #install_gnusocial_plugin_sharings_theme + install_gnusocial_plugin_sharings "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" + install_gnusocial_plugin_sharings_theme "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" # Currently Pleroma won't install on ARM systems # because it uses node-sass which doesn't support ARM diff --git a/src/freedombone-app-postactiv b/src/freedombone-app-postactiv index cf6e8694..690c64c9 100755 --- a/src/freedombone-app-postactiv +++ b/src/freedombone-app-postactiv @@ -807,7 +807,8 @@ function install_postactiv { install_postactiv_main install_qvitter "$POSTACTIV_DOMAIN_NAME" "postactiv" - + install_gnusocial_plugin_sharings "$POSTACTIV_DOMAIN_NAME" "postactiv" + install_gnusocial_plugin_sharings_theme "$POSTACTIV_DOMAIN_NAME" "postactiv" #function_check install_nodejs #install_nodejs pleroma-postactiv diff --git a/src/freedombone-utils-gnusocialtools b/src/freedombone-utils-gnusocialtools index fe931bda..ad9b97e6 100755 --- a/src/freedombone-utils-gnusocialtools +++ b/src/freedombone-utils-gnusocialtools @@ -37,6 +37,11 @@ PLEROMA_COMMIT='7d46e3965d06e039537066eeb5fac99ebcab978d' ARMADILLO_REPO="https://git.postactiv.com/maiya/Armadillo" ARMADILLO_COMMIT='ec3938a678f373156c4cbf37926c9a5ab68222c4' +SHARINGS_REPO="http://git.lasindias.club/bashrc/Sharings" +SHARINGS_COMMIT='d5c6c7f855d9afff9086c09ea706f38c859bc0d4' +SHARINGS_THEME_REPO="http://git.lasindias.club/manuel/SharingsTheme" +SHARINGS_THEME_COMMIT='7106c7ef03' + function qvitter_update_background { domain_name="$1" ext=$2 @@ -877,4 +882,131 @@ function gnusocial_use_armadillo { systemctl restart nginx } +function install_gnusocial_plugin_sharings { + domain_name=$1 + social_app_name=$2 + + if [ ! -d /var/www/$domain_name/htdocs/local/plugins ]; then + mkdir -p /var/www/$domain_name/htdocs/local/plugins + fi + + apt-get -yq install liblocale-msgfmt-perl gettext + + # update to the next commit + function_check set_repo_commit + set_repo_commit /var/www/$domain_name/htdocs/local/plugins "$social_app_name sharings plugin commit" "$SHARINGS_COMMIT" $SHARINGS_REPO + + if [[ $(app_is_installed ${social_app_name}_plugin_sharings) == "1" ]]; then + return + fi + + cd /var/www/$domain_name/htdocs/local/plugins + + if [ -d /repos/sharings ]; then + mkdir Sharings + cp -r -p /repos/sharings/. Sharings + cd Sharings + git pull + else + function_check git_clone + git_clone $SHARINGS_REPO Sharings + fi + + if [ ! -d /var/www/$domain_name/htdocs/local/plugins/Sharings ]; then + echo $"Unable to clone $social_app_name sharings plugin" + exit 36738 + fi + + cd /var/www/$domain_name/htdocs/local/plugins/Sharings + git stash + git checkout master + git branch -D $SHARINGS_COMMIT + git checkout $SHARINGS_COMMIT -b $SHARINGS_COMMIT + + # enable the plugin + if ! grep -q "addPlugin('Sharings');" /var/www/$domain_name/htdocs/config.php; then + echo "addPlugin('Sharings');" >> /var/www/$domain_name/htdocs/config.php + fi + + cd /var/www/$domain_name/htdocs + php scripts/checkschema.php + cd /var/www/$domain_name/htdocs/local/plugins/Sharings + php scripts/seedsharings.php + cd /var/www/$domain_name/htdocs + php scripts/upgrade.php + php scripts/checkschema.php + + # Languages + cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en/LC_MESSAGES + msgfmt -o Sharings.mo Sharings.po + if [ ! -f Sharings.po ]; then + echo $"English translations for $social_app_name sharings plugin were not created" + exit 782923 + fi + cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en_GB/LC_MESSAGES + msgfmt -o Sharings.mo Sharings.po + if [ ! -f Sharings.po ]; then + echo $"English (GB) translations for $social_app_name sharings plugin were not created" + exit 23528 + fi + cd /var/www/$domain_name/htdocs/local/plugins/Sharings/locale/en_US/LC_MESSAGES + msgfmt -o Sharings.mo Sharings.po + if [ ! -f Sharings.po ]; then + echo $"English (US) translations for $social_app_name sharings plugin were not created" + exit 567382 + fi + + # Looks like this update function isn't supported by the current php version + sed -i 's|ActivityVerb::UPDATE, ||g' /var/www/$domain_name/htdocs/local/plugins/Sharings/SharingsPlugin.php + + chown -R www-data:www-data /var/www/$domain_name/htdocs + + set_completion_param gnusocial "$social_app_name sharings plugin commit" "$SHARINGS_COMMIT" + install_completed ${social_app_name}_plugin_sharings +} + +function install_gnusocial_plugin_sharings_theme { + domain_name=$1 + social_app_name=$2 + + if [ ! -d /var/www/$domain_name/htdocs/local/plugins ]; then + mkdir -p /var/www/$domain_name/htdocs/local/plugins + fi + + # update to the next commit + function_check set_repo_commit + set_repo_commit /var/www/$domain_name/htdocs/local/plugins "$social_app_name sharings theme plugin commit" "$SHARINGS_THEME_COMMIT" $SHARINGS_THEME_REPO + + if [[ $(app_is_installed ${social_app_name}_plugin_sharings_theme) == "1" ]]; then + return + fi + + cd /var/www/$domain_name/htdocs/local/plugins + function_check git_clone + git_clone $SHARINGS_THEME_REPO SharingsTheme + if [ ! -d /var/www/$domain_name/htdocs/local/plugins/SharingsTheme ]; then + echo $"Unable to clone $social_app_name sharings plugin theme" + exit 639253 + fi + + cd /var/www/$domain_name/htdocs/local/plugins/SharingsTheme + git stash + git checkout master + git branch -D $SHARINGS_THEME_COMMIT + git checkout $SHARINGS_THEME_COMMIT -b $SHARINGS_THEME_COMMIT + + # enable the plugin + if ! grep -q "addPlugin('SharingsTheme');" /var/www/$domain_name/htdocs/config.php; then + echo "addPlugin('SharingsTheme');" >> /var/www/$domain_name/htdocs/config.php + fi + + cd /var/www/$domain_name/htdocs + php scripts/checkschema.php + + chown -R www-data:www-data /var/www/$domain_name/htdocs + + set_completion_param "$social_app_name sharings plugin theme commit" "$SHARINGS_THEME_COMMIT" + install_completed ${social_app_name}_plugin_sharings_theme +} + # NOTE: deliberately there is no "exit 0"