gen-onions.sh 784 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. hosts_dir="$1"
  3. for i in {0..10}; do
  4. for ClientDir in "$hosts_dir"/*client*/; do
  5. if [ -f $ClientDir/$i.torrc ] ; then
  6. DataDirectory=$ClientDir/tor-$i
  7. chmod 700 $ClientDir/*.tor
  8. chmod 700 $DataDirectory
  9. tor --hush -f $ClientDir/$i.torrc --ControlPort 0 --DisableNetwork 1 --DataDirectory $DataDirectory &
  10. fi
  11. done
  12. echo "terminating set $i"
  13. pkill -P $$
  14. wait
  15. done
  16. echo "replacing hosts file"
  17. for ClientDir in "$hosts_dir"/*client*/; do
  18. for UserDir in $ClientDir/user*.tor; do
  19. if [ -d "$UserDir" ] ; then
  20. user=$(basename "$UserDir" .tor)
  21. onion=$(cat "$UserDir"/hostname)
  22. sed -i "s/^$user:/$onion:/g" "$hosts_dir/hosts"
  23. fi
  24. done
  25. done