b832190c37708eb96e712bc063b4fe2fb87e321a
[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
26         if pw group show "${GROUP}" 2>/dev/null; then
27                 echo "You already have a group \"${GROUP}\", so I will use it."
28         else
29                 if pw groupadd ${GROUP} -g ${GID}; then
30                         echo "Added group \"${GROUP}\"."
31                 else
32                         echo "Adding group \"${GROUP}\" failed..."
33                         exit 1
34                 fi
35         fi
36
37         if pw user show "${USER}" 2>/dev/null; then
38                 echo "You already have a user \"${USER}\", so I will use it."
39         else
40                 if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
41                         -d "$VARLIB" -s /bin/sh -c "monkeysphere authentication user,,,"
42                 then
43                         echo "Added user \"${USER}\"."
44                 else
45                         echo "Adding user \"${USER}\" failed..."
46                         exit 1
47                 fi
48         fi
49
50         ## set up the cache directories:
51
52         install -d -o root -g monkeysphere -m 750 "$VARLIB"/gnupg-host
53         cat <<EOF > "$VARLIB"/gnupg-host/gpg.conf
54 list-options show-uid-validity
55 EOF
56
57         install -d -o monkeysphere -g monkeysphere -m 700 "$VARLIB"/gnupg-authentication
58 # install authentication gpg.conf
59         cat <<EOF > "$VARLIB"/gnupg-authentication/gpg.conf
60 list-options show-uid-validity
61 primary-keyring $VARLIB/gnupg-authentication/pubring.gpg
62 keyring $VARLIB/gnupg-host/pubring.gpg
63 EOF
64         chown monkeysphere:monkeysphere "$VARLIB"/gnupg-authentication/gpg.conf
65
66         ;;
67 esac