tor.postinst 1.3 KB

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