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