tor.postinst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh -e
  2. # checking debian-tor account
  3. uid=`getent passwd debian-tor | cut -d ":" -f 3`
  4. home=`getent passwd debian-tor | cut -d ":" -f 6`
  5. # if there is the uid the account is there and we can do
  6. # the sanit(ar)y checks otherwise we can safely create it.
  7. if [ "$uid" ]; then
  8. if [ "$home" = "/var/lib/tor" ]; then
  9. :
  10. #echo "debian-tor homedir check: ok"
  11. else
  12. echo "ERROR: debian-tor account has an unexpected home directory!"
  13. echo "It should be '/var/lib/tor', but it is '$home'."
  14. echo "Removing the debian-tor user might fix this, but the question"
  15. echo "remains how you got into this mess to begin with."
  16. exit 1
  17. fi
  18. else
  19. adduser --quiet \
  20. --system \
  21. --disabled-password \
  22. --home /var/lib/tor \
  23. --no-create-home \
  24. --shell /bin/bash \
  25. --group \
  26. debian-tor
  27. fi
  28. # ch{owning,moding} things around
  29. # We will do nothing across upgrades.
  30. if [ "$2" = "" ]; then
  31. for i in lib log run; do
  32. chown -R debian-tor:debian-tor /var/$i/tor
  33. chmod -R 700 /var/$i/tor
  34. find /var/$i/tor -type f -exec chmod 600 '{}' ';'
  35. done
  36. chgrp -R adm /var/log/tor
  37. chmod -R g+rX /var/log/tor
  38. chmod g+s /var/log/tor
  39. else
  40. # fix permissions of logs after 0.0.8+0.0.9pre5-1
  41. if [ "$1" = "configure" ]; then
  42. if dpkg --compare-versions "$2" le "0.0.8+0.0.9pre5-1" ; then
  43. chgrp -R adm /var/log/tor
  44. chmod -R g+rX /var/log/tor
  45. chmod g+s /var/log/tor
  46. fi
  47. fi
  48. fi
  49. #DEBHELPER#
  50. exit 0