#!/bin/bash # # Listmonk Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin config_listmonk() { echo -ne "\n* Configuring /federated/apps/listmonk container.." spin & SPINPID=$! if [ ! -d "/federated/apps/listmonk" ]; then mkdir -p /federated/apps/listmonk/static /federated/apps/listmonk/data/listmonk fi cat > /federated/apps/listmonk/docker-compose.yml < /federated/apps/listmonk/.env < /federated/apps/listmonk/data/listmonk/config.toml < /dev/null echo -ne "done." } start_listmonk() { # Install the database scheme first docker-compose -f /federated/apps/listmonk/docker-compose.yml run --rm listmonk ./listmonk --install --yes &> /dev/null # Change app.root_url and other settings to our domain docker exec postgresql psql -U listmonk -c "update settings set value='\"http://listmonk.$DOMAIN\"' where key='app.root_url'" &> /dev/null docker exec postgresql psql -U listmonk -c "update settings set value='\"listmonk \"' where key='app.from_email'" &> /dev/null docker exec postgresql psql -U listmonk -c "update settings set value='[{\"host\": \"mail.$DOMAIN\", \"port\": 587, \"enabled\": true, \"password\": \"$ADMINPASS\", \"tls_type\": \"STARTTLS\", \"username\": \"admin\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}, {\"host\": \"smtp.gmail.com\", \"port\": 465, \"enabled\": false, \"password\": \"password\", \"tls_type\": \"TLS\", \"username\": \"username@gmail.com\", \"max_conns\": 10, \"idle_timeout\": \"15s\", \"wait_timeout\": \"5s\", \"auth_protocol\": \"login\", \"email_headers\": [], \"hello_hostname\": \"\", \"max_msg_retries\": 2, \"tls_skip_verify\": false}]' where key='smtp';" &> /dev/null # Grab the container IP from docker-compose above SERVICE_IP=`grep ipv4_address /federated/apps/listmonk/docker-compose.yml | awk '{ print $2 }'` # Start service with command to make sure it's up before proceeding start_service "listmonk" "nc -z $SERVICE_IP 9000 &> /dev/null" kill -9 $SPINPID &> /dev/null echo -ne "done." }