|
@@ -13,7 +13,7 @@
|
13
|
13
|
# License
|
14
|
14
|
# =======
|
15
|
15
|
#
|
16
|
|
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
|
|
16
|
+# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
|
17
|
17
|
#
|
18
|
18
|
# This program is free software: you can redistribute it and/or modify
|
19
|
19
|
# it under the terms of the GNU Affero General Public License as published by
|
|
@@ -54,11 +54,11 @@ SHARINGS_THEME_COMMIT='7106c7ef03'
|
54
|
54
|
GNUSOCIAL_NSFW_REPO="https://gitgud.io/ShitposterClub/SensitiveContent"
|
55
|
55
|
GNUSOCIAL_NSFW_COMMIT='a096bbe0cfae9a9b177682920ffb58d32a48e136'
|
56
|
56
|
|
57
|
|
-# script which causes old posts to expire
|
58
|
|
-gnusocial_expire_script=/usr/bin/gnusocial-expire
|
59
|
|
-
|
60
|
57
|
GNUSOCIAL_TITLE='Pleroma FE'
|
61
|
58
|
|
|
59
|
+# Number of months after which posts expire
|
|
60
|
+GNUSOCIAL_EXPIRE_MONTHS=3
|
|
61
|
+
|
62
|
62
|
gnusocial_variables=(ONION_ONLY
|
63
|
63
|
GNUSOCIAL_DOMAIN_NAME
|
64
|
64
|
GNUSOCIAL_CODE
|
|
@@ -72,6 +72,7 @@ gnusocial_variables=(ONION_ONLY
|
72
|
72
|
SHARINGS_THEME_REPO
|
73
|
73
|
SHARINGS_THEME_COMMIT
|
74
|
74
|
GNUSOCIAL_TITLE
|
|
75
|
+ GNUSOCIAL_EXPIRE_MONTHS
|
75
|
76
|
MY_USERNAME)
|
76
|
77
|
|
77
|
78
|
function gnusocial_fix_endless_reloads {
|
|
@@ -843,59 +844,6 @@ function install_gnusocial_plugin_sharings_theme {
|
843
|
844
|
install_completed gnusocial_plugin_sharings_theme
|
844
|
845
|
}
|
845
|
846
|
|
846
|
|
-function expire_gnusocial_posts {
|
847
|
|
- # To prevent the database size from growing endlessly this script expires posts
|
848
|
|
- # after a number of months
|
849
|
|
- if [ ! -d /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs ]; then
|
850
|
|
- return
|
851
|
|
- fi
|
852
|
|
-
|
853
|
|
- echo '<?php' > $gnusocial_expire_script
|
854
|
|
- echo '' >> $gnusocial_expire_script
|
855
|
|
- echo '// gnusocial post expiry script, based on StatExpire by Tony Baldwin' >> $gnusocial_expire_script
|
856
|
|
- echo '// https://github.com/tonybaldwin/statexpire' >> $gnusocial_expire_script
|
857
|
|
- echo '' >> $gnusocial_expire_script
|
858
|
|
- echo '$oldate=date(("Y-m-d"), strtotime("-3 months"));' >> $gnusocial_expire_script
|
859
|
|
- echo '$username="root";' >> $gnusocial_expire_script
|
860
|
|
- echo "\$password=shell_exec('${PROJECT_NAME}-pass -u root -a mariadb');" >> $gnusocial_expire_script
|
861
|
|
- echo '$database="gnusocial";' >> $gnusocial_expire_script
|
862
|
|
- echo '' >> $gnusocial_expire_script
|
863
|
|
- echo 'if (!$link = mysql_connect("localhost", $username, $password)) {' >> $gnusocial_expire_script
|
864
|
|
- echo ' echo "Could not connect to mariadb";' >> $gnusocial_expire_script
|
865
|
|
- echo ' exit;' >> $gnusocial_expire_script
|
866
|
|
- echo '}' >> $gnusocial_expire_script
|
867
|
|
- echo '' >> $gnusocial_expire_script
|
868
|
|
- echo 'if (!mysql_select_db($database, $link)) {' >> $gnusocial_expire_script
|
869
|
|
- echo ' echo "Could not select gnusocial database";' >> $gnusocial_expire_script
|
870
|
|
- echo ' exit;' >> $gnusocial_expire_script
|
871
|
|
- echo '}' >> $gnusocial_expire_script
|
872
|
|
- echo '' >> $gnusocial_expire_script
|
873
|
|
- echo "\$notice_query=\"DELETE FROM notice WHERE created <= '\$oldate 01:01:01'\";" >> $gnusocial_expire_script
|
874
|
|
- echo "\$conversation_query=\"DELETE FROM conversation WHERE created <= '$oldate 01:01:01'\";" >> $gnusocial_expire_script
|
875
|
|
- echo "\$reply_query=\"DELETE FROM reply WHERE modified <= '\$oldate 01:01:01'\";" >> $gnusocial_expire_script
|
876
|
|
- echo '' >> $gnusocial_expire_script
|
877
|
|
- echo 'mysql_query($notice_query);' >> $gnusocial_expire_script
|
878
|
|
- echo '$rowaff1=mysql_affected_rows();' >> $gnusocial_expire_script
|
879
|
|
- echo 'mysql_query($conversation_query);' >> $gnusocial_expire_script
|
880
|
|
- echo '$rowaff2=mysql_affected_rows();' >> $gnusocial_expire_script
|
881
|
|
- echo 'mysql_query($reply_query);' >> $gnusocial_expire_script
|
882
|
|
- echo '$rowaff3=mysql_affected_rows();' >> $gnusocial_expire_script
|
883
|
|
- echo 'mysql_close();' >> $gnusocial_expire_script
|
884
|
|
- echo '' >> $gnusocial_expire_script
|
885
|
|
- echo 'echo "Expire gnusocial posts: $rowaff1 notices, $rowaff2 conversations, and $rowaff3 replies deleted from database.\n";' >> $gnusocial_expire_script
|
886
|
|
- chmod +x $gnusocial_expire_script
|
887
|
|
-
|
888
|
|
- # Add a cron job
|
889
|
|
- if ! grep -q "$gnusocial_expire_script" /etc/crontab; then
|
890
|
|
- echo "10 3 5 * * root /usr/bin/timeout 500 /usr/bin/php $gnusocial_expire_script" >> /etc/crontab
|
891
|
|
- fi
|
892
|
|
-
|
893
|
|
- # remove old expire script
|
894
|
|
- if [ -f /etc/cron.weekly/clear-gnusocial-database ]; then
|
895
|
|
- rm /etc/cron.weekly/clear-gnusocial-database
|
896
|
|
- fi
|
897
|
|
-}
|
898
|
|
-
|
899
|
847
|
function install_gnusocial_markdown {
|
900
|
848
|
GNUSOCIAL_PATH=/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs
|
901
|
849
|
|
|
@@ -983,7 +931,7 @@ function install_gnusocial {
|
983
|
931
|
fi
|
984
|
932
|
|
985
|
933
|
install_gnusocial_main
|
986
|
|
- expire_gnusocial_posts
|
|
934
|
+ expire_gnusocial_posts "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_EXPIRE_MONTHS"
|
987
|
935
|
install_qvitter "$GNUSOCIAL_DOMAIN_NAME" "gnusocial"
|
988
|
936
|
install_gnusocial_markdown
|
989
|
937
|
#install_gnusocial_plugin_sharings
|