aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mailman/pkg-deinstall
blob: 2a9ce66c683d9e4e86c9cd86e974c554d8245d70 (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
#! /bin/sh

delete_account() {
  local u g home

  u=$1
  g=$2
  echo -n "Removing group \"${g}\"... "
  pw groupdel -n ${g}
  echo "done."
  echo -n "Removing user \"${u}\"... "
  eval home=~${u}
  echo 'y' | pw userdel -n ${u}
  echo "done."
}

zero_crontab() {
  local u

  u=$1
  
  echo -n "Zeroing Mailman user's crontab(5) file... "
  crontab -u ${u} /dev/null || exit
  echo "done."
}

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

case $2 in

DEINSTALL)
  zero_crontab %%USER%%
  if ps -axwww | grep -q qrunner; then
    echo "Killing all running qrunning processes."
    killall qrunner
    sleep 2
  fi
  ;;

POST-DEINSTALL)
  if [ -d %%MAILMANDIR%% ]; then
    echo "%%MAILMANDIR%% is not empty - this installation may have active lists"
    echo "- The \"%%USER%%\" user and \"%%GROUP%%\" group were therefore not deleted."
    echo "- You may delete them with \"pw userdel %%USER%%\"."
  else
    delete_account %%USER%% %%GROUP%%
  fi
  ;;
esac