From a3ba39b9decab84de915660a34512e33d32d560c Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:26:46 +0100 Subject: [PATCH] Add Piler email archiving support and update scripts Introduces Piler email archiving with new install and container scripts, and adds metadata for frontend integration. Updates Pixelfed and Postgresus install scripts to improve PHP-FPM pool configuration and streamline build steps. --- ct/piler.sh | 88 ++++++++++ frontend/public/json/piler.json | 23 +++ install/piler-install.sh | 298 ++++++++++++++++++++++++++++++++ install/pixelfed-install.sh | 8 +- install/postgresus-install.sh | 5 +- 5 files changed, 414 insertions(+), 8 deletions(-) create mode 100644 ct/piler.sh create mode 100644 frontend/public/json/piler.json create mode 100644 install/piler-install.sh diff --git a/ct/piler.sh b/ct/piler.sh new file mode 100644 index 000000000..e592f2e3f --- /dev/null +++ b/ct/piler.sh @@ -0,0 +1,88 @@ +#!/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: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://www.mailpiler.org/ + +APP="Piler" +var_tags="${var_tags:-email;archive;smtp}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-4096}" +var_disk="${var_disk:-20}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /etc/piler/piler.conf ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE_NEW=$(curl -fsSL https://www.mailpiler.org/download.php | grep -oP 'piler-\K[0-9]+\.[0-9]+\.[0-9]+' | head -1) + RELEASE_OLD=$(pilerd -v 2>/dev/null | grep -oP 'version \K[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown") + + if [[ "${RELEASE_NEW}" != "${RELEASE_OLD}" ]]; then + msg_info "Stopping Piler Services" + $STD systemctl stop piler + $STD systemctl stop manticore + msg_ok "Stopped Piler Services" + + msg_info "Backing up Configuration" + cp /etc/piler/piler.conf /tmp/piler.conf.bak + msg_ok "Backed up Configuration" + + msg_info "Updating to v${RELEASE_NEW}" + cd /tmp + curl -fsSL "https://bitbucket.org/jsuto/piler/downloads/piler-${RELEASE_NEW}.tar.gz" -o piler.tar.gz + tar -xzf piler.tar.gz + cd "piler-${RELEASE_NEW}" + + $STD ./configure \ + --localstatedir=/var \ + --with-database=mysql \ + --sysconfdir=/etc/piler \ + --enable-memcached + + $STD make + $STD make install + $STD ldconfig + + cd /tmp && rm -rf "piler-${RELEASE_NEW}" piler.tar.gz + msg_ok "Updated to v${RELEASE_NEW}" + + msg_info "Restoring Configuration" + cp /tmp/piler.conf.bak /etc/piler/piler.conf + rm -f /tmp/piler.conf.bak + chown piler:piler /etc/piler/piler.conf + msg_ok "Restored Configuration" + + msg_info "Starting Piler Services" + $STD systemctl start manticore + $STD systemctl start piler + msg_ok "Started Piler Services" + msg_ok "Updated Successfully to v${RELEASE_NEW}" + else + msg_ok "No update available (current: v${RELEASE_OLD})" + 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}${CL}" diff --git a/frontend/public/json/piler.json b/frontend/public/json/piler.json new file mode 100644 index 000000000..1b8cb08c3 --- /dev/null +++ b/frontend/public/json/piler.json @@ -0,0 +1,23 @@ +{ + "name": "Piler", + "slug": "piler", + "categories": [ + "Email", + "Archive" + ], + "date_created": "2025-12-15", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": "80", + "documentation": "https://www.mailpiler.org/", + "website": "https://www.mailpiler.org/", + "logo": "https://www.mailpiler.org/piler-logo.png", + "description": "Piler is a feature rich open source email archiving solution with support for legal hold, deduplication, full text search, and many more features.", + "install_methods": [ + { + "type": "default", + "script": "ct/piler.sh" + } + ] +} diff --git a/install/piler-install.sh b/install/piler-install.sh new file mode 100644 index 000000000..18b9374ac --- /dev/null +++ b/install/piler-install.sh @@ -0,0 +1,298 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://www.mailpiler.org/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y \ + nginx \ + openssl \ + libtre5 \ + catdoc \ + poppler-utils \ + unrtf \ + tnef \ + clamav \ + clamav-daemon \ + memcached \ + sysstat \ + python3 \ + python3-mysqldb +msg_ok "Installed Dependencies" + +import_local_ip +setup_mariadb +MARIADB_DB_NAME="piler" MARIADB_DB_USER="piler" setup_mysql_db +PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="ldap,gd,memcached,pdo,mysql,curl,zip" setup_php + +msg_info "Installing Manticore Search" +curl -fsSL https://repo.manticoresearch.com/manticore-repo.noarch.deb -o /tmp/manticore-repo.deb +$STD dpkg -i /tmp/manticore-repo.deb +$STD apt update +$STD apt install -y manticore manticore-extra +rm -f /tmp/manticore-repo.deb +msg_ok "Installed Manticore Search" + +msg_info "Installing Piler" +VERSION="1.4.8" +cd /tmp +curl -fsSL "https://github.com/jsuto/piler/releases/download/piler-${VERSION}/piler_${VERSION}-bookworm_amd64.deb" -o piler.deb +curl -fsSL "https://github.com/jsuto/piler/releases/download/piler-${VERSION}/piler-webui_${VERSION}-bookworm_amd64.deb" -o piler-webui.deb + +$STD dpkg -i piler.deb +$STD apt-get -f install -y +$STD dpkg -i piler-webui.deb +$STD apt-get -f install -y + +rm -f piler.deb piler-webui.deb +msg_ok "Installed Piler v${VERSION}" + +msg_info "Configuring Piler Database" +cd /usr/local/share/piler +mysql -u root "${MARIADB_DB_NAME}" /etc/piler/piler.conf +hostid=piler.${LOCAL_IP}.nip.io +update_counters_to_memcached=1 + +mysql_hostname=localhost +mysql_database=${MARIADB_DB_NAME} +mysql_username=${MARIADB_DB_USER} +mysql_password=${MARIADB_DB_PASS} +mysql_socket=/var/run/mysqld/mysqld.sock + +archive_dir=/var/piler/store +data_dir=/var/piler +tmp_dir=/var/piler/tmp + +listen_addr=0.0.0.0 +listen_port=25 + +encrypt_messages=1 +key=${PILER_KEY} +iv=0123456789ABCDEF + +memcached_servers=127.0.0.1 + +enable_clamav=1 +clamd_socket=/var/run/clamav/clamd.ctl + +spam_header_line=X-Spam-Status: Yes + +verbosity=1 +EOF + +chown piler:piler /etc/piler/piler.conf +chmod 640 /etc/piler/piler.conf +chown -R piler:piler /var/piler +chmod 750 /var/piler +msg_ok "Configured Piler" + +msg_info "Configuring Manticore Search" +cat </etc/manticoresearch/manticore.conf +searchd { + listen = 9306:mysql + listen = 9312 + listen = 9308:http + log = /var/log/manticore/searchd.log + query_log = /var/log/manticore/query.log + pid_file = /var/run/manticore/searchd.pid + binlog_path = /var/lib/manticore/data +} + +source piler1 { + type = mysql + sql_host = localhost + sql_user = ${MARIADB_DB_USER} + sql_pass = ${MARIADB_DB_PASS} + sql_db = ${MARIADB_DB_NAME} + sql_port = 3306 + + sql_query = SELECT id, from_addr, to_addr, subject, body, sent FROM metadata + sql_attr_timestamp = sent +} + +index piler1 { + source = piler1 + path = /var/piler/manticore/piler1 + min_word_len = 1 + charset_table = 0..9, A..Z->a..z, a..z, U+00E1, U+00E9 +} + +index tag1 { + type = rt + path = /var/piler/manticore/tag1 + rt_field = tag + rt_attr_uint = uid +} + +index note1 { + type = rt + path = /var/piler/manticore/note1 + rt_field = note + rt_attr_uint = uid +} +EOF + +mkdir -p /var/log/manticore +chown -R manticore:manticore /var/log/manticore +chown -R piler:piler /var/piler/manticore +msg_ok "Configured Manticore Search" + +msg_info "Creating Piler Service" +cat </etc/systemd/system/piler.service +[Unit] +Description=Piler Email Archiving +After=network.target mysql.service manticore.service +Requires=mysql.service manticore.service + +[Service] +Type=forking +User=piler +Group=piler +ExecStart=/usr/local/sbin/pilerd -c /etc/piler/piler.conf +PIDFile=/var/piler/pilerd.pid +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF + +$STD systemctl daemon-reload +$STD systemctl enable --now manticore +$STD systemctl enable --now memcached +$STD systemctl enable --now clamav-daemon +$STD systemctl enable --now piler +msg_ok "Created Piler Service" + +msg_info "Configuring PHP-FPM Pool" +cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/piler.conf +sed -i 's/\[www\]/[piler]/' /etc/php/8.4/fpm/pool.d/piler.conf +sed -i 's/^user = www-data/user = piler/' /etc/php/8.4/fpm/pool.d/piler.conf +sed -i 's/^group = www-data/group = piler/' /etc/php/8.4/fpm/pool.d/piler.conf +sed -i 's|^listen = .*|listen = /run/php/php8.4-fpm-piler.sock|' /etc/php/8.4/fpm/pool.d/piler.conf +$STD systemctl restart php8.4-fpm +msg_ok "Configured PHP-FPM Pool" + +msg_info "Configuring Piler Web GUI" +cd /var/www/piler + +cat </var/www/piler/config-site.php + +EOF + +chown -R piler:piler /var/www/piler +chmod 755 /var/www/piler +msg_ok "Installed Piler Web GUI" + +msg_info "Configuring Nginx" +cat </etc/nginx/sites-available/piler +server { + listen 80; + server_name _; + root /var/www/piler; + index index.php; + + access_log /var/log/nginx/piler-access.log; + error_log /var/log/nginx/piler-error.log; + + charset utf-8; + + location / { + try_files \$uri \$uri/ /index.php?\$args; + } + + location ~ \.php$ { + fastcgi_pass unix:/run/php/php8.4-fpm-piler.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; + include fastcgi_params; + } + + location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|woff|woff2)$ { + access_log off; + expires max; + } + + location ~ /\.ht { + deny all; + } +} +EOF + +ln -sf /etc/nginx/sites-available/piler /etc/nginx/sites-enabled/piler +rm -f /etc/nginx/sites-enabled/default +$STD nginx -t +$STD systemctl enable --now nginx +msg_ok "Configured Nginx" + +msg_info "Setting Up Cron Jobs" +cat </etc/cron.d/piler +30 6 * * * piler /usr/local/libexec/piler/indexer.delta.sh +30 7 * * * piler /usr/local/libexec/piler/indexer.main.sh +*/15 * * * * piler /usr/local/bin/pilerstat +30 2 * * * piler /usr/local/bin/pilerpurge +3 * * * * piler /usr/local/bin/pilerconf +EOF +msg_ok "Set Up Cron Jobs" + +motd_ssh +customize +cleanup_lxc diff --git a/install/pixelfed-install.sh b/install/pixelfed-install.sh index dcb4134da..a122fe356 100644 --- a/install/pixelfed-install.sh +++ b/install/pixelfed-install.sh @@ -43,13 +43,12 @@ systemctl restart redis-server msg_ok "Redis configured" msg_info "Configuring PHP-FPM Pool" -mkdir -p /run/php-fpm cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/pixelfed.conf sed -i 's/\[www\]/[pixelfed]/' /etc/php/8.4/fpm/pool.d/pixelfed.conf sed -i 's/^user = www-data/user = pixelfed/' /etc/php/8.4/fpm/pool.d/pixelfed.conf sed -i 's/^group = www-data/group = pixelfed/' /etc/php/8.4/fpm/pool.d/pixelfed.conf -sed -i 's|^listen = .*|listen = /run/php-fpm/pixelfed.sock|' /etc/php/8.4/fpm/pool.d/pixelfed.conf -sed -i 's/^listen.owner = .*/listen.owner = pixelfed/' /etc/php/8.4/fpm/pool.d/pixelfed.conf +sed -i 's|^listen = .*|listen = /run/php/php8.4-fpm-pixelfed.sock|' /etc/php/8.4/fpm/pool.d/pixelfed.conf +sed -i 's/^listen.owner = .*/listen.owner = www-data/' /etc/php/8.4/fpm/pool.d/pixelfed.conf sed -i 's/^listen.group = .*/listen.group = www-data/' /etc/php/8.4/fpm/pool.d/pixelfed.conf systemctl restart php8.4-fpm msg_ok "PHP-FPM Pool configured" @@ -75,6 +74,7 @@ sed -i "s|REDIS_PORT=.*|REDIS_PORT=6379|" .env sed -i "s|ACTIVITY_PUB=.*|ACTIVITY_PUB=true|" .env sed -i "s|AP_REMOTE_FOLLOW=.*|AP_REMOTE_FOLLOW=true|" .env sed -i "s|OAUTH_ENABLED=.*|OAUTH_ENABLED=true|" .env +echo "SESSION_SECURE_COOKIE=false" >>.env chown -R pixelfed:pixelfed /opt/pixelfed chmod -R 755 /opt/pixelfed @@ -122,7 +122,7 @@ server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php-fpm/pixelfed.sock; + fastcgi_pass unix:/run/php/php8.4-fpm-pixelfed.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/install/postgresus-install.sh b/install/postgresus-install.sh index 812346647..4de9b8208 100644 --- a/install/postgresus-install.sh +++ b/install/postgresus-install.sh @@ -26,16 +26,13 @@ NODE_VERSION="24" setup_nodejs fetch_and_deploy_gh_release "postgresus" "RostislavDugin/postgresus" "tarball" "latest" "/opt/postgresus" msg_info "Building Postgresus (Patience)" -# Build frontend cd /opt/postgresus/frontend $STD npm ci $STD npm run build - -# Build backend cd /opt/postgresus/backend $STD go mod tidy $STD go mod download -$STD CGO_ENABLED=0 go build -o /opt/postgresus/postgresus ./cmd/main.go +CGO_ENABLED=0 go build -o postgresus . mkdir -p /opt/postgresus/{data,backups,logs} cp -r /opt/postgresus/frontend/dist /opt/postgresus/ui cp -r /opt/postgresus/backend/migrations /opt/postgresus/