diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dc5ea4b5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -dist: trusty -sudo: required -language: node_js -node_js: - - 8 -services: - - mysql -before_install: - - sudo apt-get -q -y install pwgen imagemagick -install: - - sudo bash test/e2e/install.sh - - npm install -before_script: - - npm run starttest > /dev/null 2>&1 & - - sleep 10 -script: - - grunt - - npm run _e2e diff --git a/TODO.md b/TODO.md index 4f4ebff5..1641a058 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,7 @@ ### Front page - Some dashboard -### Message delivery -- Better integration with ZoneMTA to allow multiple send configurations (with different DKIM) against one ZoneMTA instance via different HTTP configuration of ZoneMTA. This may need an extension of ZoneMTA to provide some header entry that identifies the campaign. - ### Campaigns -- Statistics for a sent campaign - List of sent RSS campaigns (?) ### Pull requests @@ -19,9 +15,7 @@ - Add API extensions ### GDPR -- Removal of personal data upon unsubscribe (settable per list) - Refuse editing subscriptions which have been anonymized - Add field to subscriptions which says till when the consent has been given - Provide a link (and merge tag) that will update the consent date to now - Add campaign trigger that triggers if the consent for specific subscription field is about to expire (i.e. it is greater than now - seconds) -- Removal of personal data upon consent expiration (settable per list) diff --git a/server/setup/install-centos7.sh b/server/setup/install-centos7.sh deleted file mode 100644 index 3c592857..00000000 --- a/server/setup/install-centos7.sh +++ /dev/null @@ -1,227 +0,0 @@ -#!/bin/bash - -# This installation script works on CentOS 7 -# Run as root! - -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi - -set -e - -yum -y install epel-release - -curl --silent --location https://rpm.nodesource.com/setup_7.x | bash - -yum -y install mariadb-server nodejs ImageMagick git python redis pwgen bind-utils gcc-c++ make - -systemctl start mariadb -systemctl enable mariadb - -systemctl start redis -systemctl enable redis - - -PUBLIC_IP=`curl -s https://api.ipify.org` -if [ ! -z "$PUBLIC_IP" ]; then - HOSTNAME=`dig +short -x $PUBLIC_IP | sed 's/\.$//'` - HOSTNAME="${HOSTNAME:-$PUBLIC_IP}" -fi -HOSTNAME="${HOSTNAME:-`hostname`}" - -MYSQL_PASSWORD=`pwgen 12 -1` -MYSQL_RO_PASSWORD=`pwgen 12 -1` -DKIM_API_KEY=`pwgen 12 -1` -SMTP_PASS=`pwgen 12 -1` - -# Setup MySQL user for Mailtrain -mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';" -mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';" -mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$MYSQL_RO_PASSWORD';" -mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';" -mysql -u mailtrain --password="$MYSQL_PASSWORD" -e "CREATE database mailtrain;" - -# Enable firewall, allow connections to SSH, HTTP, HTTPS and SMTP -for port in 80/tcp 443/tcp 25/tcp; do firewall-cmd --add-port=$port --permanent; done -firewall-cmd --reload - -# Fetch Mailtrain files -mkdir -p /opt/mailtrain -cd /opt/mailtrain -git clone git://github.com/Mailtrain-org/mailtrain.git . - -# Normally we would let Mailtrain itself to import the initial SQL data but in this case -# we need to modify it, before we start Mailtrain -mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain < setup/sql/mailtrain.sql - -mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain <> config/production.toml <> workers/reports/config/production.toml < /etc/logrotate.d/mailtrain -/var/log/mailtrain.log { - daily - rotate 12 - compress - delaycompress - missingok - notifempty - copytruncate - nomail -} -EOM - -# Set up systemd service script -cp setup/mailtrain-centos7.service /etc/systemd/system/mailtrain.service -systemctl enable mailtrain.service - -# Fetch ZoneMTA files -mkdir -p /opt/zone-mta -cd /opt/zone-mta -git clone git://github.com/zone-eu/zone-mta.git . -git checkout 6964091273 - -# Ensure queue folder -mkdir -p /var/data/zone-mta/mailtrain - -# Setup installation configuration -cat >> config/production.json <&2 - exit 1 -fi - -set -e - -export DEBIAN_FRONTEND=noninteractive - -MYSQL_ROOT_PASSWORD=`pwgen 12 -1` - -debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASSWORD' -debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD' - -curl -sL https://deb.nodesource.com/setup_7.x | bash - -apt-get -q -y install mariadb-server pwgen nodejs imagemagick git ufw build-essential dnsutils python software-properties-common - -apt-add-repository -y ppa:chris-lea/redis-server -apt-get update -apt-get -q -y install redis-server - -apt-get clean - -PUBLIC_IP=`curl -s https://api.ipify.org` -if [ ! -z "$PUBLIC_IP" ]; then - HOSTNAME=`dig +short -x $PUBLIC_IP | sed 's/\.$//'` - HOSTNAME="${HOSTNAME:-$PUBLIC_IP}" -fi -HOSTNAME="${HOSTNAME:-`hostname`}" - -MYSQL_PASSWORD=`pwgen 12 -1` -MYSQL_RO_PASSWORD=`pwgen 12 -1` -DKIM_API_KEY=`pwgen 12 -1` -SMTP_PASS=`pwgen 12 -1` - -# Setup MySQL user for Mailtrain -mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';" -p$MYSQL_ROOT_PASSWORD -mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';" -p$MYSQL_ROOT_PASSWORD -mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$MYSQL_RO_PASSWORD';" -p$MYSQL_ROOT_PASSWORD -mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';" -p$MYSQL_ROOT_PASSWORD -mysql -u mailtrain --password="$MYSQL_PASSWORD" -e "CREATE database mailtrain;" - -# Enable firewall, allow connections to SSH, HTTP, HTTPS and SMTP -ufw allow 22/tcp -ufw allow 80/tcp -ufw allow 443/tcp -ufw allow 25/tcp -ufw --force enable - -# Fetch Mailtrain files -mkdir -p /opt/mailtrain -cd /opt/mailtrain -git clone git://github.com/Mailtrain-org/mailtrain.git . - -# Normally we would let Mailtrain itself to import the initial SQL data but in this case -# we need to modify it, before we start Mailtrain -mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain < setup/sql/mailtrain.sql - -mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain <> config/production.toml <> workers/reports/config/production.toml < /etc/logrotate.d/mailtrain -/var/log/mailtrain.log { - daily - rotate 12 - compress - delaycompress - missingok - notifempty - copytruncate - nomail -} -EOM - -if [ -d "/run/systemd/system" ]; then - # Set up systemd service script - cp setup/mailtrain.service /etc/systemd/system/ - systemctl enable mailtrain.service -else - # Set up upstart service script - cp setup/mailtrain.conf /etc/init/ -fi - -# Fetch ZoneMTA files -mkdir -p /opt/zone-mta -cd /opt/zone-mta -git clone git://github.com/zone-eu/zone-mta.git . -git checkout 6964091273 - -# Ensure queue folder -mkdir -p /var/data/zone-mta/mailtrain - -# Setup installation configuration -cat >> config/production.json < ~/mysql_root_password -echo "MySQL root password: $MYSQL_ROOT_PASSWORD" -echo "Success! Open http://$HOSTNAME/ and log in as admin:test"; diff --git a/server/setup/mailtrain-nginx.conf b/server/setup/mailtrain-nginx.conf deleted file mode 100644 index 06541286..00000000 --- a/server/setup/mailtrain-nginx.conf +++ /dev/null @@ -1,20 +0,0 @@ -# This example sets up mailtrain.org/www.mailtrain.org virtual domains -# for Nginx and proxies requests for these domains to localhost port 3000 - -server { - listen 80; - listen [::]:80; - - server_name mailtrain.org www.mailtrain.org; - access_log /var/log/nginx/mailtrain.log; - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header HOST $http_host; - proxy_set_header X-NginX-Proxy true; - - proxy_pass http://127.0.0.1:3000; - proxy_redirect off; - } -} diff --git a/server/setup/mailtrain.conf b/server/setup/mailtrain.conf deleted file mode 100644 index 2dff9463..00000000 --- a/server/setup/mailtrain.conf +++ /dev/null @@ -1,17 +0,0 @@ -# upstart script for example server - -description "Mailtrain server" -author "Andris Reinman " - -start on runlevel [2345] -stop on runlevel [!2345] - -env NODE_ENV=production - -respawn -respawn limit 10 0 - -script - cd /opt/mailtrain - exec node index.js >> /var/log/mailtrain.log 2>&1 -end script diff --git a/server/setup/mailtrain.service b/server/setup/mailtrain.service deleted file mode 100644 index 5501e8ae..00000000 --- a/server/setup/mailtrain.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Mailtrain server -Requires=mysql.service -After=syslog.target network.target - -[Service] -Environment="NODE_ENV=production" -WorkingDirectory=/opt/mailtrain -ExecStart=/usr/bin/node index.js -Type=simple -Restart=always -RestartSec=10 - -[Install] -WantedBy=multi-user.target -# Alias=mailtrain.service diff --git a/setup/install-centos7.sh b/setup/install-centos7.sh new file mode 100644 index 00000000..4dd0b60c --- /dev/null +++ b/setup/install-centos7.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +# This installation script works on CentOS 7 +# Run as root! + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +set -e + +yum -y install epel-release + +curl --silent --location https://rpm.nodesource.com/setup_11.x | bash - +cat > /etc/yum.repos.d/mongodb-org.repo < config/production.yaml <> workers/reports/config/production.yaml < /etc/logrotate.d/mailtrain +/var/log/mailtrain.log { + daily + rotate 12 + compress + delaycompress + missingok + notifempty + copytruncate + nomail +} +EOM + +# Set up systemd service script +cp setup/mailtrain-centos7.service /etc/systemd/system/mailtrain.service +systemctl enable mailtrain.service + +# Start the service +systemctl daemon-reload + +systemctl start mailtrain.service + +echo "Success! Open http://$HOSTNAME/ and log in as admin:test"; diff --git a/server/setup/mailtrain-apache-sample.conf b/setup/mailtrain-apache-sample.conf similarity index 100% rename from server/setup/mailtrain-apache-sample.conf rename to setup/mailtrain-apache-sample.conf diff --git a/server/setup/mailtrain-centos7.service b/setup/mailtrain-centos7.service similarity index 87% rename from server/setup/mailtrain-centos7.service rename to setup/mailtrain-centos7.service index 9fcd5b1a..d7b0ddaa 100644 --- a/server/setup/mailtrain-centos7.service +++ b/setup/mailtrain-centos7.service @@ -5,7 +5,7 @@ After=syslog.target network.target [Service] Environment="NODE_ENV=production" -WorkingDirectory=/opt/mailtrain +WorkingDirectory=/opt/mailtrain/server ExecStart=/usr/bin/node index.js Type=simple Restart=always