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