You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
5.9 KiB

  1. #!/bin/sh
  2. #
  3. # convert uci configuration into daemon specific format
  4. #
  5. UCI=/sbin/uci
  6. create_file() {
  7. echo "# -- DO NOT EDIT THIS FILE --" > $1
  8. echo "# automatic generated configuration file for IBR-DTN daemon" >> $1
  9. echo "#" >> $1
  10. }
  11. add_param() {
  12. VALUE=`$UCI -q get $2`
  13. if [ $? == 0 ]; then
  14. echo "$3 = $VALUE" >> $1
  15. fi
  16. }
  17. getconfig() {
  18. $UCI -q get ibrdtn.$1
  19. return $?
  20. }
  21. if [ "$1" == "--safe-mode" ]; then
  22. SAFEMODE=yes
  23. CONFFILE=$2
  24. else
  25. SAFEMODE=no
  26. CONFFILE=$1
  27. fi
  28. # create the file and write some header info
  29. create_file $CONFFILE
  30. add_param $CONFFILE "ibrdtn.main.uri" "local_uri"
  31. add_param $CONFFILE "ibrdtn.main.routing" "routing"
  32. add_param $CONFFILE "ibrdtn.main.fragmentation" "fragmentation"
  33. if [ "$SAFEMODE" == "yes" ]; then
  34. if [ -n "`getconfig safemode.forwarding`" ]; then
  35. add_param $CONFFILE "ibrdtn.safemode.forwarding" "routing_forwarding"
  36. else
  37. add_param $CONFFILE "ibrdtn.main.forwarding" "routing_forwarding"
  38. fi
  39. if [ -n "`getconfig safemode.maxblock`" ]; then
  40. add_param $CONFFILE "ibrdtn.safemode.maxblock" "limit_blocksize"
  41. else
  42. add_param $CONFFILE "ibrdtn.main.blocksize" "limit_blocksize"
  43. fi
  44. if [ -n "`getconfig safemode.storage`" ]; then
  45. add_param $CONFFILE "ibrdtn.safemode.storage" "limit_storage"
  46. else
  47. add_param $CONFFILE "ibrdtn.storage.limit" "limit_storage"
  48. fi
  49. else
  50. add_param $CONFFILE "ibrdtn.main.forwarding" "routing_forwarding"
  51. add_param $CONFFILE "ibrdtn.main.blocksize" "limit_blocksize"
  52. add_param $CONFFILE "ibrdtn.storage.limit" "limit_storage"
  53. add_param $CONFFILE "ibrdtn.storage.blobs" "blob_path"
  54. add_param $CONFFILE "ibrdtn.storage.bundles" "storage_path"
  55. add_param $CONFFILE "ibrdtn.storage.engine" "storage"
  56. fi
  57. add_param $CONFFILE "ibrdtn.main.max_predated_timestamp" "limit_predated_timestamp"
  58. add_param $CONFFILE "ibrdtn.main.limit_lifetime" "limit_lifetime"
  59. add_param $CONFFILE "ibrdtn.main.foreign_blocksize" "limit_foreign_blocksize"
  60. add_param $CONFFILE "ibrdtn.discovery.address" "discovery_address"
  61. add_param $CONFFILE "ibrdtn.discovery.timeout" "discovery_timeout"
  62. add_param $CONFFILE "ibrdtn.discovery.version" "discovery_version"
  63. add_param $CONFFILE "ibrdtn.discovery.crosslayer" "discovery_crosslayer"
  64. add_param $CONFFILE "ibrdtn.tcptuning.idle_timeout" "tcp_idle_timeout"
  65. add_param $CONFFILE "ibrdtn.tcptuning.nodelay" "tcp_nodelay"
  66. add_param $CONFFILE "ibrdtn.tcptuning.chunksize" "tcp_chunksize"
  67. add_param $CONFFILE "ibrdtn.security.level" "security_level"
  68. add_param $CONFFILE "ibrdtn.security.bab_key" "security_bab_default_key"
  69. add_param $CONFFILE "ibrdtn.security.key_path" "security_path"
  70. add_param $CONFFILE "ibrdtn.security.generate_dh" "generate_dh_params"
  71. add_param $CONFFILE "ibrdtn.tls.certificate" "security_certificate"
  72. add_param $CONFFILE "ibrdtn.tls.key" "security_key"
  73. add_param $CONFFILE "ibrdtn.tls.trustedpath" "security_trusted_ca_path"
  74. add_param $CONFFILE "ibrdtn.tls.required" "security_tls_required"
  75. add_param $CONFFILE "ibrdtn.tls.noencryption" "security_tls_disable_encryption"
  76. add_param $CONFFILE "ibrdtn.tls.fallback_badclock" "security_tls_fallback_badclock"
  77. add_param $CONFFILE "ibrdtn.timesync.reference" "time_reference"
  78. add_param $CONFFILE "ibrdtn.timesync.synchronize" "time_synchronize"
  79. add_param $CONFFILE "ibrdtn.timesync.discovery_announcement" "time_discovery_announcements"
  80. add_param $CONFFILE "ibrdtn.timesync.sigma" "time_sigma"
  81. add_param $CONFFILE "ibrdtn.timesync.psi" "time_psi"
  82. add_param $CONFFILE "ibrdtn.timesync.sync_level" "time_sync_level"
  83. add_param $CONFFILE "ibrdtn.timesync.time_set_clock" "time_set_clock"
  84. add_param $CONFFILE "ibrdtn.dht.enabled" "dht_enabled"
  85. add_param $CONFFILE "ibrdtn.dht.port" "dht_port"
  86. add_param $CONFFILE "ibrdtn.dht.id" "dht_id"
  87. add_param $CONFFILE "ibrdtn.dht.bootstrap" "dht_bootstrapping"
  88. add_param $CONFFILE "ibrdtn.dht.nodesfile" "dht_nodes_file"
  89. add_param $CONFFILE "ibrdtn.dht.enable_ipv4" "dht_enable_ipv4"
  90. add_param $CONFFILE "ibrdtn.dht.enable_ipv6" "dht_enable_ipv6"
  91. add_param $CONFFILE "ibrdtn.dht.bind_ipv4" "dht_bind_ipv4"
  92. add_param $CONFFILE "ibrdtn.dht.bind_ipv6" "dht_bind_ipv6"
  93. add_param $CONFFILE "ibrdtn.dht.ignore_neighbour_informations" "dht_ignore_neighbour_informations"
  94. add_param $CONFFILE "ibrdtn.dht.allow_neighbours_to_announce_me" "dht_allow_neighbours_to_announce_me"
  95. add_param $CONFFILE "ibrdtn.dht.allow_neighbour_announcement" "dht_allow_neighbour_announcement"
  96. # iterate through all network interfaces
  97. iter=0
  98. netinterfaces=
  99. while [ 1 == 1 ]; do
  100. $UCI -q get "ibrdtn.@network[$iter]" > /dev/null
  101. if [ $? == 0 ]; then
  102. netinterfaces="${netinterfaces} lan${iter}"
  103. add_param $CONFFILE "ibrdtn.@network[$iter].type" "net_lan${iter}_type"
  104. add_param $CONFFILE "ibrdtn.@network[$iter].interface" "net_lan${iter}_interface"
  105. add_param $CONFFILE "ibrdtn.@network[$iter].port" "net_lan${iter}_port"
  106. else
  107. break
  108. fi
  109. let iter=iter+1
  110. done
  111. # write list of network interfaces
  112. echo "net_interfaces =$netinterfaces" >> $CONFFILE
  113. # iterate through all static routes
  114. iter=0
  115. while [ 1 == 1 ]; do
  116. $UCI -q get "ibrdtn.@static-route[$iter]" > /dev/null
  117. if [ $? == 0 ]; then
  118. PATTERN=`$UCI -q get "ibrdtn.@static-route[$iter].pattern"`
  119. DESTINATION=`$UCI -q get "ibrdtn.@static-route[$iter].destination"`
  120. let NUMBER=iter+1
  121. echo "route$NUMBER = $PATTERN $DESTINATION" >> $CONFFILE
  122. else
  123. break
  124. fi
  125. let iter=iter+1
  126. done
  127. #iterate through all static connections
  128. iter=0
  129. while [ 1 == 1 ]; do
  130. $UCI -q get "ibrdtn.@static-connection[$iter]" > /dev/null
  131. if [ $? == 0 ]; then
  132. let NUMBER=iter+1
  133. add_param $CONFFILE "ibrdtn.@static-connection[$iter].uri" "static${NUMBER}_uri"
  134. add_param $CONFFILE "ibrdtn.@static-connection[$iter].address" "static${NUMBER}_address"
  135. add_param $CONFFILE "ibrdtn.@static-connection[$iter].port" "static${NUMBER}_port"
  136. add_param $CONFFILE "ibrdtn.@static-connection[$iter].protocol" "static${NUMBER}_proto"
  137. add_param $CONFFILE "ibrdtn.@static-connection[$iter].immediately" "static${NUMBER}_immediately"
  138. else
  139. break
  140. fi
  141. let iter=iter+1
  142. done