tor-hardened.sh 769 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. ##############################################
  3. # Tor-Hardened Cleaner & Startup Script #
  4. ##############################################
  5. # Clean left over files
  6. echo "Cleaning any files left over from a previous run..."
  7. rm /opt/torchroot/var/lib/tor/*
  8. # Detect old version and upgrade
  9. Torchroothash=$(sha256sum /opt/torchroot/usr/bin/tor | awk '{print $1}')
  10. Toroutsidehash=$(sha256sum /usr/bin/tor | awk '{print $1}')
  11. if [ "$Torchroothash" != "$Toroutsidehash" ]
  12. then
  13. echo "New version of Tor detected! Updating chroot before running."
  14. rm -rf /opt/torchroot
  15. wait
  16. /usr/bin/sh -c "/opt/tor-hardened-scripts/torchroot.sh"
  17. wait
  18. fi
  19. # Start Tor inside of our chroot
  20. echo "Running Tor..."
  21. chroot --userspec=tor:tor /opt/torchroot /usr/bin/tor -f /etc/tor/torrc