make sure that the /etc/monkeysphere/gpg-*.conf are placed during package installation.
[monkeysphere.git] / packaging / freebsd / 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
9
10 # FIXME: is /var/lib/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
19 case $2 in
20 POST-INSTALL)
21         USER=monkeysphere
22         GROUP=${USER}
23         UID=641
24         GID=${UID}
25         SHELL=/usr/local/bin/bash
26
27         if pw group show "${GROUP}" >/dev/null 2>&1; then
28                 echo "You already have a group \"${GROUP}\", so I will use it."
29         else
30                 if pw groupadd ${GROUP} -g ${GID}; then
31                         echo "Added group \"${GROUP}\"."
32                 else
33                         echo "Adding group \"${GROUP}\" failed..."
34                         exit 1
35                 fi
36         fi
37
38         if pw user show "${USER}" >/dev/null 2>&1; then
39             oldshell=`pw user show "${USER}" 2>/dev/null | cut -f10 -d:`
40             if [ x"$oldshell" != x"$SHELL" ]; then
41                 echo "You already have a \"${USER}\" user, but its shell is '$oldshell'."
42                 echo "This package requires that \"${USER}\"'s shell be '$SHELL'."
43                 echo "You should fix this by hand and then re-install the package."
44                 echo "   hint: pw usermod '$USER' -s '$SHELL'"
45                 exit 1
46             fi
47             echo "You already have a user \"${USER}\" with the proper shell, so I will use it."
48         else
49                 if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
50                         -d "$VARLIB" -s /usr/local/bin/bash -c "monkeysphere authentication user,,,"
51                 then
52                         echo "Added user \"${USER}\"."
53                 else
54                         echo "Adding user \"${USER}\" failed..."
55                         exit 1
56                 fi
57         fi
58
59         ## set up the cache directories:
60
61         install -d -o root -g monkeysphere -m 750 "$VARLIB"/gnupg-host
62         cat <<EOF > "$VARLIB"/gnupg-host/gpg.conf
63 list-options show-uid-validity
64 EOF
65
66         install -d -o monkeysphere -g monkeysphere -m 700 "$VARLIB"/gnupg-authentication
67 # install authentication gpg.conf
68         cat <<EOF > "$VARLIB"/gnupg-authentication/gpg.conf
69 list-options show-uid-validity
70 primary-keyring $VARLIB/gnupg-authentication/pubring.gpg
71 keyring $VARLIB/gnupg-host/pubring.gpg
72 EOF
73         chown monkeysphere:monkeysphere "$VARLIB"/gnupg-authentication/gpg.conf
74
75         monkeysphere-server diagnostics
76         ;;
77 esac