Add script for email announcements

This commit is contained in:
Felix 2020-05-17 15:57:22 +02:00
parent a0528dc1af
commit 2a244ee167
3 changed files with 37 additions and 4 deletions

4
files/email-template.txt Normal file
View File

@ -0,0 +1,4 @@
subject:email to all users
from:info@your-instance.com
this is a test email.

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
echo -e "This will send an email to all users, based on the template in $(pwd)/email-template.txt. Content:\n\n"
cat email-template.txt
echo -e "\n\n"
read -p "Send test email (y/N)? " SEND_EMAIL
case "$SEND_EMAIL" in
[yY]* ) ;;
[nN]* ) exit;;
* ) exit;;
esac
EMAIL_LIST=$(mktemp)
echo $EMAIL_LIST
docker-compose exec -T -u postgres postgres psql -U peertube -d peertube -c "SELECT email FROM public.user WHERE NOT blocked" -t > $EMAIL_LIST
echo "Sending email to $(wc -l $EMAIL_LIST | cut -d' ' -f1) users"
cat $EMAIL_LIST | while read EMAIL
do
echo "sending to $EMAIL"
cat email-template.txt | \
docker exec -i "$(docker-compose ps -q postfix)" sendmail -t "$EMAIL"
done
rm $EMAIL_LIST

View File

@ -25,11 +25,13 @@
- { path: '/peertube/volumes/certbot/' }
- { path: '/peertube/volumes/config/' }
- name: copy docker config
copy: src={{item.src}} dest={{item.dest}} mode='0644'
- name: copy files
copy: src={{item.src}} dest={{item.dest}} mode={{item.mode}} force={{item.force}}
with_items:
- { src: 'files/docker-daemon.json', dest: '/etc/docker/daemon.json' }
- { src: 'files/local-production.json', dest: '/peertube/volumes/config/local-production.json' }
- { src: 'files/docker-daemon.json', dest: '/etc/docker/daemon.json', mode: '0644', force: 'yes' }
- { src: 'files/local-production.json', dest: '/peertube/volumes/config/local-production.json', mode: '0644', force: 'yes' }
- { src: 'files/send-email-to-users.bash', dest: '/peertube/send-email-to-users.bash', mode: '755', force: 'yes' }
- { src: 'files/email-template.txt', dest: '/peertube/email-template.txt', mode: '0644', force: 'no' }
- name: get latest peertube version from github
uri: