summaryrefslogtreecommitdiff
path: root/packaging/freebsd/pkg-install
blob: 731667c262afe2ba726fcbb3dc6119750fcc34f7 (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. 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 cache directories, and link them to the config files:
  51. install -d -o root -g monkeysphere -m 750 "$VARLIB"/gnupg-host
  52. ln -sf "$ETCDIR"/gnupg-host.conf "$VARLIB"/gnupg-host/gpg.conf
  53. install -d -o monkeysphere -g monkeysphere -m 700 "$VARLIB"/gnupg-authentication
  54. ln -sf "$ETCDIR"/gnupg-authentication.conf "$VARLIB"/gnupg-authentication/gpg.conf
  55. install -d "$VARLIB"/tmp "$VARLIB"/authorized_keys
  56. chown monkeysphere:monkeysphere "$VARLIB"/gnupg-authentication/gpg.conf
  57. monkeysphere-server diagnostics
  58. ;;
  59. esac