add protectedusers support

basically protectedusers shouldn't be deleted... currently untested
This commit is contained in:
ingoj 2020-04-03 00:11:24 +02:00
parent 8df2172aa2
commit 89c0c3a575
1 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#siteurl="https://domain.tld/"
#siteadmin="admin@domain.tld"
#sitefrom="no-reply@domain.tld"
#protectedusers="admin1 admin2 admin3"
source /usr/local/etc/cleanup_friendica.conf
@ -19,8 +20,13 @@ cd ${friendicapath} || exit 0
# filtering for "weeks" will result in accounts with 2 weeks old accounts,
# filter for just "week" will do the same after 1 week.
# same should apply to "month" and "months", but untested.
for u in $( ${friendicapath}/bin/console user list active -c 10000 | grep 'never.*never' | grep weeks | awk '{print $2}') ; do
${friendicapath}/bin/console user delete "${u}" -q
for username in $( ${friendicapath}/bin/console user list active -c 10000 | grep 'never.*never' | grep weeks | awk '{print $2}') ; do
# if username is a protected user do nothing, else delete user
if [[ "${protectedusers}" == *"${username}"* ]]; then
:
else
${friendicapath}/bin/console user delete "${username}" -q
fi
done
# find & notify users that didn't logged in >6 months and send mail to log in again
@ -56,7 +62,12 @@ your ${site} admins
EOF
) | sed 's/_/\ /g' | /usr/bin/mail -s "The Fediverse misses you, ${username}!" -r "${sitefrom}" -b "$siteadmin" -- "${usermail}"
# if username is a protected user do nothing, else delete user
if [[ "${protectedusers}" == *"${username}"* ]]; then
:
else
# ${friendicapath}/bin/console user delete "${u}" -q
fi
elif [ ${num_months} -eq 6 ]; then
# mail the user and ask to re-login
( cat <<EOF