#!/bin/sh # set the following variables accordingly to your site # the admin will get a notification mail in BCC friendicapath="/var/www/net/nerdica.net/friendica" site="SITE" siteurl="https://domain.tld/" siteadmin="admin@domain.tld" sitefrom="no-reply@domain.tld" cd ${friendicapath} || exit 0 # delete users that never logged in and never posted content # 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 done # find & notify users that didn't logged in >6 months and send mail to log in again for u in $( ${friendicapath}/bin/console user list active -c 10000 | grep -v '.*---.*' | sed 's/|/;/g' | tr -s "\ " | sed 's/^;\ //g' | sed 's/\ ;\ /;/g' | sed 's/\ /_/g' | tail -n +2 ); do r=$(echo "${u}" | awk -F ";" '{print $1}') dispname=$(echo "${u}" | awk -F ";" '{print $2}') profileurl=$(echo "${u}"| awk -F ";" '{print $3}') usermail=$(echo "${u}" | awk -F ";" '{print $4}') registered=$(echo "${u}" | awk -F ";" '{print $5}') lastlogin=$(echo "${u}" | awk -F ";" '{print $6}') lastpost=$(echo "${u}" | awk -F ";" '{print $7}') #echo "Userinfo: ${username},${dispname},${profileurl},${usermail},${registered},${lastlogin},${lastpost}" res=$(echo "${lastlogin}" | grep '[6-9]_months.*') if [ -n "${res}" ]; then num_months=$(echo "${res}" | awk -F "_" '{ print $1}') #echo "months: ${num_months}" if [ ${num_months} -ge 7 ]; then # delete account when last login is older than 7 months and send mail about deletion # you should copy & paste the text from 6 months for the first runs of this script # and later change the text to a notification that the account has been deleted. ( cat <