postinst 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. # postinst script for emqx
  3. #
  4. # see: dh_installdeb(1)
  5. set -e
  6. # install startup script
  7. update-rc.d emqx defaults >/dev/null
  8. # create group
  9. if ! getent group emqx >/dev/null; then
  10. addgroup --system emqx
  11. fi
  12. # create user
  13. if ! getent passwd emqx >/dev/null; then
  14. adduser --ingroup emqx \
  15. --home /var/lib/emqx \
  16. --disabled-password \
  17. --system --shell /bin/bash --no-create-home \
  18. --gecos "emqx user" emqx
  19. fi
  20. for i in lib run log; do
  21. chown -R emqx:emqx /var/$i/emqx
  22. done
  23. chown -R emqx:emqx /usr/lib/emqx
  24. chown -R emqx:emqx /etc/emqx
  25. chmod 0755 /var/run/emqx /etc/emqx
  26. chmod 0644 /etc/emqx/*
  27. chmod -R +X /etc/emqx
  28. chmod -R 0755 /usr/lib/emqx/bin
  29. [ -f /usr/bin/emqx ] && rm /usr/bin/emqx
  30. [ -f /usr/bin/emqx_ctl ] && rm /usr/bin/emqx_ctl
  31. ln -s /usr/lib/emqx/bin/emqx /usr/bin/emqx
  32. ln -s /usr/lib/emqx/bin/emqx_ctl /usr/bin/emqx_ctl
  33. case "$1" in
  34. configure)
  35. ;;
  36. abort-upgrade|abort-remove|abort-deconfigure)
  37. ;;
  38. *)
  39. echo "postinst called with unknown argument \`$1'" >&2
  40. exit 1
  41. ;;
  42. esac
  43. # dh_installdeb will replace this with shell code automatically
  44. # generated by other debhelper scripts.
  45. #DEBHELPER#
  46. exit 0