Changeset 4085 in genesis for tools/config-node.sh
- Timestamp:
- Mar 16, 2005, 11:26:53 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config-node.sh
r4054 r4085 1 1 #!/bin/sh 2 # (c) Copyright 2002, 2003 Stichting Wireless Leiden, all2 # (c) Copyright 2002, 2003, 2005 Stichting Wireless Leiden, all 3 3 # rights reserved. More information can be found on 4 4 # http://wwww.wirelessleiden.nl and the license is at: … … 9 9 # If there is a global system configuration file, suck it in. 10 10 # 11 12 13 if [ -r /etc/defaults/rc.conf ]; then14 . /etc/defaults/rc.conf15 source_rc_confs16 elif [ -r /etc/rc.conf ]; then17 . /etc/rc.conf18 fi19 11 20 12 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin … … 49 41 case $proxyset in 50 42 51 n) 43 n) 52 44 echo no proxy is set 53 45 ;; 54 46 y) 55 56 57 47 echo this the proxy ${HTTP_PROXY} 48 export HTTP_PROXY 49 ;; 58 50 59 51 *) 60 61 62 63 52 ${HTTP_PROXY}=${proxyset} 53 echo this the proxy $HTTP_PROXY 54 export HTTP_PROXY 55 ;; 64 56 esac 65 57 … … 74 66 lcd=${LCDIR:-/lcd} 75 67 76 # True/false - logging.77 # quiet=true78 79 68 # Make sure we clean up our mess when needed. 80 69 trap "rm -f ${TMPPREFIX}.?; echo Failed; exit 1;" 2 3 … … 87 76 killall dhclient 88 77 fi 89 78 90 79 91 80 echo "enter the ipadress to resolv dns" … … 99 88 case $dns_list in 100 89 1) 101 102 103 2) 104 105 90 resolver="172.17.8.1" 91 ;; 92 2) 93 resolver="194.109.9.99" 94 ;; 106 95 3) 107 108 96 resolver="10.0.0.1" 97 ;; 109 98 *) 110 111 99 resolver=$dns_list 100 ;; 112 101 esac 113 102 … … 122 111 do 123 112 case ${nic} in 124 125 echo 126 127 128 129 130 131 132 133 134 135 136 137 138 139 113 lo0) 114 echo 115 ;; 116 wi*) 117 echo 118 ;; 119 *) 120 if ping -qnoc ${WHOST}; then 121 echo Connection on interface ${nic} ok 122 else 123 killall dhclient 124 echo Trying to get a DHCP lease on ${nic} 125 dhclient -1 ${nic} 126 fi 127 ;; 128 esac 140 129 done 141 130 } … … 150 139 fi 151 140 if [ "x${nic_dhcp}" = "xn" ] ; then 152 153 154 155 141 echo proceding... 142 else 143 echo running dhclient 144 connset 156 145 fi 157 146 # Logging function … … 159 148 log() 160 149 { 161 ${quiet} || return 162 echo $* 150 echo $* 163 151 } 164 152 165 153 cleanse() 166 154 { 167 155 rm -f ${TMPPREFIX}.? 168 156 } 169 157 … … 173 161 cleanexit() 174 162 { 175 176 177 178 179 180 181 182 183 163 E=1 164 if [ $# -gt 0 ]; then 165 E=$1 166 fi 167 cleanse 168 log Exit 169 exit $E 170 # Trap any weird exit codes. 171 exit 1 184 172 } 185 173 186 174 safefetch() 187 175 { 188 189 190 191 192 193 194 195 196 176 url=$1 177 file=$2 178 fetch -q -o - ${link}${nodename} > ${TMPPREFIX}.x \ 179 || cleanexit 1 180 cp ${TMPPREFIX}.x ${dir}/${list} \ 181 || cleanexit 1 182 rm -f ${TMPPREFIX}.x 183 184 return 0 197 185 } 198 186 … … 208 196 while ! grep -q "^${nodename}\$" ${nlist} 209 197 do 210 211 212 213 214 if [ -z ${QUIET} ]; then 215 216 217 218 219 220 221 222 198 echo Nodes: 199 cat ${nlist} 200 echo 201 echo -n enter nodename \[default: ${default}\]: 202 if [ -z ${QUIET} ]; then 203 read nodename 204 else 205 nodename=${default} 206 fi 207 208 if [ "x${nodename}" = "x" ]; then 209 nodename=${default} 210 fi 223 211 done 224 212 … … 226 214 } 227 215 228 # a function to move conf_file to admin_dir229 # and to make symlink on the old location to230 # the new location231 216 232 217 do_diff() { 233 diff -uwbB ${symdir}/${i} ${dir}/${i}.new 234 } 218 diff -uwbB ${symdir}/${i} ${dir}/${i}.new 219 } 220 235 221 236 222 do_move() { 237 if [ - x${dir}/${i}.bak ]; then223 if [ -e ${dir}/${i}.bak ]; then 238 224 rm ${dir}/${i}.bak 239 225 fi 240 226 241 if [ - x${dir}/${i} ]; then242 mv ${dir}/${i} ${dir}/${i}.bak 227 if [ -e ${dir}/${i} ]; then 228 mv ${dir}/${i} ${dir}/${i}.bak || cleanexit 1 243 229 log backup ${dir}/${i} to ${dir}/${i}.bak 244 230 fi … … 249 235 250 236 bink() { 251 237 $CMD 252 238 } 253 239 … … 259 245 # 260 246 if [ ! -d ${dir} ]; then 261 247 mkdir -p ${dir} || cleanexit 1 262 248 fi 263 249 264 250 if [ -z ${HTTP_PROXY} ]; then 265 266 267 268 269 270 271 272 273 251 # checking connection - and only fiddle 252 # with interfaces if we need to. 253 # 254 ( 255 echo no proxy defined - checking connection. 256 host ${WHOST} > /dev/null || exit 1 257 ping -qnoc 1 ${WHOST} > /dev/null || exit 1 258 exit 0 259 ) || connset 274 260 fi 275 261 276 262 CMD=do_move 277 263 if [ "x$1" = "x-d" ]; then 278 279 280 264 CMD=do_diff 265 dir=${TMPDIR} 266 shift 281 267 fi 282 268 … … 284 270 # 285 271 if [ $# = 1 ]; then 286 272 nodename=$1 287 273 else 288 289 290 291 292 293 274 if [ -r ${lcd}/myname ]; then 275 default=`cat ${lcd}/myname` 276 else 277 default=`hostname -s` 278 test -z $default && default=none 279 fi 294 280 fi 295 281 … … 306 292 for i in `cat ${dir}/${list}` 307 293 do 308 309 310 294 log getting ${i} for ${nodename} from ${link} 295 fetch -q -o - ${link}${nodename}/${i} > ${dir}/${i}.new \ 296 || cleanexit 1 311 297 done 312 298 … … 314 300 for i in `cat ${dir}/${list}` 315 301 do 316 case ${i} in 317 linux.sh | config) 318 log obsolete file: ${i} - skipped 319 ;; 320 resolv.conf | rc.node.local | rc.local) 321 symdir='/etc/' 322 bink 323 ;; 324 snmpd.local.conf) 325 symdir='/usr/local/share/snmp/' 326 bink 327 ;; 328 named.conf) 329 symdir='/etc/namedb/' 330 bink 331 ;; 332 dhcpd.conf) 333 symdir='/usr/local/etc/' 334 bink 335 ;; 336 zebra.conf | ospfd.conf) 337 symdir='/usr/local/etc/zebra/' 338 bink 339 ;; 340 authorized_keys) 341 symdir='/root/.ssh' 342 bink 343 ;; 344 daemons.sh) 345 symdir='/wl' 346 bink 347 ;; 348 *) 349 echo Script cannot cope with ${i} - ignoring.. 350 ;; 351 esac 302 case $i in 303 txtconfig|rc.local|rc.node.local|snmpd.local.conf|resolv.conf|dhcpd.conf|named.conf) 304 bink 305 ;; 306 *) 307 echo Script cannot cope with ${i} - ignoring.. 308 ;; 309 esac 352 310 done 353 311 354 312 355 313 if [ -e /etc/rc.local ]; then 356 357 358 359 360 361 362 363 364 365 366 367 368 314 # See if we are in rc.local 315 if grep -q /config-node.sh /etc/rc.local; then 316 317 echo As this node now has real configs - do enter a root password 318 echo 319 passwd \ 320 || cleanexit 1 321 322 echo Removing /etc/rc.local 323 rm -f /etc/rc.local 324 325 echo Will drop write perms on the next reboot. 326 fi 369 327 fi 370 328 … … 376 334 hostname $H 377 335 if [ -r /etc/namedb/make-localhost ]; then 378 379 380 381 336 ( 337 cd /etc/namedb || exit 1 338 sh /etc/namedb/make-localhost || exit 1 339 ) || exit 1 382 340 fi 383 341 … … 385 343 386 344 if [ -e /etc/rc.empty.conf ] ; then 387 388 389 390 345 rm /etc/rc.empty.conf || exit 346 echo removed /etc/rc.empty.conf - and rebooting in 30 seconds \(or press ctrl-C to abort\) 347 read -t 30 DUMMY 348 reboot 391 349 fi 392 350
Note:
See TracChangeset
for help on using the changeset viewer.