Files
global-autoresponder/scripts/backend.sh
T
2026-06-02 19:19:00 +02:00

37 lines
935 B
Bash
Executable File

#!/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."