tor.postinst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. echo "debian-tor homedir check: ok"
  10. else
  11. echo "ERROR: debian-tor account has an invalid home directory!"
  12. echo "Please check /usr/share/doc/tor/README.Debian on how to"
  13. echo "correct this problem"
  14. exit 1
  15. fi
  16. else
  17. # what this might mean?? oh creating a system l^Huser!
  18. adduser --quiet \
  19. --system \
  20. --disabled-password \
  21. --home /var/lib/tor \
  22. --no-create-home \
  23. --shell /bin/bash \
  24. --group \
  25. debian-tor
  26. fi
  27. # ch{owning,moding} things around
  28. # We will do nothing across upgrades.
  29. if [ "$2" = "" ]; then
  30. for i in lib log run; do
  31. chown -R debian-tor:debian-tor /var/$i/tor
  32. chmod -R 700 /var/$i/tor
  33. find /var/$i/tor -type f -exec chmod 600 '{}' ';'
  34. done
  35. chgrp -R adm /var/log/tor
  36. chmod -R g+rX /var/log/tor
  37. chmod g+s /var/log/tor
  38. else
  39. # fix permissions of logs after 0.0.8+0.0.9pre5-1
  40. if [ "$1" = "configure" ]; then
  41. if dpkg --compare-versions "$2" le "0.0.8+0.0.9pre5-1" ; then
  42. chgrp -R adm /var/log/tor
  43. chmod -R g+rX /var/log/tor
  44. chmod g+s /var/log/tor
  45. fi
  46. fi
  47. fi
  48. #DEBHELPER#
  49. exit 0