Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

mailserver.sql.j2 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. -- If tables are not dropped, have to truncate before insert or use "insert or replace" (not postgres compatible)
  2. DROP TABLE IF EXISTS "virtual_users";
  3. DROP TABLE IF EXISTS "virtual_aliases";
  4. DROP TABLE IF EXISTS "virtual_domains";
  5. CREATE TABLE IF NOT EXISTS "virtual_domains" (
  6. "id" SERIAL,
  7. "name" TEXT NOT NULL,
  8. PRIMARY KEY ("id")
  9. );
  10. CREATE UNIQUE INDEX name_idx ON virtual_domains (name);
  11. CREATE TABLE IF NOT EXISTS "virtual_users" (
  12. "id" SERIAL,
  13. "username" TEXT NOT NULL,
  14. "domain" TEXT NOT NULL,
  15. "password" TEXT NOT NULL,
  16. "sendonly" boolean DEFAULT FALSE,
  17. PRIMARY KEY ("id")
  18. );
  19. CREATE UNIQUE INDEX email_idx ON virtual_users (username, domain);
  20. CREATE TABLE IF NOT EXISTS "virtual_aliases" (
  21. "id" SERIAL,
  22. "source" TEXT NOT NULL,
  23. "destination" TEXT NOT NULL,
  24. PRIMARY KEY ("id")
  25. );
  26. CREATE INDEX source_idx ON virtual_aliases (source);
  27. {% for virtual_domain in virtual_domains %}
  28. INSERT INTO "virtual_domains" ("name")
  29. VALUES ('{{ virtual_domain.name }}');
  30. {% endfor %}
  31. {% for virtual_user in mail_virtual_users %}
  32. INSERT INTO "virtual_users" ("username", "domain", "password" , "sendonly")
  33. VALUES (
  34. '{{ virtual_user.account }}',
  35. '{{ virtual_user.domain }}',
  36. '{{ virtual_user.password }}',
  37. '{{ virtual_user.sendonly }}'
  38. );
  39. {% endfor %}
  40. {% if mail_virtual_aliases is defined %}
  41. {% for virtual_alias in mail_virtual_aliases %}
  42. INSERT INTO "virtual_aliases" ("source", "destination")
  43. VALUES (
  44. '{{ virtual_alias.source }}',
  45. '{{ virtual_alias.destination }}'
  46. );
  47. {% endfor %}
  48. {% endif %}