Compare commits
No commits in common. "ba0ae09fe657e6b2c0768e00ee58ea780398b91c" and "0c1a77a7159f4030703a4fb5849b31942eccebc7" have entirely different histories.
ba0ae09fe6
...
0c1a77a715
3 changed files with 109 additions and 79 deletions
|
@ -103,20 +103,20 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` add index if not exists \`contact_baseurl\` (baseurl)"
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` add index if not exists \`contact_baseurl\` (baseurl)"
|
||||||
fi
|
fi
|
||||||
while read -r id nick baseurl lastitem; do
|
"${dbengine}" "${db}" -N -B -q -e \
|
||||||
loop "${id}" "${nick}" "${baseurl}" &
|
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) / 2)) ]]; then
|
|
||||||
wait -n
|
|
||||||
fi
|
|
||||||
done < <("${dbengine}" "${db}" -N -B -q -e \
|
|
||||||
"select \`id\`, \`nick\`, \`baseurl\`, \`last-item\` from contact c where \
|
"select \`id\`, \`nick\`, \`baseurl\`, \`last-item\` from contact c where \
|
||||||
c.\`id\` not in (select \`cid\` from \`user-contact\`) and \
|
c.\`id\` not in (select \`cid\` from \`user-contact\`) and \
|
||||||
c.\`id\` not in (select \`uid\` from \`user\`) and \
|
c.\`id\` not in (select \`uid\` from \`user\`) and \
|
||||||
c.\`id\` not in ( select \`contact-id\` from \`group_member\`) and \
|
c.\`id\` not in ( select \`contact-id\` from \`group_member\`) and \
|
||||||
c.\`contact-type\` != 4 and not pending and \`last-discovery\` < CURDATE() - INTERVAL ${period} and \`last-item\` < CURDATE() - INTERVAL ${period}")
|
c.\`contact-type\` != 4 and not pending and \`last-discovery\` < CURDATE() - INTERVAL ${period} and \`last-item\` < CURDATE() - INTERVAL ${period}" |
|
||||||
|
while read -r id nick baseurl lastitem; do
|
||||||
|
loop "${id}" "${nick}" "${baseurl}" &
|
||||||
|
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) * 2)) ]]; then
|
||||||
|
wait -n
|
||||||
|
fi
|
||||||
|
done
|
||||||
wait
|
wait
|
||||||
printf "\n\r"
|
printf "\n\r"
|
||||||
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread\` auto_increment = 1; \
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread\` auto_increment = 1; \
|
||||||
alter table \`post-thread-user\` auto_increment = 1; \
|
alter table \`post-thread-user\` auto_increment = 1; \
|
||||||
alter table \`post-user\` auto_increment = 1; \
|
alter table \`post-user\` auto_increment = 1; \
|
||||||
|
@ -124,6 +124,7 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
alter table \`post\` auto_increment = 1; \
|
alter table \`post\` auto_increment = 1; \
|
||||||
alter table \`photo\` auto_increment = 1; \
|
alter table \`photo\` auto_increment = 1; \
|
||||||
alter table \`contact\` auto_increment = 1"
|
alter table \`contact\` auto_increment = 1"
|
||||||
|
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` drop index \`contact_baseurl\`"
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` drop index \`contact_baseurl\`"
|
||||||
fi
|
fi
|
||||||
rm -rf "${tmpfile}"
|
rm -rf "${tmpfile}"
|
||||||
|
|
|
@ -9,17 +9,13 @@ else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
db="friendica"
|
db="friendica"
|
||||||
|
tmpfile=/tmp/friendica-delete-old-users.csv
|
||||||
url=friendica.example.net
|
url=friendica.example.net
|
||||||
avatarfolder=/var/www/friendica/avatar
|
avatarfolder=/var/www/friendica/avatar
|
||||||
avatarfolderescaped=${avatarfolder////\\/}
|
avatarfolderescaped=${avatarfolder////\\/}
|
||||||
input_id=${1:-""}
|
input_id=${1:-"0"}
|
||||||
|
|
||||||
#Check if our dependencies are installed
|
loop() {
|
||||||
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
|
||||||
#Check if there was an input id; if not, skip
|
|
||||||
if [[ "${input_id}" != "" ]]; then
|
|
||||||
date
|
|
||||||
while read -r id nick baseurl lastitem; do
|
|
||||||
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
||||||
#Find the pictures in the avatar folders and delete them
|
#Find the pictures in the avatar folders and delete them
|
||||||
picturecount=0
|
picturecount=0
|
||||||
|
@ -46,6 +42,19 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
contactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${id}; select row_count();" || echo 0)
|
contactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${id}; select row_count();" || echo 0)
|
||||||
apcontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${id}; select row_count();" || echo 0)
|
apcontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${id}; select row_count();" || echo 0)
|
||||||
diasporacontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${id}; select row_count();" || echo 0)
|
diasporacontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${id}; select row_count();" || echo 0)
|
||||||
|
while read -r tmp_picturecount tmp_postthreadcount tmp_postthreadusercount tmp_postusercount tmp_posttagcount tmp_postcontentcount tmp_postcount tmp_photocount tmp_contactcount tmp_apcontactcount tmp_diasporacontactcount; do
|
||||||
|
picturecount=$((picturecount + tmp_picturecount))
|
||||||
|
postthreadcount=$((postthreadcount + tmp_postthreadcount))
|
||||||
|
postthreadusercount=$((postthreadusercount + tmp_postthreadusercount))
|
||||||
|
postusercount=$((postusercount + tmp_postusercount))
|
||||||
|
posttagcount=$((posttagcount + tmp_posttagcount))
|
||||||
|
postcontentcount=$((postcontentcount + tmp_postcontentcount))
|
||||||
|
postcount=$((postcount + tmp_postcount))
|
||||||
|
photocount=$((photocount + tmp_photocount))
|
||||||
|
contactcount=$((contactcount + tmp_contactcount))
|
||||||
|
apcontactcount=$((apcontactcount + tmp_apcontactcount))
|
||||||
|
diasporacontactcount=$((diasporacontactcount + tmp_diasporacontactcount))
|
||||||
|
done <"${tmpfile}"
|
||||||
response_left=$(printf "%s %s %s@%s " "${id}" "${lastitem::-9}" "${nick}" "${baseurltrimmed}")
|
response_left=$(printf "%s %s %s@%s " "${id}" "${lastitem::-9}" "${nick}" "${baseurltrimmed}")
|
||||||
response=$(printf "%spicture:%s " "${response}" "${picturecount}")
|
response=$(printf "%spicture:%s " "${response}" "${picturecount}")
|
||||||
response=$(printf "%spost-thread:%s " "${response}" "${postthreadcount}")
|
response=$(printf "%spost-thread:%s " "${response}" "${postthreadcount}")
|
||||||
|
@ -58,6 +67,7 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
response=$(printf "%scontact:%s " "${response}" "${contactcount}")
|
response=$(printf "%scontact:%s " "${response}" "${contactcount}")
|
||||||
response=$(printf "%sapcontact:%s " "${response}" "${apcontactcount}")
|
response=$(printf "%sapcontact:%s " "${response}" "${apcontactcount}")
|
||||||
response=$(printf "%sdiaspora-contact:%s " "${response}" "${diasporacontactcount}")
|
response=$(printf "%sdiaspora-contact:%s " "${response}" "${diasporacontactcount}")
|
||||||
|
echo "${picturecount}" "${postthreadcount} ${postthreadusercount} ${postusercount} ${posttagcount} ${postcontentcount} ${postcount} ${photocount} ${contactcount} ${apcontactcount} ${diasporacontactcount}" >"${tmpfile}"
|
||||||
#Previous line clearance
|
#Previous line clearance
|
||||||
#Measure length of string, blank only the excess
|
#Measure length of string, blank only the excess
|
||||||
#Since this string is panned to both sides, we will need to account for two lengths
|
#Since this string is panned to both sides, we will need to account for two lengths
|
||||||
|
@ -82,8 +92,27 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
done
|
done
|
||||||
response=$(printf "%s%s%s" "${response_left}" "${blank_string}" "${response}")
|
response=$(printf "%s%s%s" "${response_left}" "${blank_string}" "${response}")
|
||||||
printf "%s\r" "${response}"
|
printf "%s\r" "${response}"
|
||||||
done < <("${dbengine}" "${db}" -N -B -q -e "select \`id\`, \`nick\`, \`baseurl\`, \`last-item\` from contact where \`id\` = ${input_id}")
|
}
|
||||||
|
|
||||||
|
#Check if our dependencies are installed
|
||||||
|
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
||||||
|
#Check if there was an input id; if not, skip
|
||||||
|
if [[ "${input_id}" -gt 0 ]]; then
|
||||||
|
date
|
||||||
|
touch "${tmpfile}"
|
||||||
|
echo "0 0 0 0 0 0 0 0 0 0 0" >"${tmpfile}"
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e \
|
||||||
|
"select \`id\`, \`nick\`, \`baseurl\`, \`last-item\` from contact c where \
|
||||||
|
c.\`id\` = ${input_id}" |
|
||||||
|
while read -r id nick baseurl lastitem; do
|
||||||
|
loop "${id}" "${nick}" "${baseurl}" &
|
||||||
|
if [[ $(jobs -r -p | wc -l) -ge $(getconf _NPROCESSORS_ONLN) ]]; then
|
||||||
|
wait -n
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
wait
|
||||||
printf "\n\r"
|
printf "\n\r"
|
||||||
|
rm -rf "${tmpfile}"
|
||||||
date
|
date
|
||||||
else
|
else
|
||||||
echo "${input_id}"
|
echo "${input_id}"
|
||||||
|
|
|
@ -47,7 +47,7 @@ db="friendica"
|
||||||
on c.id = o.\`owner-id\` \
|
on c.id = o.\`owner-id\` \
|
||||||
right join tmp_causers as t \
|
right join tmp_causers as t \
|
||||||
on c.id = t.\`causer-id\` \
|
on c.id = t.\`causer-id\` \
|
||||||
inner join gserver as g \
|
left join gserver as g \
|
||||||
on g.id = c.gsid \
|
on g.id = c.gsid \
|
||||||
order by final_amount asc \
|
order by final_amount asc \
|
||||||
limit 1000;"
|
limit 1000;"
|
||||||
|
|
Loading…
Add table
Reference in a new issue