Improve script
This commit is contained in:
parent
d3bc3533b0
commit
1c3a3b26c5
|
@ -33,6 +33,7 @@ set -e # exit on first error
|
||||||
NGINX_PURGE_SKYLINKS_FILE="/home/user/skynet-webportal/docker/data/nginx/blocker/skylinks.txt"
|
NGINX_PURGE_SKYLINKS_FILE="/home/user/skynet-webportal/docker/data/nginx/blocker/skylinks.txt"
|
||||||
NGINX_PURGE_SKYLINKS_QUEUED="/home/user/skynet-webportal/docker/data/nginx/blocker/queued.txt"
|
NGINX_PURGE_SKYLINKS_QUEUED="/home/user/skynet-webportal/docker/data/nginx/blocker/queued.txt"
|
||||||
NGINX_PURGE_SKYLINKS_LOCK="/home/user/skynet-webportal/docker/data/nginx/blocker/lock"
|
NGINX_PURGE_SKYLINKS_LOCK="/home/user/skynet-webportal/docker/data/nginx/blocker/lock"
|
||||||
|
NGINX_CACHE_DIR="/home/user/skynet-webportal/docker/data/nginx/cache/"
|
||||||
|
|
||||||
purge_skylinks () {
|
purge_skylinks () {
|
||||||
# read all skylinks from the queued skylinks file
|
# read all skylinks from the queued skylinks file
|
||||||
|
@ -51,7 +52,8 @@ purge_skylinks () {
|
||||||
for skylink in "${skylinks[@]}";
|
for skylink in "${skylinks[@]}";
|
||||||
do
|
do
|
||||||
echo ".. ⌁ Purging skylink ${skylink}"
|
echo ".. ⌁ Purging skylink ${skylink}"
|
||||||
cached_files_command="find /data/nginx/cache/ -type f | xargs -r grep -Els '^Skynet-Skylink: ${skylink}'"
|
cached_files_command="find ${NGINX_CACHE_DIR} -type f | xargs -r grep -Els '^Skynet-Skylink: ${skylink}'"
|
||||||
|
echo $cached_files_command
|
||||||
docker exec -it nginx bash -c "${cached_files_command} | xargs -r rm"
|
docker exec -it nginx bash -c "${cached_files_command} | xargs -r rm"
|
||||||
|
|
||||||
echo ".. ⌁ Skylink ${skylink} purged"
|
echo ".. ⌁ Skylink ${skylink} purged"
|
||||||
|
@ -69,7 +71,7 @@ acquire_lock () {
|
||||||
do
|
do
|
||||||
if ! mkdir $NGINX_PURGE_SKYLINKS_LOCK 2>/dev/null
|
if ! mkdir $NGINX_PURGE_SKYLINKS_LOCK 2>/dev/null
|
||||||
then
|
then
|
||||||
echo "skylinks file is locked, waiting..." + $attempts
|
echo "skylinks file is locked, waiting..."
|
||||||
((attempts++))
|
((attempts++))
|
||||||
sleep 1;
|
sleep 1;
|
||||||
else
|
else
|
||||||
|
|
Reference in New Issue