summaryrefslogtreecommitdiff
path: root/packaging/freebsd/security/monkeysphere/pkg-install
blob: 435c69ad12c0c42ea63875be84686a7d7605660f (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,2009
  7. # FIXME: is /var/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. ETCDIR="/usr/local/etc/monkeysphere"
  13. case $2 in
  14. POST-INSTALL)
  15. USER=monkeysphere
  16. GROUP=${USER}
  17. UID=641
  18. GID=${UID}
  19. SHELL=/usr/local/bin/bash
  20. if pw group show "${GROUP}" >/dev/null 2>&1; then
  21. echo "You already have a group \"${GROUP}\", so I will use it."
  22. else
  23. if pw groupadd ${GROUP} -g ${GID}; then
  24. echo "Added group \"${GROUP}\"."
  25. else
  26. echo "Adding group \"${GROUP}\" failed..."
  27. exit 1
  28. fi
  29. fi
  30. if pw user show "${USER}" >/dev/null 2>&1; then
  31. oldshell=`pw user show "${USER}" 2>/dev/null | cut -f10 -d:`
  32. if [ x"$oldshell" != x"$SHELL" ]; then
  33. echo "You already have a \"${USER}\" user, but its shell is '$oldshell'."
  34. echo "This package requires that \"${USER}\"'s shell be '$SHELL'."
  35. echo "You should fix this by hand and then re-install the package."
  36. echo " hint: pw usermod '$USER' -s '$SHELL'"
  37. exit 1
  38. fi
  39. echo "You already have a user \"${USER}\" with the proper shell, so I will use it."
  40. else
  41. if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
  42. -d "$VARLIB" -s /usr/local/bin/bash -c "monkeysphere authentication user,,,"
  43. then
  44. echo "Added user \"${USER}\"."
  45. else
  46. echo "Adding user \"${USER}\" failed..."
  47. exit 1
  48. fi
  49. fi
  50. ## set up the monkeysphere authentication cache directory:
  51. monkeysphere-authentication setup
  52. ;;
  53. esac