diff --git a/ct/mail-archiver.sh b/ct/mail-archiver.sh new file mode 100644 index 000000000..8c06febf8 --- /dev/null +++ b/ct/mail-archiver.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/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" "s1t5/mail-archiver"; then + msg_info "Stopping Mail-Archiver" + systemctl stop mail-archiver + msg_ok "Stopped Mail-Archiver" + + msg_info "Creating Backup" + cp /opt/mail-archiver/appsettings.json /opt/mail-archiver/.env /opt/ + [[ -d /opt/mail-archiver/DataProtection-Keys ]] && cp -r /opt/mail-archiver/DataProtection-Keys /opt + msg_ok "Created Backup" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mail-archiver" "s1t5/mail-archiver" "tarball" + + msg_info "Updating Mail-Archiver" + mv /opt/mail-archiver /opt/mail-archiver-build + cd /opt/mail-archiver-build + $STD dotnet restore + $STD dotnet publish -c Release -o /opt/mail-archiver + rm -rf /opt/mail-archiver-build + msg_ok "Updated Mail-Archiver" + + msg_info "Restoring Backup" + cp /opt/appsettings.json /opt/.env /opt/mail-archiver + [[ -d /opt/DataProtection-Keys ]] && cp -r /opt/DataProtection-Keys /opt/mail-archiver/ + msg_ok "Restored Backup" + + msg_info "Starting Mail-Archiver" + systemctl start mail-archiver + msg_ok "Started Mail-Archiver" + 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}:5000${CL}" diff --git a/frontend/public/json/mail-archiver.json b/frontend/public/json/mail-archiver.json new file mode 100644 index 000000000..006cae8ca --- /dev/null +++ b/frontend/public/json/mail-archiver.json @@ -0,0 +1,35 @@ +{ + "name": "Mail-Archiver", + "slug": "mail-archiver", + "categories": [ + 7 + ], + "date_created": "2025-12-12", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 5000, + "documentation": "https://github.com/s1t5/mail-archiver/blob/main/doc/Index.md", + "config_path": "/opt/mail-archiver/.env, /opt/mail-archiver/appsettings.json", + "website": "https://github.com/s1t5/mail-archiver", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/mail-archiver.webp", + "description": "Mail-Archiver is a web application for archiving, searching, and exporting emails from multiple accounts. Featuring folder sync, attachment support, mailbox migration and a dashboard.", + "install_methods": [ + { + "type": "default", + "script": "ct/mail-archiver.sh", + "resources": { + "cpu": 1, + "ram": 2048, + "hdd": 8, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": "admin", + "password": "secure123!" + }, + "notes": [] +} diff --git a/install/mail-archiver-install.sh b/install/mail-archiver-install.sh new file mode 100644 index 000000000..61d60ebfb --- /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/ProxmoxVE/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" "s1t5/mail-archiver" "tarball" + +msg_info "Setting up Mail-Archiver" +mv /opt/mail-archiver /opt/mail-archiver-build +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