postinst 1.3 KB

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