Skip to content

Commit 7ffd6cb

Browse files
bvdberg01havardthomMickLesk
authored
New script: listmonk LXC (#442)
* New script: listmonk LXC * Fixed issues after PR review * Fixed issues after PR review Co-Authored-By: Håvard Gjøby Thom <[email protected]> * add network.target Co-authored-by: Håvard Gjøby Thom <[email protected]> --------- Co-authored-by: Håvard Gjøby Thom <[email protected]> Co-authored-by: CanbiZ <[email protected]>
1 parent fab35a6 commit 7ffd6cb

File tree

3 files changed

+209
-0
lines changed

3 files changed

+209
-0
lines changed

ct/listmonk.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2024 community-scripts ORG
4+
# Author: bvdberg01
5+
# License: MIT
6+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
function header_info {
9+
clear
10+
cat <<"EOF"
11+
___ __ __
12+
/ (_)____/ /_____ ___ ____ ____ / /__
13+
/ / / ___/ __/ __ `__ \/ __ \/ __ \/ //_/
14+
/ / (__ ) /_/ / / / / / /_/ / / / / ,<
15+
/_/_/____/\__/_/ /_/ /_/\____/_/ /_/_/|_|
16+
17+
EOF
18+
}
19+
header_info
20+
echo -e "Loading..."
21+
APP="listmonk"
22+
var_disk="4"
23+
var_cpu="1"
24+
var_ram="512"
25+
var_os="debian"
26+
var_version="12"
27+
variables
28+
color
29+
catch_errors
30+
31+
function default_settings() {
32+
CT_TYPE="1"
33+
PW=""
34+
CT_ID=$NEXTID
35+
HN=$NSAPP
36+
DISK_SIZE="$var_disk"
37+
CORE_COUNT="$var_cpu"
38+
RAM_SIZE="$var_ram"
39+
BRG="vmbr0"
40+
NET="dhcp"
41+
GATE=""
42+
APT_CACHER=""
43+
APT_CACHER_IP=""
44+
DISABLEIP6="no"
45+
MTU=""
46+
SD=""
47+
NS=""
48+
MAC=""
49+
VLAN=""
50+
SSH="no"
51+
VERB="no"
52+
echo_default
53+
}
54+
55+
function update_script() {
56+
header_info
57+
check_container_storage
58+
check_container_resources
59+
if [[ ! -f /etc/systemd/system/listmonk.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
60+
61+
RELEASE=$(curl -s https://api.github.com/repos/knadh/listmonk/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
62+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
63+
msg_info "Stopping ${APP}"
64+
systemctl stop listmonk
65+
msg_ok "Stopped ${APP}"
66+
67+
msg_info "Updating ${APP} to v${RELEASE}"
68+
cd /opt
69+
wget -q "https://github.com/knadh/listmonk/releases/download/v${RELEASE}/listmonk_${RELEASE}_linux_amd64.tar.gz"
70+
tar -xzf "listmonk_${RELEASE}_linux_amd64.tar.gz" -C /opt/listmonk
71+
/opt/listmonk/listmonk --upgrade --yes --config /opt/listmonk/config.toml &>/dev/null
72+
echo "${RELEASE}" >/opt/${APP}_version.txt
73+
msg_ok "Updated $APP to v${RELEASE}"
74+
75+
msg_info "Starting ${APP}"
76+
systemctl start listmonk
77+
msg_ok "Started ${APP}"
78+
79+
msg_info "Cleaning up"
80+
rm -rf "/opt/listmonk_${RELEASE}_linux_amd64.tar.gz"
81+
msg_ok "Cleaned"
82+
83+
msg_ok "Updated Successfully"
84+
else
85+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
86+
fi
87+
exit
88+
}
89+
90+
start
91+
build_container
92+
description
93+
94+
msg_ok "Completed Successfully!\n"
95+
echo -e "${APP} should be reachable by going to the following URL.
96+
${BL}http://${IP}:9000${CL} \n"

install/listmonk-install.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2024 community-scripts ORG
4+
# Author: bvdberg01
5+
# License: MIT
6+
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt-get install -y \
18+
curl \
19+
sudo \
20+
mc \
21+
postgresql
22+
msg_ok "Installed Dependencies"
23+
24+
msg_info "Setting up PostgreSQL"
25+
DB_NAME=listmonk
26+
DB_USER=listmonk
27+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
28+
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
29+
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;"
30+
{
31+
echo "listmonk-Credentials"
32+
echo -e "listmonk Database User: \e[32m$DB_USER\e[0m"
33+
echo -e "listmonk Database Password: \e[32m$DB_PASS\e[0m"
34+
echo -e "listmonk Database Name: \e[32m$DB_NAME\e[0m"
35+
} >> ~/listmonk.creds
36+
msg_ok "Set up PostgreSQL"
37+
38+
msg_info "Installing listmonk"
39+
cd /opt
40+
mkdir /opt/listmonk
41+
RELEASE=$(curl -s https://api.github.com/repos/knadh/listmonk/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
42+
wget -q "https://github.com/knadh/listmonk/releases/download/v${RELEASE}/listmonk_${RELEASE}_linux_amd64.tar.gz"
43+
tar -xzf "listmonk_${RELEASE}_linux_amd64.tar.gz" -C /opt/listmonk
44+
45+
$STD /opt/listmonk/listmonk --new-config --config /opt/listmonk/config.toml
46+
sed -i -e 's/address = "localhost:9000"/address = "0.0.0.0:9000"/' -e 's/^password = ".*"/password = "'"$DB_PASS"'"/' /opt/listmonk/config.toml
47+
$STD /opt/listmonk/listmonk --install --yes --config /opt/listmonk/config.toml
48+
49+
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
50+
msg_ok "Installed listmonk"
51+
52+
msg_info "Creating Service"
53+
cat <<EOF >/etc/systemd/system/listmonk.service
54+
[Unit]
55+
Description=Listmonk Service
56+
Wants=network.target
57+
After=postgresql.service
58+
59+
[Service]
60+
Type=simple
61+
ExecStart=/opt/listmonk/listmonk --config /opt/listmonk/config.toml
62+
Restart=always
63+
RestartSec=3
64+
WorkingDirectory=/opt/listmonk
65+
66+
[Install]
67+
WantedBy=multi-user.target
68+
EOF
69+
systemctl enable -q --now listmonk
70+
msg_ok "Created Service"
71+
72+
motd_ssh
73+
customize
74+
75+
msg_info "Cleaning up"
76+
rm -rf "/opt/listmonk_${RELEASE}_linux_amd64.tar.gz"
77+
$STD apt-get -y autoremove
78+
$STD apt-get -y autoclean
79+
msg_ok "Cleaned"

json/listmonk.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "listmonk",
3+
"slug": "listmonk",
4+
"categories": [
5+
14
6+
],
7+
"date_created": "2024-11-22",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": "9000",
12+
"documentation": "https://listmonk.app/docs/",
13+
"website": "https://listmonk.app/",
14+
"logo": "https://listmonk.app/static/images/logo.svg",
15+
"description": "High performance, self-hosted, newsletter and mailing list manager with a modern dashboard.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/listmonk.sh",
20+
"resources": {
21+
"cpu": "1",
22+
"ram": "512",
23+
"hdd": "4",
24+
"os": "debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": []
34+
}

0 commit comments

Comments
 (0)