···58585959 # Check frequently at first, then slow down - longer timeout per attempt
6060 for i in {1..120}; do
6161- if grep -q "Bootstrapped 100%" "$TOR_DIR/tor.log" 2>/dev/null; then
6161+ # Check if log file exists and contains the success message
6262+ if [ -f "$TOR_DIR/tor.log" ] && grep -q "Bootstrapped 100%" "$TOR_DIR/tor.log" 2>/dev/null; then
6263 # Success - exit both loops
6364 break 2
6565+ fi
6666+ # If log file doesn't exist after 2 seconds, tor likely failed to start
6767+ if [ "$i" -eq 20 ] && [ ! -f "$TOR_DIR/tor.log" ]; then
6868+ # Log file wasn't created after 2 seconds - tor likely failed completely
6969+ # Exit with failure immediately rather than retrying
7070+ break
6471 fi
6572 # Check every 0.1s for first 2 seconds, then every 0.5s
6673 if [ "$i" -le 20 ]; then
···99106100107# Execute the command
101108export TORSOCKS_TOR_PORT=$SOCKS_PORT
109109+export TOR_CONTROL_PORT=$CONTROL_PORT
102110exec torsocks "$@"