summaryrefslogtreecommitdiff
path: root/packaging/freebsd/pkg-install
blob: 5e520cdfd20ad8a19f5b8f7c8e0dd1df39b0fb80 (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}" >/dev/null 2>&1; 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 pw user show "${USER}" >/dev/null 2>&1; then
  30. oldshell=`pw user show "${USER}" 2>/dev/null | cut -f10 -d:`
  31. if [ x"$oldshell" != x"$SHELL" ]; then
  32. echo "You already have a \"${USER}\" user, but its shell is '$oldshell'."
  33. echo "This package requires that \"${USER}\"'s shell be '$SHELL'."
  34. echo "You should fix this by hand and then re-install the package."
  35. echo " hint: pw usermod '$USER' -s '$SHELL'"
  36. exit 1
  37. fi
  38. echo "You already have a user \"${USER}\" with the proper shell, so I will use it."
  39. else
  40. if pw useradd ${USER} -u ${UID} -g ${GROUP} -h - \
  41. -d "$VARLIB" -s /usr/local/bin/bash -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. ## set up the cache directories:
  50. install -d -o root -g monkeysphere -m 750 "$VARLIB"/gnupg-host
  51. cat <<EOF > "$VARLIB"/gnupg-host/gpg.conf
  52. list-options show-uid-validity
  53. EOF
  54. install -d -o monkeysphere -g monkeysphere -m 700 "$VARLIB"/gnupg-authentication
  55. # install authentication gpg.conf
  56. cat <<EOF > "$VARLIB"/gnupg-authentication/gpg.conf
  57. list-options show-uid-validity
  58. primary-keyring $VARLIB/gnupg-authentication/pubring.gpg
  59. keyring $VARLIB/gnupg-host/pubring.gpg
  60. EOF
  61. chown monkeysphere:monkeysphere "$VARLIB"/gnupg-authentication/gpg.conf
  62. monkeysphere-server diagnostics
  63. ;;
  64. esac