summaryrefslogtreecommitdiff
path: root/mail/mailman/files/pkg-install.in
blob: 90d4f05843186bd87012e0be775c20a16b24561b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#! /bin/sh
#
# $FreeBSD$

PATH=/bin:/usr/bin:/usr/sbin

check_rcfile_fix_perms() {
    (
    . /etc/rc.subr

    name="mailman"
    rcvar=mailman_enable

    load_rc_config $name

    : ${mailman_fix_perms="YES"}

    checkyesno mailman_fix_perms
    )
}

set -e
case "$2" in

POST-INSTALL)
  echo "---> Starting post-install script"
  LC_ALL=C
  export LC_ALL

  MYTMP="$(mktemp -d "${TMPDIR-/tmp}/mminstall.XXXXXXXXXX")"
  trap "rm -rf \"$MYTMP\"" EXIT

  # fix up permissions - this is under investigation; pkg or libarchive
  # goof up the group writable and/or setgid bits
  /usr/bin/find "%%MAILMANDIR%%/qfiles" -maxdepth 1 -type d -exec \
    /bin/chmod u+rwx,g+rwsx,o-w "{}" +
  /bin/chmod 02775 "%%MAILMANDIR%%" \
    "%%MAILMANDIR%%/Mailman" \
    "%%MAILMANDIR%%/bin" \
    "%%MAILMANDIR%%/cgi-bin" \
    "%%MAILMANDIR%%/icons" \
    "%%MAILMANDIR%%/mail" \
    "%%MAILMANDIR%%/scripts" \
    "%%MAILMANDIR%%/tests" \
    "%%MAILMANDIR%%/pythonlib" \
    "%%MAILMANDIR%%/spam" \
    "%%MAILMANDIR%%/locks" \
    "%%MAILMANDIR%%/Mailman/Archiver" \
    "%%MAILMANDIR%%/Mailman/Bouncers" \
    "%%MAILMANDIR%%/Mailman/Cgi" \
    "%%MAILMANDIR%%/Mailman/Commands" \
    "%%MAILMANDIR%%/Mailman/Gui" \
    "%%MAILMANDIR%%/Mailman/Handlers" \
    "%%MAILMANDIR%%/Mailman/Logging" \
    "%%MAILMANDIR%%/Mailman/MTA" \
    "%%MAILMANDIR%%/Mailman/Queue" \
    "%%MAILMANDIR%%/tests/bounces" \
    "%%MAILMANDIR%%/tests/msgs" \
    "%%MAILMANDIR%%/cron" \
    "%%MAILMANDIR%%/data" \
    "%%MAILMANDIR%%/lists" \
    "%%MAILMANDIR%%/archives" \
    "%%MAILMANDIR%%/archives/public"
  # this can be 2770 or 2771 but should not be stomped over
  test -d "%%MAILMANDIR%%/archives/private" \
  || /usr/bin/install -m 02771 -g "%%GROUP%%" \
      -d "%%MAILMANDIR%%/archives/private"

  /bin/chmod u+rwx,g+srwx      "%%MAILMANDIR%%/archives/private"
  /bin/chmod u+rwx,g+srwx,o+rx "%%MAILMANDIR%%/logs"

  /usr/bin/find "%%MAILMANDIR%%/messages" "%%MAILMANDIR%%/templates" -type d \
    -exec chmod 02775 '{}' +

  echo "---> Running update"

  LC_ALL=C "%%MAILMANDIR%%/bin/update"

  echo "---> Checking crontab(5) file for user \"%%USER%%\""

  if [ -e /var/cron/allow ]; then
      grep -q "^%%USER%%\$" /var/cron/allow || \
      printf '%s\n' "%%USER%%" >> /var/cron/allow
  fi

  if /usr/bin/crontab -u "%%USER%%" -l >"$MYTMP/crontab" 2>&1 ; then
      if test -s "$MYTMP/crontab"; then
          echo "---> \"%%USER%%\" already has a crontab.  Not overwriting it"
          echo "---> Please merge any changes from the standard crontab file"
          echo "--->     %%MAILMANDIR%%/cron/crontab.in"
      else
          echo "---> Installing crontab(5) file for user \"%%USER%%\""
          /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/crontab.in"
      fi
  else
      echo "---> Creating crontab(5) file for user \"%%USER%%\""
      /usr/bin/crontab -u "%%USER%%" "%%MAILMANDIR%%/cron/crontab.in"
  fi
  rm -f "$MYTMP/crontab"

  if check_rcfile_fix_perms ; then
    echo "---> Checking (and fixing) file and directory permissions"
    output="$("%%MAILMANDIR%%/bin/check_perms" -f 2>&1)" || :
    printf '%s\n' "$output" | egrep -v '^Re-run' || :
  else
    echo "---> rcfile sets mailman_fix_perms to no, skipping check_perms"
  fi

  echo "---> Running assorted other checks"
  if egrep -q "^[ \t]*MTA.*=.*Postfix" "%%MAILMANDIR%%/Mailman/mm_cfg.py" ; then
      # run Postfix-specific checks
      POSTCONF=$(PATH="${PKG_PREFIX}/sbin:/usr/sbin:/sbin:$PATH" which postconf)
      if [ "x`${POSTCONF} -h myhostname`" != "xlocalhost" ] \
	  && ! egrep -q "^[ \t]*SMTPHOST.*=.*`${POSTCONF} -h myhostname`" \
	    "%%MAILMANDIR%%/Mailman/mm_cfg.py"
      then
	  echo ""
	  echo "Your Postfix hostname is non-default."
	  echo -n "You must add \"SMTPHOST = '`${POSTCONF} -h myhostname`'"
	  echo "\" to the bottom of mm_cfg.py (without quotes)."
	  echo ""
      fi
  fi
  ;;
esac