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