Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
bbfa6d35
Commit
bbfa6d35
authored
7 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Also expire files uploaded to gnusocial/postactiv
parent
a59923cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-utils-gnusocialtools
+44
-36
44 additions, 36 deletions
src/freedombone-utils-gnusocialtools
with
44 additions
and
36 deletions
src/freedombone-utils-gnusocialtools
+
44
−
36
View file @
bbfa6d35
...
@@ -503,53 +503,61 @@ function expire_gnusocial_posts {
...
@@ -503,53 +503,61 @@ function expire_gnusocial_posts {
expire_months
=
3
expire_months
=
3
fi
fi
expire_days
=
$((
expire_months
*
30
))
# To prevent the database size from growing endlessly this script expires posts
# To prevent the database size from growing endlessly this script expires posts
# after a number of months
# after a number of months
if
[
!
-d
/var/www/
${
domain_name
}
/htdocs
]
;
then
if
[
!
-d
/var/www/
${
domain_name
}
/htdocs
]
;
then
return
return
fi
fi
gnusocial_expire_script
=
/usr/bin/
${
gnusocial_type
}
-expire
gnusocial_expire_posts_script
=
/usr/bin/
${
gnusocial_type
}
-expire-posts
echo
'<?php'
>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
"//
${
gnusocial_type
}
post expiry script, based on StatExpire by Tony Baldwin"
>>
$gnusocial_expire_posts_script
echo
'// https://github.com/tonybaldwin/statexpire'
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
"
\$
oldate=date((
\"
Y-m-d
\"
), strtotime(
\"
-
${
expire_months
}
months
\"
));"
>>
$gnusocial_expire_posts_script
echo
'$username="root";'
>>
$gnusocial_expire_posts_script
echo
"
\$
password=shell_exec('
${
PROJECT_NAME
}
-pass -u root -a mariadb');"
>>
$gnusocial_expire_posts_script
echo
"
\$
database=
\"
${
gnusocial_type
}
\"
;"
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
'if (!$link = mysql_connect("localhost", $username, $password)) {'
>>
$gnusocial_expire_posts_script
echo
' echo "Could not connect to mariadb";'
>>
$gnusocial_expire_posts_script
echo
' exit;'
>>
$gnusocial_expire_posts_script
echo
'}'
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
'if (!mysql_select_db($database, $link)) {'
>>
$gnusocial_expire_posts_script
echo
" echo
\"
Could not select
${
gnusocial_type
}
database
\"
;"
>>
$gnusocial_expire_posts_script
echo
' exit;'
>>
$gnusocial_expire_posts_script
echo
'}'
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
"
\$
notice_query=
\"
DELETE FROM notice WHERE created <= '
\$
oldate 01:01:01'
\"
;"
>>
$gnusocial_expire_posts_script
echo
"
\$
conversation_query=
\"
DELETE FROM conversation WHERE created <= '
$oldate
01:01:01'
\"
;"
>>
$gnusocial_expire_posts_script
echo
"
\$
reply_query=
\"
DELETE FROM reply WHERE modified <= '
\$
oldate 01:01:01'
\"
;"
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
'mysql_query($notice_query);'
>>
$gnusocial_expire_posts_script
echo
'$rowaff1=mysql_affected_rows();'
>>
$gnusocial_expire_posts_script
echo
'mysql_query($conversation_query);'
>>
$gnusocial_expire_posts_script
echo
'$rowaff2=mysql_affected_rows();'
>>
$gnusocial_expire_posts_script
echo
'mysql_query($reply_query);'
>>
$gnusocial_expire_posts_script
echo
'$rowaff3=mysql_affected_rows();'
>>
$gnusocial_expire_posts_script
echo
'mysql_close();'
>>
$gnusocial_expire_posts_script
echo
''
>>
$gnusocial_expire_posts_script
echo
-n
"echo
\"
Expire
${
gnusocial_type
}
posts: "
>>
$gnusocial_expire_posts_script
echo
'$rowaff1 notices, $rowaff2 conversations, and $rowaff3 replies deleted from database.\n";'
>>
$gnusocial_expire_posts_script
chmod
+x
$gnusocial_expire_posts_script
echo
'<?php'
>
$gnusocial_expire_script
gnusocial_expire_script
=
/usr/bin/
${
gnusocial_type
}
-expire
echo
''
>>
$gnusocial_expire_script
echo
'#!/bin/bash'
>
$gnusocial_expire_script
echo
"//
${
gnusocial_type
}
post expiry script, based on StatExpire by Tony Baldwin"
>>
$gnusocial_expire_script
echo
"/usr/bin/php
$gnusocial_expire_posts_script
"
>
$gnusocial_expire_script
echo
'// https://github.com/tonybaldwin/statexpire'
>>
$gnusocial_expire_script
echo
"find /var/www/
${
domain_name
}
/htdocs/file/* -mtime +
${
expire_days
}
-exec rm {} +"
>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
"
\$
oldate=date((
\"
Y-m-d
\"
), strtotime(
\"
-
${
expire_months
}
months
\"
));"
>>
$gnusocial_expire_script
echo
'$username="root";'
>>
$gnusocial_expire_script
echo
"
\$
password=shell_exec('
${
PROJECT_NAME
}
-pass -u root -a mariadb');"
>>
$gnusocial_expire_script
echo
"
\$
database=
\"
${
gnusocial_type
}
\"
;"
>>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
'if (!$link = mysql_connect("localhost", $username, $password)) {'
>>
$gnusocial_expire_script
echo
' echo "Could not connect to mariadb";'
>>
$gnusocial_expire_script
echo
' exit;'
>>
$gnusocial_expire_script
echo
'}'
>>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
'if (!mysql_select_db($database, $link)) {'
>>
$gnusocial_expire_script
echo
" echo
\"
Could not select
${
gnusocial_type
}
database
\"
;"
>>
$gnusocial_expire_script
echo
' exit;'
>>
$gnusocial_expire_script
echo
'}'
>>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
"
\$
notice_query=
\"
DELETE FROM notice WHERE created <= '
\$
oldate 01:01:01'
\"
;"
>>
$gnusocial_expire_script
echo
"
\$
conversation_query=
\"
DELETE FROM conversation WHERE created <= '
$oldate
01:01:01'
\"
;"
>>
$gnusocial_expire_script
echo
"
\$
reply_query=
\"
DELETE FROM reply WHERE modified <= '
\$
oldate 01:01:01'
\"
;"
>>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
'mysql_query($notice_query);'
>>
$gnusocial_expire_script
echo
'$rowaff1=mysql_affected_rows();'
>>
$gnusocial_expire_script
echo
'mysql_query($conversation_query);'
>>
$gnusocial_expire_script
echo
'$rowaff2=mysql_affected_rows();'
>>
$gnusocial_expire_script
echo
'mysql_query($reply_query);'
>>
$gnusocial_expire_script
echo
'$rowaff3=mysql_affected_rows();'
>>
$gnusocial_expire_script
echo
'mysql_close();'
>>
$gnusocial_expire_script
echo
''
>>
$gnusocial_expire_script
echo
-n
"echo
\"
Expire
${
gnusocial_type
}
posts: "
>>
$gnusocial_expire_script
echo
'$rowaff1 notices, $rowaff2 conversations, and $rowaff3 replies deleted from database.\n";'
>>
$gnusocial_expire_script
chmod
+x
$gnusocial_expire_script
chmod
+x
$gnusocial_expire_script
# Add a cron job
# Add a cron job
if
!
grep
-q
"
${
gnusocial_type
}
_expire_script"
/etc/crontab
;
then
if
!
grep
-q
"
${
gnusocial_type
}
_expire_script"
/etc/crontab
;
then
echo
"10 3 5 * * root /usr/bin/timeout 500
/usr/bin/php
${
gnusocial_expire_script
}
"
>>
/etc/crontab
echo
"10 3 5 * * root /usr/bin/timeout 500
${
gnusocial_expire_script
}
"
>>
/etc/crontab
fi
fi
# remove old expire script
# remove old expire script
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment