add listmonk app
This commit is contained in:
53
modules/apps/listmonk/lib/scripts/install-listmonk.sh
Normal file
53
modules/apps/listmonk/lib/scripts/install-listmonk.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
#LISTMONK_BINARY=/usr/local/bin/listmonk
|
||||
#LISTMONK_VERSION=6.0.0
|
||||
#LISTMONK_CONFIG=/home/listmonk/config.toml
|
||||
#DB_USER
|
||||
#DB_PASS
|
||||
#DB_NAME
|
||||
set -euo pipefail
|
||||
|
||||
source /opt/environment/.env
|
||||
|
||||
# Listmonk binary
|
||||
if [ ! -f $LISTMONK_BINARY ]; then
|
||||
wget -O /tmp/listmonk.tar.gz "https://github.com/knadh/listmonk/releases/download/v${LISTMONK_VERSION}/listmonk_${LISTMONK_VERSION}_linux_amd64.tar.gz"
|
||||
mkdir /tmp/listmonk
|
||||
tar -xzf /tmp/listmonk.tar.gz -C /tmp/listmonk
|
||||
mv /tmp/listmonk/listmonk $LISTMONK_BINARY
|
||||
chmod +x $LISTMONK_BINARY
|
||||
fi
|
||||
|
||||
# Listmonk config
|
||||
|
||||
cat > $LISTMONK_CONFIG <<EOF
|
||||
[app]
|
||||
address = "0.0.0.0:9000"
|
||||
|
||||
[db]
|
||||
host = "localhost"
|
||||
port = 5432
|
||||
user = "$DB_USER"
|
||||
password = "$DB_PASS"
|
||||
database = "$DB_NAME"
|
||||
ssl_mode = "disable"
|
||||
max_open = 25
|
||||
max_idle = 25
|
||||
max_lifetime = "300s"
|
||||
EOF
|
||||
|
||||
# Listmonk pgsql init db
|
||||
|
||||
sudo -u postgres psql <<EOF
|
||||
CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';
|
||||
CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
|
||||
EOF
|
||||
|
||||
$LISTMONK_BINARY --install --config $LISTMONK_CONFIG --yes
|
||||
|
||||
systemctl start restore-backup.service
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable listmonk
|
||||
systemctl start listmonk
|
||||
Reference in New Issue
Block a user