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.

173 lines
6.1 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. netinternet=
  100. while [ 1 == 1 ]; do
  101. $UCI -q get "ibrdtn.@network[$iter]" > /dev/null
  102. if [ $? == 0 ]; then
  103. netinterfaces="${netinterfaces} lan${iter}"
  104. add_param $CONFFILE "ibrdtn.@network[$iter].type" "net_lan${iter}_type"
  105. add_param $CONFFILE "ibrdtn.@network[$iter].interface" "net_lan${iter}_interface"
  106. add_param $CONFFILE "ibrdtn.@network[$iter].port" "net_lan${iter}_port"
  107. if [ "$(uci -q get ibrdtn.@network[$iter].global)" == "yes" ]; then
  108. netinternet="${netinternet} $(uci -q get ibrdtn.@network[$iter].interface)"
  109. fi
  110. else
  111. break
  112. fi
  113. let iter=iter+1
  114. done
  115. # write list of network interfaces
  116. echo "net_interfaces =$netinterfaces" >> $CONFFILE
  117. echo "net_internet =${netinternet}" >> $CONFFILE
  118. # iterate through all static routes
  119. iter=0
  120. while [ 1 == 1 ]; do
  121. $UCI -q get "ibrdtn.@static-route[$iter]" > /dev/null
  122. if [ $? == 0 ]; then
  123. PATTERN=`$UCI -q get "ibrdtn.@static-route[$iter].pattern"`
  124. DESTINATION=`$UCI -q get "ibrdtn.@static-route[$iter].destination"`
  125. let NUMBER=iter+1
  126. echo "route$NUMBER = $PATTERN $DESTINATION" >> $CONFFILE
  127. else
  128. break
  129. fi
  130. let iter=iter+1
  131. done
  132. #iterate through all static connections
  133. iter=0
  134. while [ 1 == 1 ]; do
  135. $UCI -q get "ibrdtn.@static-connection[$iter]" > /dev/null
  136. if [ $? == 0 ]; then
  137. let NUMBER=iter+1
  138. add_param $CONFFILE "ibrdtn.@static-connection[$iter].uri" "static${NUMBER}_uri"
  139. add_param $CONFFILE "ibrdtn.@static-connection[$iter].address" "static${NUMBER}_address"
  140. add_param $CONFFILE "ibrdtn.@static-connection[$iter].port" "static${NUMBER}_port"
  141. add_param $CONFFILE "ibrdtn.@static-connection[$iter].protocol" "static${NUMBER}_proto"
  142. add_param $CONFFILE "ibrdtn.@static-connection[$iter].immediately" "static${NUMBER}_immediately"
  143. else
  144. break
  145. fi
  146. let iter=iter+1
  147. done