fix up notes about how to prepare a release
[monkeysphere.git] / packaging / freebsd / security / monkeysphere / pkg-install
1 #!/bin/sh
2
3 # an installation script for monkeysphere (borrowing liberally from
4 # postgresql and mysql pkg-install scripts, and from monkeysphere's
5 # debian/monkeysphere.postinst)
6
7 # Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
8 # Copyright 2008,2009
9
10 # FIXME: is /var/monkeysphere the right place for this stuff on
11 # FreeBSD?
12
13 # PostgreSQL puts its data in /usr/local/pgsql/data
14
15 # MySQL puts its data in /var/db/mysql
16
17 VARLIB="/var/monkeysphere"
18 ETCDIR="/usr/local/etc/monkeysphere"
19
20 case $2 in
21 POST-INSTALL)
22         USER=monkeysphere
23         GROUP=${USER}
24         UID=641
25         GID=${UID}
26         SHELL=/usr/local/bin/bash
27
28         if pw group show "${GROUP}" >/dev/null 2>&1; then
29                 echo "You already have a group \"${GROUP}\", so I will use it."
30         else
31                 if pw groupadd ${GROUP} -g ${GID}; then
32                         echo "Added group \"${GROUP}\"."
33                 else
34                         echo "Adding group \"${GROUP}\" failed..."
35                         exit 1
36                 fi
37         fi
38
39         if pw user show "${USER}" >/dev/null 2>&1; then
40             oldshell=`pw user show "${USER}" 2>/dev/null | cut -f10 -d:`
41             if [ x"$oldshell" != x"$SHELL" ]; then
42                 echo "You already have a \"${USER}\" user, but its shell is '$oldshell'."
43                 echo "This package requires that \"${USER}\"'s shell be '$SHELL'."
44                 echo "You should fix this by hand and then re-install the package."
45                 echo "   hint: pw usermod '$USER' -s '$SHELL'"
46                 exit 1
47             fi
48             echo "You already have a user \"${USER}\" with the proper shell, so I will use it."
49         else
50                 if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
51                         -d "$VARLIB" -s /usr/local/bin/bash -c "monkeysphere authentication user,,,"
52                 then
53                         echo "Added user \"${USER}\"."
54                 else
55                         echo "Adding user \"${USER}\" failed..."
56                         exit 1
57                 fi
58         fi
59
60         ## set up the monkeysphere authentication cache directory:
61
62         monkeysphere-authentication setup
63         ;;
64 esac