diff --git a/copy.sh b/copy.sh new file mode 100644 index 0000000..829ffb4 --- /dev/null +++ b/copy.sh @@ -0,0 +1,16 @@ +#!/bin/bash +for i in ./*.sh; do + shfmt -w "${i}" + shellcheck -o all -f diff "${i}" | patch -p1 + i_tmp="${i##./}" + find /etc/cron.* -iname "${i_tmp%.sh}" | while read -r j; do + echo "${j}" + diff <(sed -e "s/friendica.example.net/hub.azkware.net/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 + done + find ../../Scripts -iname "${i_tmp}" | while read -r k; do + echo "${k}" + diff <(sed -e "s/friendica.example.net/hub.azkware.net/g" "${i}") "${k}" + sed -e "s/friendica.example.net/hub.azkware.net/g" "${i}" | sudo tee "${k}" &>/dev/null + done +done diff --git a/friendica-clean-database.sh b/friendica-clean-database.sh index 98da4ce..2f80242 100755 --- a/friendica-clean-database.sh +++ b/friendica-clean-database.sh @@ -282,7 +282,6 @@ until [[ "${tmp_item_uri_not_valid_q}" -lt "${limit}" ]]; do AND NOT EXISTS ( SELECT \`thr-parent-id\` FROM \`mail\` WHERE \`thr-parent-id\` = \`item-uri\`.\`id\` ) \ ORDER BY \`id\` LIMIT ${limit}") - final_i=$(($(date +%s) - initial_i)) echo "${tmp_item_uri_not_valid_q} item(s) deleted until ${tmp_item_uri_not_valid_current_id} in ${final_i}s" done diff --git a/friendica-remove-invalid-photos.sh b/friendica-remove-invalid-photos.sh index 7782fad..cfc6d4e 100755 --- a/friendica-remove-invalid-photos.sh +++ b/friendica-remove-invalid-photos.sh @@ -21,7 +21,7 @@ lastid=0 #Highest possible ID known maxid=$(mariadb "${db}" -B -N -q -e "select max(\`id\`) from contact") #Limit per batch -limit=$(( ( maxid / 1000 ) + 1 )) +limit=$(((maxid / 1000) + 1)) if [[ -f /tmp/lastid ]]; then rm /tmp/lastid && touch /tmp/lastid else @@ -53,7 +53,7 @@ until [[ $((nt + limit)) -gt ${dbcount} ]]; do if [[ -s "${lastid_i}" ]]; then lastid="${lastid_i}" fi - done < /tmp/lastid + done ${lastid} and \`photo\` like \"https:\/\/${url}/avatar/%\" and (\`id\` in (select \`cid\` from \`user-contact\`) or \`id\` in (select \`uid\` from \`user\`) or \`id\` in (select \`contact-id\` from \`group_member\`)) order by id limit ${limit}") dboutput=$(mariadb "${db}" -B -N -q -e "select \`id\`, \`photo\`, \`thumb\`, \`micro\` from \`contact\` where \`id\` > ${lastid} and \`photo\` like \"https:\/\/${url}/avatar/%\" order by id limit ${limit}") @@ -76,7 +76,7 @@ until [[ $((nt + limit)) -gt ${dbcount} ]]; do curl -s "${micro}" | file - | grep -q -e "text" -e "empty" -e "symbolic link" -e "directory"; then #Request the user data to be regenerated in the system through the database mariadb "${db}" -N -B -q -e "update contact set avatar= \"\", photo = \"\", thumb = \"\", micro = \"\" where id = \"${id}\"" - if [[ $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then + if [[ -n $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then mariadb "${db}" -N -B -q -e "insert ignore into workerqueue (command, parameter, priority, created) values (\"UpdateContact\", \"[${id}]\", 20, CURTIME());" fi echo "${id} ${photo}" @@ -103,7 +103,7 @@ until [[ $((nt + limit)) -gt ${dbcount} ]]; do rm -rf "${k_photo}" fi #Request the user data to be regenerated in the system through the database - if [[ $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then + if [[ -n $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then mariadb "${db}" -N -B -q -e "insert ignore into workerqueue (command, parameter, priority, created) values (\"UpdateContact\", \"[${id}]\", 20, CURTIME());" fi else @@ -111,7 +111,7 @@ until [[ $((nt + limit)) -gt ${dbcount} ]]; do #If no remote avatar is found, then we blank the photo/thumb/micro and let the avatar cache process fix them later mariadb "${db}" -e "update contact set photo = \"\", thumb = \"\", micro = \"\" where id = \"${id}\"" #Request the user data to be regenerated in the system through the database - if [[ $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then + if [[ -n $(mariadb "${db}" -N -B -q -e "select count(*) from workerqueue where command = \"UpdateContact\" and parameter = \"[${id}]\"" -gt 0) ]]; then mariadb "${db}" -N -B -q -e "insert ignore into workerqueue (command, parameter, priority, created) values (\"UpdateContact\", \"[${id}]\", 20, CURTIME());" fi fi @@ -127,7 +127,7 @@ until [[ $((nt + limit)) -gt ${dbcount} ]]; do fi lastid="${id}" touch /tmp/lastid - echo "${n} ${nt} ${lastid}" > /tmp/lastid + echo "${n} ${nt} ${lastid}" >/tmp/lastid fi printf "\rB. %5d Fd. %8d E. %8d Ct. %4d/%4d To. %8d/%8d Dt. %6d " "${batch}" "${n}" "${nt}" "${nx}" "${limit}" "${lastid}" "${maxid}" "${k_photo_delta}" done < <(echo "${dboutput}")