summaryrefslogtreecommitdiff
path: root/mail/mailman/pkg-install
blob: 16f6ff16a7007deff3320972417972369c654055 (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
#! /bin/sh

make_account() {
  local u uid g gid gcos home shell

  u=$1
  uid=$2
  g=$3
  gid=$4
  gcos=$5
  home=$6
  shell=$7

  if pw group show "${g}" >/dev/null 2>&1; then
    echo "You already have a group \"${g}\", so I will use it."
  else
    echo -n "Adding group \"${g}\" (${gid})... "
    if which -s pw; then
      pw groupadd ${g} -g ${gid} || exit
      echo "done."
    else
      exit 1
    fi
  fi

  if pw user show "${u}" >/dev/null 2>&1; then
    echo "You already have a user \"${u}\", so I will use it."
  else
    echo -n "Adding user \"${u}\" (${uid})... "
    if which -s pw; then
      pw useradd ${u} -u ${uid} -g ${g} -h - -d ${home} \
        -s ${shell} -c "${gcos}" || exit
      echo "done."
    else
      exit 1
    fi
  fi

  if [ x"$home" != x ]; then
    if [ ! -d "${home}" ]; then
      echo -n "Creating ${u}'s home directory (${home})... "
      (umask 002 && mkdir -p ${home}) || exit
      chown -R ${u}:${g} ${home} || exit
      chmod g+s ${home} || exit
      echo "done."
    fi
  fi
}

create_crontab() {
  local u file

  u=$1
  file=$2

  echo -n "Creating crontab(5) file for Mailman user... "
  crontab -u ${u} ${file} || exit
  echo "done."

}

case $2 in

PRE-INSTALL)
  if which -s pw && which -s lockf; then
    :
  else
    cat <<EOF

This system looks like a pre-2.2 version of FreeBSD. I see that it
is missing the "lockf" and/or "pw" utilities. I need these utilities.
Please get them and install them, and try again. You can get the
sources from:

 ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.bin/lockf.tar.gz
 ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz

EOF
    exit 1
  fi

  make_account %%USER%% %%UID%% %%GROUP%% %%GID%% \
    "Mailman User" "%%MAILMANDIR%%" "/sbin/nologin"
  ;;

POST-INSTALL)
  create_crontab %%USER%% "%%MAILMANDIR%%/cron/crontab.in"
  ;;
esac