PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/prototypes/v0/sandbox/dht_test/setup.ksh

https://code.google.com/
Korn Shell | 55 lines | 40 code | 9 blank | 6 comment | 5 complexity | 75889f671c8422c597ca1abb32bb6fa7 MD5 | raw file
  1. #!/usr/bin/ksh
  2. set -eau
  3. ROOT_DIR=./world
  4. DHT_EXE=/cygdrive/c/jlouis/sandbox/test/test_dht/test_dht.exe
  5. create_agent() {
  6. typeset agent_nbr="${1}"
  7. echo "creating agent $1"
  8. typeset agent_dir="${ROOT_DIR}/agent_${1}"
  9. mkdir -p "${agent_dir}"
  10. typeset agent_ping=''
  11. if [ "${agent_nbr}" != 0 ]; then
  12. agent_ping='agent_2=localhost:22220'
  13. else
  14. agent_ping='first_agent=yes'
  15. fi
  16. cat > "${agent_dir}/dht.properties" <<EOF
  17. # properties file for DHT
  18. # file specify a port for the DHT listener
  19. # and the list of other agent it can contact when initializing
  20. is_listening=yes
  21. tcp_listener_port=2222${agent_nbr}
  22. udp_listener_port=3333${agent_nbr}
  23. default.key_length=8
  24. agent_1=localhost:11111
  25. ${agent_ping}
  26. EOF
  27. ln -s "${DHT_EXE}" "${agent_dir}/agent_${agent_nbr}.exe"
  28. }
  29. set +e
  30. (
  31. set -e
  32. # create the file system with N agent
  33. integer N=5
  34. integer i=0
  35. rm -rf "${ROOT_DIR}"
  36. while ((i<N))
  37. do
  38. echo "i=$i"
  39. create_agent $i
  40. ((i=i+1))
  41. done
  42. # start the first agent
  43. cd "${ROOT_DIR}/agent_0"
  44. ./agent_0
  45. )
  46. if [ $? != 0 ]; then echo "Error..."; fi