feat: implement global autoresponder plugin
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
BASE_DIR="/usr/local/hitme_plugins/global-autoresponders"
|
||||
STATE_FILE="$BASE_DIR/config/backend-state.json"
|
||||
|
||||
usage() {
|
||||
echo "Usage: scripts/backend.sh da|exim" >&2
|
||||
}
|
||||
|
||||
if [ "${1:-}" != "da" ] && [ "${1:-}" != "exim" ]; then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$BASE_DIR/config" "$BASE_DIR/data" "$BASE_DIR/state" "$BASE_DIR/logs"
|
||||
chmod 700 "$BASE_DIR/config" "$BASE_DIR/logs"
|
||||
|
||||
if [ "$1" = "da" ]; then
|
||||
cat > "$STATE_FILE" <<'EOF'
|
||||
{"active_backend":"da","migration_status":"complete"}
|
||||
EOF
|
||||
echo "Backend set to da"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CUSTOM_DIR="/usr/local/directadmin/custombuild/custom/exim"
|
||||
if [ ! -d "$CUSTOM_DIR" ]; then
|
||||
echo "Cannot enable exim backend: safe CustomBuild exim customization directory not found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > "$STATE_FILE" <<'EOF'
|
||||
{"active_backend":"exim","migration_status":"pending_exim_validation"}
|
||||
EOF
|
||||
echo "Backend prepared for exim; validate Exim customization before production use."
|
||||
@@ -0,0 +1,2 @@
|
||||
# global-autoresponder router placeholder
|
||||
# This file must only be installed through DirectAdmin/CustomBuild-safe Exim customization paths.
|
||||
@@ -0,0 +1,2 @@
|
||||
# global-autoresponder transport placeholder
|
||||
# This file must only be installed through DirectAdmin/CustomBuild-safe Exim customization paths.
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/local/bin/php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__) . '/exec/lib/Settings.php';
|
||||
require_once dirname(__DIR__) . '/exec/lib/MessageClassifier.php';
|
||||
require_once dirname(__DIR__) . '/exec/lib/RepeatState.php';
|
||||
require_once dirname(__DIR__) . '/exec/lib/MailSender.php';
|
||||
|
||||
echo "global-autoresponder worker placeholder: enable only after safe Exim integration review.\n";
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
BASE_DIR="/usr/local/hitme_plugins/global-autoresponders"
|
||||
PLUGIN_DIR="/usr/local/directadmin/plugins/global-autoresponder"
|
||||
|
||||
mkdir -p "$BASE_DIR/config/users" "$BASE_DIR/data/users" "$BASE_DIR/state/replies" "$BASE_DIR/logs"
|
||||
chmod 700 "$BASE_DIR/config" "$BASE_DIR/logs"
|
||||
chmod 711 "$BASE_DIR/data" "$BASE_DIR/state"
|
||||
|
||||
if [ ! -f "$BASE_DIR/config/plugin-settings.conf" ]; then
|
||||
cp "$PLUGIN_DIR/plugin-settings.conf" "$BASE_DIR/config/plugin-settings.conf"
|
||||
chmod 600 "$BASE_DIR/config/plugin-settings.conf"
|
||||
fi
|
||||
|
||||
if [ ! -f "$BASE_DIR/config/backend-state.json" ]; then
|
||||
printf '%s\n' '{"active_backend":"da","migration_status":"complete"}' > "$BASE_DIR/config/backend-state.json"
|
||||
chmod 600 "$BASE_DIR/config/backend-state.json"
|
||||
fi
|
||||
|
||||
touch "$BASE_DIR/logs/audit.log"
|
||||
chmod 600 "$BASE_DIR/logs/audit.log"
|
||||
echo "global-autoresponder installed"
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
VERSION="$(awk -F= '$1=="version"{print $2}' plugin.conf)"
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Cannot determine version from plugin.conf" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f images/user_icon.svg ]; then
|
||||
echo "Missing user-supplied icon: src/images/user_icon.svg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ROOT_DIR="$(cd .. && pwd)"
|
||||
mkdir -p "$ROOT_DIR/archives/$VERSION"
|
||||
tar -czf "$ROOT_DIR/archives/$VERSION/global-autoresponder.tar.gz" \
|
||||
--exclude='./.git' \
|
||||
--exclude='./tests' \
|
||||
--exclude='./data' \
|
||||
--exclude='./state' \
|
||||
--exclude='./logs' \
|
||||
--exclude='./*.log' \
|
||||
--exclude='./.DS_Store' \
|
||||
.
|
||||
echo "$ROOT_DIR/archives/$VERSION/global-autoresponder.tar.gz"
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/usr/local/bin/php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
echo "DirectAdmin vacation synchronization is executed by plugin handlers when DA backend is active.\n";
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
BASE_DIR="/usr/local/hitme_plugins/global-autoresponders"
|
||||
if [ "${PURGE_GLOBAL_AUTORESPONDER_DATA:-0}" = "1" ]; then
|
||||
rm -rf "$BASE_DIR"
|
||||
echo "global-autoresponder data purged"
|
||||
else
|
||||
echo "global-autoresponder uninstalled; external data preserved at $BASE_DIR"
|
||||
fi
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
BASE_DIR="/usr/local/hitme_plugins/global-autoresponders"
|
||||
mkdir -p "$BASE_DIR/config/users" "$BASE_DIR/data/users" "$BASE_DIR/state/replies" "$BASE_DIR/logs"
|
||||
echo "global-autoresponder updated; external configuration preserved"
|
||||
Reference in New Issue
Block a user