You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
3.6 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2014 OpenWrt.org
  3. START=50
  4. STOP=50
  5. upgrade() {
  6. config_directory="$IPKG_INSTROOT"/etc/postfix
  7. if [ -f "$config_directory"/opkg_postinst ]; then
  8. rm -f "$config_directory"/opkg_postinst
  9. group_exists postfix || group_add postfix 87
  10. user_exists postfix || user_add postfix 87
  11. group_exists postdrop || group_add postdrop 88
  12. echo "myhostname = $(uci get system.@system[0].hostname)" >> "$config_directory"/main.cf.default
  13. echo "mydomain = $(uci get system.@system[0].hostname|sed -e "s/[^\.]*\.\(.*\)/\1/")" >> "$config_directory"/main.cf.default
  14. ifconfig | grep "inet addr" | sed -e "s/.*inet addr:\([0-9.]*\).*Mask:/\1 /" | while read IP NETMASK; do eval "$(ipcalc.sh $IP $NETMASK)"; echo "$NETWORK/$PREFIX"; done | xargs echo "mynetworks =" >> "$config_directory"/main.cf.default
  15. grep -qc "^sendmail_path" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^sendmail_path =" "$config_directory"/main.cf.default)"
  16. grep -qc "^newaliases_path" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^newaliases_path =" "$config_directory"/main.cf.default)"
  17. grep -qc "^mailq_path" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^mailq_path =" "$config_directory"/main.cf.default)"
  18. grep -qc "^html_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^html_directory =" "$config_directory"/main.cf.default)"
  19. grep -qc "^manpage_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^manpage_directory =" "$config_directory"/main.cf.default)"
  20. grep -qc "^sample_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^sample_directory =" "$config_directory"/main.cf.default)"
  21. grep -qc "^readme_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^readme_directory =" "$config_directory"/main.cf.default)"
  22. grep -qc "^command_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^command_directory =" "$config_directory"/main.cf.default)"
  23. grep -qc "^daemon_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^daemon_directory =" "$config_directory"/main.cf.default)"
  24. grep -qc "^data_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^data_directory =" "$config_directory"/main.cf.default)"
  25. grep -qc "^queue_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^queue_directory =" "$config_directory"/main.cf.default)"
  26. grep -qc "^config_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^config_directory =" "$config_directory"/main.cf.default)"
  27. grep -qc "^mail_spool_directory" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^mail_spool_directory =" "$config_directory"/main.cf.default)"
  28. grep -qc "^mail_owner" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^mail_owner =" "$config_directory"/main.cf.default)"
  29. grep -qc "^setgid_group" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^setgid_group =" "$config_directory"/main.cf.default)"
  30. grep -qc "^myhostname" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^myhostname =" "$config_directory"/main.cf.default)"
  31. grep -qc "^mydomain" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^mydomain =" "$config_directory"/main.cf.default)"
  32. grep -qc "^mynetworks" "$config_directory"/main.cf >/dev/null || postconf -e "$(grep "^mynetworks =" "$config_directory"/main.cf.default)"
  33. postfix set-permissions
  34. postfix post-install upgrade-source
  35. postfix upgrade-configuration
  36. newaliases
  37. fi
  38. }
  39. start() {
  40. upgrade
  41. postfix start
  42. }
  43. stop() {
  44. postfix stop
  45. }
  46. reload() {
  47. upgrade
  48. postfix reload
  49. }