Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pleroma
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
404
Issues
404
List
Boards
Labels
Service Desk
Milestones
Merge Requests
60
Merge Requests
60
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pleroma
pleroma
Commits
b5b9d161
Commit
b5b9d161
authored
May 20, 2020
by
Maksim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update purge script
parent
5f0a3ac7
Pipeline
#26113
passed with stages
in 8 minutes and 32 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
39 deletions
+40
-39
installation/nginx-cache-purge.example
installation/nginx-cache-purge.example
+0
-39
installation/nginx-cache-purge.sh.example
installation/nginx-cache-purge.sh.example
+40
-0
No files found.
installation/nginx-cache-purge.example
deleted
100755 → 0
View file @
5f0a3ac7
#!/bin/bash
# A simple Bash script to delete an media from the Nginx cache.
SCRIPTNAME
=
${
0
##*/
}
# NGINX cache directory
CACHE_DIRECTORY
=
"/tmp/pleroma-media-cache"
function
get_cache_files
()
{
local
max_parallel
=
${
3
-16
}
find
$2
-maxdepth
1
-type
d | xargs
-P
$max_parallel
-n
1
grep
-ERl
"^KEY:.*
$1
"
|
sort
-u
}
function
purge_item
()
{
local
cache_files
cache_files
=
$(
get_cache_files
"
$1
"
"
$2
"
)
if
[
-n
"
$cache_files
"
]
;
then
for
i
in
$cache_files
;
do
[
-f
$i
]
||
continue
echo
"Deleting
$i
from
$2
."
rm
$i
done
else
echo
"
$1
is not cached."
fi
}
function
purge
()
{
for
url
in
"
$@
"
do
echo
"
$SCRIPTNAME
delete
$url
from cache (
$CACHE_DIRECTORY
)"
purge_item
$url
$CACHE_DIRECTORY
done
}
purge
$1
installation/nginx-cache-purge.sh.example
0 → 100755
View file @
b5b9d161
#!/bin/sh
# A simple shell script to delete a media from the Nginx cache.
SCRIPTNAME
=
${
0
##*/
}
# NGINX cache directory
CACHE_DIRECTORY
=
"/tmp/pleroma-media-cache"
## Return the files where the items are cached.
## $1 - the filename, can be a pattern .
## $2 - the cache directory.
## $3 - (optional) the number of parallel processes to run for grep.
get_cache_files
()
{
local
max_parallel
=
${
3
-16
}
find
$2
-maxdepth
2
-type
d | xargs
-P
$max_parallel
-n
1
grep
-ERl
"^KEY:.*
$1
"
|
sort
-u
}
## Removes an item from the given cache zone.
## $1 - the filename, can be a pattern .
## $2 - the cache directory.
purge_item
()
{
for
f
in
$(
get_cache_files
$1
$2
)
;
do
echo
"found file:
$f
"
[
-f
$f
]
||
continue
echo
"Deleting
$f
from
$2
."
rm
$f
done
}
# purge_item
purge
()
{
for
url
in
"
$@
"
do
echo
"
$SCRIPTNAME
delete
\`
$url
\`
from cache (
$CACHE_DIRECTORY
)"
purge_item
$url
$CACHE_DIRECTORY
done
}
purge
$1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment