Compare commits
3 commits
eedc7f0472
...
78e26fce2d
Author | SHA1 | Date | |
---|---|---|---|
78e26fce2d | |||
94b6d9f996 | |||
477637f7e4 |
4 changed files with 170 additions and 79 deletions
2
copy.sh
2
copy.sh
|
@ -7,7 +7,7 @@ for i in ./*.sh; do
|
||||||
find /etc/cron.* -iname "${i_tmp%.sh}" | while read -r j; do
|
find /etc/cron.* -iname "${i_tmp%.sh}" | while read -r j; do
|
||||||
echo "${j}"
|
echo "${j}"
|
||||||
diff <(sed -e "s/friendica.example.net/hub.azkware.net/g" -e "s/1\:-\"0\"/1\:-\"1\"/g" -e "s/#&>/\&\>/g" "${i}") "${j}"
|
diff <(sed -e "s/friendica.example.net/hub.azkware.net/g" -e "s/1\:-\"0\"/1\:-\"1\"/g" -e "s/#&>/\&\>/g" "${i}") "${j}"
|
||||||
sed -e "s/friendica.example.net/hub.azkware.net/g" -e "s/#&>/\&\>/g" "${i}" | sudo tee "${j}" &>/dev/null
|
sed -e "s/friendica.example.net/hub.azkware.net/g" -e "s/1\:-\"0\"/1\:-\"1\"/g" -e "s/#&>/\&\>/g" "${i}" | sudo tee "${j}" &>/dev/null
|
||||||
done
|
done
|
||||||
find ../../Scripts -iname "${i_tmp}" | while read -r k; do
|
find ../../Scripts -iname "${i_tmp}" | while read -r k; do
|
||||||
echo "${k}"
|
echo "${k}"
|
||||||
|
|
|
@ -8,16 +8,19 @@ elif [[ -n $(type mysql) ]]; then
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
intense_optimizations=${1:-"0"}
|
||||||
db="friendica"
|
db="friendica"
|
||||||
|
period="3 MONTH"
|
||||||
|
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////\\/}
|
||||||
|
|
||||||
loop() {
|
loop() {
|
||||||
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
||||||
printf "%s - %s@%s " "${lineb}" "${nick}" "${baseurltrimmed}"
|
|
||||||
#Find the pictures in the avatar folders and delete them
|
#Find the pictures in the avatar folders and delete them
|
||||||
"${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${lineb}" | while read -r photo thumb micro; do
|
picturecount=0
|
||||||
|
while read -r photo thumb micro; do
|
||||||
#If stored in avatar folder
|
#If stored in avatar folder
|
||||||
if grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
if grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
||||||
#if [[ -z "${isavatar}" ]]
|
#if [[ -z "${isavatar}" ]]
|
||||||
|
@ -27,55 +30,98 @@ loop() {
|
||||||
rm -rfv "${thumbtrimmed}"
|
rm -rfv "${thumbtrimmed}"
|
||||||
microtrimmed=$(echo "${micro}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
microtrimmed=$(echo "${micro}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
||||||
rm -rfv "${microtrimmed}"
|
rm -rfv "${microtrimmed}"
|
||||||
|
picturecount=1
|
||||||
fi
|
fi
|
||||||
|
done < <("${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${id}")
|
||||||
|
postthreadcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();" || echo 0)
|
||||||
|
postthreadusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();" || echo 0)
|
||||||
|
postusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();" || echo 0)
|
||||||
|
posttagcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${id}; select row_count();" || echo 0)
|
||||||
|
postcontentcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();" || echo 0)
|
||||||
|
postcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();" || echo 0)
|
||||||
|
photocount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-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)
|
||||||
|
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=$(printf "%spicture:%s " "${response}" "${picturecount}")
|
||||||
|
response=$(printf "%spost-thread:%s " "${response}" "${postthreadcount}")
|
||||||
|
response=$(printf "%spost-thread-user:%s " "${response}" "${postthreadusercount}")
|
||||||
|
response=$(printf "%spost-user:%s " "${response}" "${postusercount}")
|
||||||
|
response=$(printf "%spost-tag:%s " "${response}" "${posttagcount}")
|
||||||
|
response=$(printf "%spost-content:%s " "${response}" "${postcontentcount}")
|
||||||
|
response=$(printf "%spost:%s " "${response}" "${postcount}")
|
||||||
|
response=$(printf "%sphoto:%s " "${response}" "${photocount}")
|
||||||
|
response=$(printf "%scontact:%s " "${response}" "${contactcount}")
|
||||||
|
response=$(printf "%sapcontact:%s " "${response}" "${apcontactcount}")
|
||||||
|
response=$(printf "%sdiaspora-contact:%s " "${response}" "${diasporacontactcount}")
|
||||||
|
echo "${picturecount}" "${postthreadcount} ${postthreadusercount} ${postusercount} ${posttagcount} ${postcontentcount} ${postcount} ${photocount} ${contactcount} ${apcontactcount} ${diasporacontactcount}" >"${tmpfile}"
|
||||||
|
#Previous line clearance
|
||||||
|
#Measure length of string, blank only the excess
|
||||||
|
final_string_length_left="${#response_left}"
|
||||||
|
final_string_length_right="${#response}"
|
||||||
|
final_string_length=$((final_string_length_left + final_string_length_right))
|
||||||
|
blank_string=""
|
||||||
|
columns_length="${COLUMNS}"
|
||||||
|
while [[ "${final_string_length}" -gt "${columns_length}" ]]; do
|
||||||
|
columns_length=$((columns_length + COLUMNS))
|
||||||
done
|
done
|
||||||
postthreadcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
blank_string_length=$((columns_length - final_string_length))
|
||||||
postthreadusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
for ((count = 0; count < "${blank_string_length}"; count++)); do
|
||||||
postusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();")
|
blank_string=$(printf "%s " "${blank_string}")
|
||||||
posttagcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}; select row_count();")
|
done
|
||||||
postcontentcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
response=$(printf "%s%s%s" "${response_left}" "${blank_string}" "${response}")
|
||||||
postcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
for ((count = 0; count < "${final_string_length}"; count++)); do
|
||||||
photocount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}; select row_count();")
|
response=$(printf "%s\b" "${response}")
|
||||||
contactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}; select row_count();")
|
done
|
||||||
apcontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}; select row_count();")
|
printf "%s\r" "${response}"
|
||||||
diasporacontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}; select row_count();")
|
|
||||||
printf "post-thread: %s " "${postthreadcount}"
|
|
||||||
printf "post-thread-user: %s " "${postthreadusercount}"
|
|
||||||
printf "post-user: %s " "${postusercount}"
|
|
||||||
printf "post-tag: %s " "${posttagcount}"
|
|
||||||
printf "post-content: %s " "${postcontentcount}"
|
|
||||||
printf "post: %s " "${postcount}"
|
|
||||||
printf "photo: %s " "${photocount}"
|
|
||||||
printf "contact: %s " "${contactcount}"
|
|
||||||
printf "apcontact: %s " "${apcontactcount}"
|
|
||||||
printf "diaspora-contact: %s " "${diasporacontactcount}"
|
|
||||||
printf "\r\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if our dependencies are installed
|
#Check if our dependencies are installed
|
||||||
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
||||||
date
|
date
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` add index if not exists \`contact_baseurl\` (baseurl)"
|
touch "${tmpfile}"
|
||||||
|
echo "0 0 0 0 0 0 0 0 0 0 0" >"${tmpfile}"
|
||||||
|
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` add index if not exists \`contact_baseurl\` (baseurl)"
|
||||||
|
fi
|
||||||
"${dbengine}" "${db}" -N -B -q -e \
|
"${dbengine}" "${db}" -N -B -q -e \
|
||||||
"select \`id\`, \`nick\`, \`baseurl\` 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 1 YEAR and \`last-item\` < CURDATE() - INTERVAL 1 YEAR" |
|
c.\`contact-type\` != 4 and not pending and \`last-discovery\` < CURDATE() - INTERVAL ${period} and \`last-item\` < CURDATE() - INTERVAL ${period}" |
|
||||||
while read -r lineb nick baseurl; do
|
while read -r id nick baseurl lastitem; do
|
||||||
loop "${lineb}" "${nick}" "${baseurl}" &
|
loop "${id}" "${nick}" "${baseurl}" &
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) / 2)) ]]; then
|
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) / 1)) ]]; then
|
||||||
wait -n
|
wait -n
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
printf "\r\n"
|
||||||
wait
|
wait
|
||||||
"${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; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread-user\` auto_increment = 1"
|
alter table \`post-thread-user\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-user\` auto_increment = 1"
|
alter table \`post-user\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-tag\` auto_increment = 1"
|
alter table \`post-tag\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post\` auto_increment = 1"
|
alter table \`post\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`photo\` auto_increment = 1"
|
alter table \`photo\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` auto_increment = 1"
|
alter table \`contact\` auto_increment = 1"
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` drop index \`contact_baseurl\`"
|
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
||||||
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` drop index \`contact_baseurl\`"
|
||||||
|
fi
|
||||||
|
rm -rf "${tmpfile}"
|
||||||
date
|
date
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,9 +8,11 @@ elif [[ -n $(type mysql) ]]; then
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
intense_optimizations=${1:-"0"}
|
||||||
db="friendica"
|
db="friendica"
|
||||||
tmpfile="/tmp/sitesdown.txt"
|
tmpfile="/tmp/sitesdown.txt"
|
||||||
idsdownfile="/tmp/idsdown.txt"
|
idsdownfile="/tmp/idsdown.txt"
|
||||||
|
usrfile="/tmp/usersdown.txt"
|
||||||
url=friendica.example.net
|
url=friendica.example.net
|
||||||
avatarfolder=/var/www/friendica/avatar
|
avatarfolder=/var/www/friendica/avatar
|
||||||
avatarfolderescaped=${avatarfolder////\\/}
|
avatarfolderescaped=${avatarfolder////\\/}
|
||||||
|
@ -44,9 +46,9 @@ loop_2() {
|
||||||
|
|
||||||
loop_3() {
|
loop_3() {
|
||||||
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
baseurltrimmed=$(echo "${baseurl}" | sed -e "s/http[s]*:\/\///g")
|
||||||
printf "%s - %s@%s " "${lineb}" "${nick}" "${baseurltrimmed}"
|
|
||||||
#Find the pictures in the avatar folders and delete them
|
#Find the pictures in the avatar folders and delete them
|
||||||
"${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${lineb}" | while read -r photo thumb micro; do
|
picturecount=0
|
||||||
|
while read -r photo thumb micro; do
|
||||||
#If stored in avatar folder
|
#If stored in avatar folder
|
||||||
if grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
if grep -v -q "${url}/avatar" <(echo "${photo}"); then
|
||||||
#if [[ -z "${isavatar}" ]]
|
#if [[ -z "${isavatar}" ]]
|
||||||
|
@ -56,36 +58,73 @@ loop_3() {
|
||||||
rm -rfv "${thumbtrimmed}"
|
rm -rfv "${thumbtrimmed}"
|
||||||
microtrimmed=$(echo "${micro}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
microtrimmed=$(echo "${micro}" | sed -e "s/https:\/\/${url}\/avatar/${avatarfolderescaped}/g" -e "s/\?ts.*//g")
|
||||||
rm -rfv "${microtrimmed}"
|
rm -rfv "${microtrimmed}"
|
||||||
|
picturecount=1
|
||||||
fi
|
fi
|
||||||
|
done < <("${dbengine}" "${db}" -N -B -q -e "select \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` = ${id}")
|
||||||
|
postthreadcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select_row_count();" || echo 0)
|
||||||
|
postthreadusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select_row_count();" || echo 0)
|
||||||
|
postusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select_row_count();" || echo 0)
|
||||||
|
posttagcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${id}; select_row_count();" || echo 0)
|
||||||
|
postcontentcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select_row_count();" || echo 0)
|
||||||
|
postcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${id} or \`author-id\` = ${id} or \`causer-id\` = ${id}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select_row_count();" || echo 0)
|
||||||
|
photocount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-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)
|
||||||
|
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 <"${usrfile}"
|
||||||
|
response_left=$(printf "%s %s@%s " "${id}" "${nick}" "${baseurltrimmed}")
|
||||||
|
response=$(printf "%spicture:%s " "${response}" "${picturecount}")
|
||||||
|
response=$(printf "%spost-thread:%s " "${response}" "${postthreadcount}")
|
||||||
|
response=$(printf "%spost-thread-user:%s " "${response}" "${postthreadusercount}")
|
||||||
|
response=$(printf "%spost-user:%s " "${response}" "${postusercount}")
|
||||||
|
response=$(printf "%spost-tag:%s " "${response}" "${posttagcount}")
|
||||||
|
response=$(printf "%spost-content:%s " "${response}" "${postcontentcount}")
|
||||||
|
response=$(printf "%spost:%s " "${response}" "${postcount}")
|
||||||
|
response=$(printf "%sphoto:%s " "${response}" "${photocount}")
|
||||||
|
response=$(printf "%scontact:%s " "${response}" "${contactcount}")
|
||||||
|
response=$(printf "%sapcontact:%s " "${response}" "${apcontactcount}")
|
||||||
|
response=$(printf "%sdiaspora-contact:%s " "${response}" "${diasporacontactcount}")
|
||||||
|
echo "${picturecount}" "${postthreadcount} ${postthreadusercount} ${postusercount} ${posttagcount} ${postcontentcount} ${postcount} ${photocount} ${contactcount} ${apcontactcount} ${diasporacontactcount}" >"${usrfile}"
|
||||||
|
#Previous line clearance
|
||||||
|
#Measure length of string, blank only the excess
|
||||||
|
final_string_length_left="${#response_left}"
|
||||||
|
final_string_length_right="${#response}"
|
||||||
|
final_string_length=$((final_string_length_left + final_string_length_right))
|
||||||
|
blank_string=""
|
||||||
|
columns_length="${COLUMNS}"
|
||||||
|
while [[ "${final_string_length}" -gt "${columns_length}" ]]; do
|
||||||
|
columns_length=$((columns_length + COLUMNS))
|
||||||
done
|
done
|
||||||
postthreadcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread (select \`uri-id\` from \`post-thread\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete h.* from \`post-thread\` h inner join \`tmp_post_thread\` t where h.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
blank_string_length=$((columns_length - final_string_length))
|
||||||
postthreadusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_thread_user (select \`uri-id\` from \`post-thread-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete r.* from \`post-thread-user\` r inner join \`tmp_post_thread_user\` t where r.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
for ((count = 0; count < "${blank_string_length}"; count++)); do
|
||||||
postusercount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post_user (select \`id\` from \`post-user\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete u.* from \`post-user\` u inner join \`tmp_post_user\` t where u.\`id\` = t.\`id\`; select row_count();")
|
blank_string=$(printf "%s " "${blank_string}")
|
||||||
posttagcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`post-tag\` where cid = ${lineb}; select row_count();")
|
done
|
||||||
postcontentcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post-content\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
response=$(printf "%s%s%s" "${response_left}" "${blank_string}" "${response}")
|
||||||
postcount=$("${dbengine}" "${db}" -N -B -q -e "create temporary table tmp_post (select \`uri-id\` from \`post\` where \`owner-id\` = ${lineb} or \`author-id\` = ${lineb} or \`causer-id\` = ${lineb}); delete p.* from \`post\` p inner join \`tmp_post\` t where p.\`uri-id\` = t.\`uri-id\`; select row_count();")
|
for ((count = 0; count < "${final_string_length}"; count++)); do
|
||||||
photocount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`photo\` where \`contact-id\` = ${lineb}; select row_count();")
|
response=$(printf "%s\b" "${response}")
|
||||||
contactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`contact\` where \`id\` = ${lineb}; select row_count();")
|
done
|
||||||
apcontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`apcontact\` where \`uri-id\` = ${lineb}; select row_count();")
|
printf "%s\r" "${response}"
|
||||||
diasporacontactcount=$("${dbengine}" "${db}" -N -B -q -e "delete from \`diaspora-contact\` where \`uri-id\` = ${lineb}; select row_count();")
|
|
||||||
printf "post-thread: %s " "${postthreadcount}"
|
|
||||||
printf "post-thread-user: %s " "${postthreadusercount}"
|
|
||||||
printf "post-user: %s " "${postusercount}"
|
|
||||||
printf "post-tag: %s " "${posttagcount}"
|
|
||||||
printf "post-content: %s " "${postcontentcount}"
|
|
||||||
printf "post: %s " "${postcount}"
|
|
||||||
printf "photo: %s " "${photocount}"
|
|
||||||
printf "contact: %s " "${contactcount}"
|
|
||||||
printf "apcontact: %s " "${apcontactcount}"
|
|
||||||
printf "diaspora-contact: %s " "${diasporacontactcount}"
|
|
||||||
printf "\r\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Check if our dependencies are installed
|
#Check if our dependencies are installed
|
||||||
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(type date) ]]; then
|
||||||
date
|
date
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` add index if not exists \`contact_baseurl\` (\`baseurl\`)"
|
if [[ "${intense_optimizations}" -gt 0 ]]; then
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-user\` add index if not exists \`post_user_id\` (\`author-id\`, \`causer-id\`, \`owner-id\`)"
|
"${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 \`post-user\` add index if not exists \`post_user_id\` (\`author-id\`, \`causer-id\`, \`owner-id\`)"
|
||||||
|
fi
|
||||||
if [[ ! -f "${tmpfile}" ]]; then
|
if [[ ! -f "${tmpfile}" ]]; then
|
||||||
echo "Listing sites"
|
echo "Listing sites"
|
||||||
siteslist=$("${dbengine}" "${db}" -N -B -q -e "select distinct baseurl, protocol from contact where baseurl != ''" | sort -b -f -n | sed -e "s/http:/https:/g" | uniq -i)
|
siteslist=$("${dbengine}" "${db}" -N -B -q -e "select distinct baseurl, protocol from contact where baseurl != ''" | sort -b -f -n | sed -e "s/http:/https:/g" | uniq -i)
|
||||||
|
@ -117,24 +156,30 @@ if [[ -n $(type curl) && -n "${dbengine}" && -n $(type "${dbengine}") && -n $(ty
|
||||||
u=$(sort -n "${idsdownfile}" | uniq)
|
u=$(sort -n "${idsdownfile}" | uniq)
|
||||||
echo "${u}" >"${idsdownfile}"
|
echo "${u}" >"${idsdownfile}"
|
||||||
fi
|
fi
|
||||||
while read -r lineb nick baseurl; do
|
touch "${usrfile}"
|
||||||
|
echo "0 0 0 0 0 0 0 0 0 0 0" >"${usrfile}"
|
||||||
|
while read -r id nick baseurl; do
|
||||||
#The community no longer exists, delete
|
#The community no longer exists, delete
|
||||||
loop_3 "${lineb}" "${nick}" "${baseurl}" &
|
loop_3 "${id}" "${nick}" "${baseurl}" &
|
||||||
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) / 2)) ]]; then
|
if [[ $(jobs -r -p | wc -l) -ge $(($(getconf _NPROCESSORS_ONLN) / 2)) ]]; then
|
||||||
wait -n
|
wait -n
|
||||||
fi
|
fi
|
||||||
wait
|
wait
|
||||||
done <"${idsdownfile}"
|
done <"${idsdownfile}"
|
||||||
|
printf "\r\n"
|
||||||
rm "${tmpfile}" 2>/dev/null
|
rm "${tmpfile}" 2>/dev/null
|
||||||
rm "${idsdownfile}" 2>/dev/null
|
rm "${idsdownfile}" 2>/dev/null
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread\` auto_increment = 1"
|
rm "${usrfile}" 2>/dev/null
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread-user\` auto_increment = 1"
|
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-thread\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-user\` auto_increment = 1"
|
alter table \`post-thread-user\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-tag\` auto_increment = 1"
|
alter table \`post-user\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post\` auto_increment = 1"
|
alter table \`post-tag\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`photo\` auto_increment = 1"
|
alter table \`post\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` auto_increment = 1"
|
alter table \`photo\` auto_increment = 1; \
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`contact\` drop index \`contact_baseurl\`"
|
alter table \`contact\` auto_increment = 1"
|
||||||
"${dbengine}" "${db}" -N -B -q -e "alter table \`post-user\` drop index \`post_user_id\`"
|
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 \`post-user\` drop index \`post_user_id\`"
|
||||||
|
fi
|
||||||
date
|
date
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,7 +3,7 @@ limit=1000
|
||||||
ca=${limit}
|
ca=${limit}
|
||||||
camax=0
|
camax=0
|
||||||
until [[ ${ca} -lt ${limit} ]]; do
|
until [[ ${ca} -lt ${limit} ]]; do
|
||||||
ca=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"UpdateContact\" limit ${ca}; select row_count();")
|
ca=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"UpdateContact\" and \`done\` = 0 limit ${ca}; select row_count();")
|
||||||
camax=$((camax + ca))
|
camax=$((camax + ca))
|
||||||
printf "\rUpdateContact\t\t%s\r" "${camax}"
|
printf "\rUpdateContact\t\t%s\r" "${camax}"
|
||||||
done
|
done
|
||||||
|
@ -13,7 +13,7 @@ printf "\rUpdateContact\t\t%s\n\r" "${camax}"
|
||||||
cb=${limit}
|
cb=${limit}
|
||||||
cbmax=0
|
cbmax=0
|
||||||
until [[ ${cb} -lt ${limit} ]]; do
|
until [[ ${cb} -lt ${limit} ]]; do
|
||||||
cb=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"ContactDiscovery\" limit ${cb}; select row_count();")
|
cb=$(sudo mariadb friendica -B -N -q -e "delete from workerqueue where regexp_replace(regexp_replace(\`parameter\`, '\\\[', ''), '\\\]', '') not in (select \`id\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)) and \`command\` = \"ContactDiscovery\" and \`done\` = 0 limit ${cb}; select row_count();")
|
||||||
cbmax=$((cbmax + cb))
|
cbmax=$((cbmax + cb))
|
||||||
printf "\rContactDiscovery\t%s\r" "${cbmax}"
|
printf "\rContactDiscovery\t%s\r" "${cbmax}"
|
||||||
done
|
done
|
||||||
|
@ -23,7 +23,7 @@ printf "\rContactDiscovery\t%s\n\r" "${cbmax}"
|
||||||
cc=${limit}
|
cc=${limit}
|
||||||
ccmax=0
|
ccmax=0
|
||||||
until [[ ${cc} -lt ${limit} ]]; do
|
until [[ ${cc} -lt ${limit} ]]; do
|
||||||
cc=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_addcontact (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"AddContact\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_addcontact) limit ${cc}; select row_count();")
|
cc=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_addcontact (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"AddContact\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_addcontact) and \`done\` = 0 limit ${cc}; select row_count();")
|
||||||
ccmax=$((ccmax + cc))
|
ccmax=$((ccmax + cc))
|
||||||
printf "\rAddContact \t%s\r" "${ccmax}"
|
printf "\rAddContact \t%s\r" "${ccmax}"
|
||||||
done
|
done
|
||||||
|
@ -33,7 +33,7 @@ printf "\rAddContact \t%s\n\r" "${ccmax}"
|
||||||
cd=${limit}
|
cd=${limit}
|
||||||
cdmax=0
|
cdmax=0
|
||||||
until [[ ${cd} -lt ${limit} ]]; do
|
until [[ ${cd} -lt ${limit} ]]; do
|
||||||
cd=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_updategserver (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\` = \"UpdateGServer\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_updategserver) limit ${cd}; select row_count();")
|
cd=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_updategserver (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\` = \"UpdateGServer\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_updategserver) and \`done\` = 0 limit ${cd}; select row_count();")
|
||||||
cdmax=$((cdmax + cd))
|
cdmax=$((cdmax + cd))
|
||||||
printf "\rUpdateGServer\t\t%s\r" "${cdmax}"
|
printf "\rUpdateGServer\t\t%s\r" "${cdmax}"
|
||||||
done
|
done
|
||||||
|
@ -43,7 +43,7 @@ printf "\rUpdateGServer\t\t%s\n\r" "${cdmax}"
|
||||||
ce=${limit}
|
ce=${limit}
|
||||||
cemax=0
|
cemax=0
|
||||||
until [[ ${ce} -lt ${limit} ]]; do
|
until [[ ${ce} -lt ${limit} ]]; do
|
||||||
ce=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_fetchfeaturedposts (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"FetchFeaturedPosts\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_fetchfeaturedposts) limit ${ce}; select row_count();")
|
ce=$(sudo mariadb friendica -B -N -q -e "create temporary table tmp_fetchfeaturedposts (select \`url\` from \`contact\` where \`id\` in (select \`contact-id\` from \`group_member\`) or \`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`)); delete from workerqueue where \`command\`= \"FetchFeaturedPosts\" and regexp_replace(substring_index(substring_index(\`parameter\`, '\\\"', -2), '\\\"', 1), '\\\\\\\\', '') not in (select \`url\` from tmp_fetchfeaturedposts) and \`done\` = 0 limit ${ce}; select row_count();")
|
||||||
cemax=$((cemax + ce))
|
cemax=$((cemax + ce))
|
||||||
printf "\rFetchFeaturedPosts\t%s\r" "${cemax}"
|
printf "\rFetchFeaturedPosts\t%s\r" "${cemax}"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue