From 58f0b23ba6980fd43acdc42e2d19b09b719c2a91 Mon Sep 17 00:00:00 2001 From: tremor021 Date: Mon, 15 Dec 2025 18:50:56 +0100 Subject: [PATCH] Add Mail-Archiver script --- ct/mail-archiver.sh | 44 +++++++++++++++++++++ install/mail-archiver-install.sh | 68 ++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 ct/mail-archiver.sh create mode 100644 install/mail-archiver-install.sh diff --git a/ct/mail-archiver.sh b/ct/mail-archiver.sh new file mode 100644 index 000000000..832100c43 --- /dev/null +++ b/ct/mail-archiver.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/s1t5/mail-archiver + +APP="Mail-Archiver" +var_tags="${var_tags:-mail-archiver}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/mail-archiver ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "mail-archiver-build" "s1t5/mail-archiver"; then + msg_ok "Updated successfully!" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5380${CL}" diff --git a/install/mail-archiver-install.sh b/install/mail-archiver-install.sh new file mode 100644 index 000000000..8c436ba32 --- /dev/null +++ b/install/mail-archiver-install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/s1t5/mail-archiver + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +setup_deb822_repo \ + "microsoft" \ + "https://packages.microsoft.com/keys/microsoft-2025.asc" \ + "https://packages.microsoft.com/debian/13/prod/" \ + "trixie" \ + "main" +$STD apt install -y \ + dotnet-sdk-10.0 \ + aspnetcore-runtime-8.0 +msg_ok "Installed Dependencies" + +PG_VERSION="17" setup_postgresql +PG_DB_NAME="mailarchiver_db" PG_DB_USER="mailarchiver" setup_postgresql_db +fetch_and_deploy_gh_release "mail-archiver-build" "s1t5/mail-archiver" "tarball" + +msg_info "Setting up Mail-Archiver" +mkdir -p /opt/mail-archiver +cd /opt/mail-archiver-build +$STD dotnet restore +$STD dotnet publish -c Release -o /opt/mail-archiver +cp /opt/mail-archiver-build/appsettings.json /opt/mail-archiver/appsettings.json +sed -i "s|\"DefaultConnection\": \"[^\"]*\"|\"DefaultConnection\": \"Host=localhost;Database=mailarchiver_db;Username=mailarchiver;Password=$PG_DB_PASS\"|" /opt/mail-archiver/appsettings.json +rm -rf /opt/mail-archiver-build + +cat </opt/mail-archiver/.env +ASPNETCORE_URLS=http://+:5000 +ASPNETCORE_ENVIRONMENT=Production +TZ=UTC +EOF +msg_ok "Setup Mail-Archiver" + +msg_info "Creating Service" +cat </etc/systemd/system/mail-archiver.service +[Unit] +Description=Mail-Archiver Service +After=network.target + +[Service] +EnvironmentFile=/opt/mail-archiver/.env +WorkingDirectory=/opt/mail-archiver +ExecStart=/usr/bin/dotnet MailArchiver.dll +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now mail-archiver +msg_info "Created Service" + +motd_ssh +customize +cleanup_lxc