n2n.bash 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # 注意:不同shell对语法的支持有细微差别,第一行并不能随便写。
  3. cd /app
  4. # 自动更新当前架构可用版本
  5. bash auto_update.bash
  6. # 首次启动时配置文件不存在,自动生成
  7. EDGE_FILE='/app/config/edge.conf'
  8. SUPER_FILE='/app/config/supernode.conf'
  9. if [ ! -f $SUPER_FILE ]; then
  10. echo "#####Generating supernode configuration file#####"
  11. cat>"${SUPER_FILE}"<<EOF
  12. # The configuration file is similar to the command line, with one option per line. An equal
  13. # sign '=' should be used between key and value. Example: -p=7777
  14. # This file contains a basic configuration example, please refer to the help (-h) for the full
  15. # list of available options.
  16. #
  17. # -p
  18. # Sets the UDP listening port.
  19. #
  20. -p=7777
  21. #
  22. # -c
  23. # Optionally specifies the allowed communities as listed in community.list file.
  24. #
  25. # -c=community.list
  26. -a=172.30.0.0-172.30.0.0/16
  27. EOF
  28. else
  29. echo "##### supernode Configuration file already exists#####"
  30. fi
  31. if [ ! -f $EDGE_FILE ]; then
  32. echo "#####Generating edge configuration file#####"
  33. cat>"${EDGE_FILE}"<<EOF
  34. -c=mynetwork
  35. -k=mysecretpass
  36. -a=172.30.0.111/16
  37. -l=supernode.ntop.org:7777
  38. -A5
  39. -S2
  40. #-H
  41. EOF
  42. else
  43. echo "##### edge Configuration file already exists#####"
  44. fi
  45. if [[ ${START_TYPE} == "supernode" ]]; then
  46. /app/bin/supernode $SUPER_FILE -f
  47. else
  48. /app/bin/edge $EDGE_FILE -f
  49. fi
  50. exec "$@"