Changeset 4986 in genesis for tools/config-node.sh


Ignore:
Timestamp:
Nov 2, 2005, 5:43:32 PM (19 years ago)
Author:
rick
Message:

Minor bug fixes and RO/RW automation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/config-node.sh

    • Property svn:keywords set to Id Rev
    r4985 r4986  
    1212#       file list, check node name to be valid, '-n' mode.
    1313#       make moving of final files a bit safer. (dirkx)
     14# 1.04  Add auto read-only detection.
    1415#
    1516# If there is a global system configuration file, suck it in.
     
    2223HTTP_PROXY_DEFAULT=${HTTP_PROXY:-http://proxy.wleiden.net:3128}
    2324HTTP_USER_AGENT=${HTTP_USER_AGENT:-curl.faked.fetch/0.0}
    24 VERSION=1.03
     25VERSION=1.04
    2526QUIET=${QUIET:-}
    2627PRETEND=no
     28FORCE=no
    2729
    2830FETCH=${FETCH:-/usr/bin/fetch}
     
    4244        echo "-n                Show what would happen - but do not do it"
    4345        echo "-q                Suppress all output and user interaction"
     46        echo "-F                Force disk to write"
    4447        exit 1
    4548}
     
    6669                        PRETEND=yes
    6770                        ;;
     71                -F)
     72                        FORCE=yes
     73                        ;;
    6874                *)
    6975                        test $# -eq 1 || usage
     
    7581done
    7682
     83echo Config Node -- Version: $VERSION '$Rev$'
     84
     85# Make sure we clean up our mess when needed.
     86trap "rm -f ${TMPPREFIX}.?; echo Failed; exit 1;" 2 3
     87
     88if [ ${PRETEND} != 'yes' ]; then
     89        if mount | grep "on / " | grep -q read-only; then
     90                if [ ${FORCE} = "yes" ]; then
     91                        echo Forcing read-only disk into rw.
     92                        fsck / || exit 2
     93                        mount -o noatime -u -w / || exit 2 || exit 1
     94                        trap "mount -u -r /; rm -f ${TMPPREFIX}.?; echo Failed; exit 1;" 2 3
     95                        FORCE=rw
     96                else
     97                        echo ERROR - disk / is mounted read only. Aborting.
     98                        exit 1
     99                fi
     100        fi
     101fi
     102
    77103export HTTP_USER_AGENT
    78104export TMPDIR
     
    85111lcd=${LCDIR:-/lcd}
    86112
    87 # Make sure we clean up our mess when needed.
    88 trap "rm -f ${TMPPREFIX}.?; echo Failed; exit 1;" 2 3
    89113
    90114# connection test function
     
    253277   fi
    254278
    255    test -e $symdir/$file || echo WARNING: Symlink $symdir/$file not in place.
     279   test -e $symdir/$file || (
     280                echo WARNING: Symlink $symdir/$file not in place.
     281                echo use:   ln -s $dir/$file $symdir/$file 
     282                echo to fix if appropriate.
     283        )
    256284}
    257285
    258286dir=${lcd}
    259287
    260 echo Config Node -- Version: $VERSION
    261288
    262289#check config dir
     
    331358                ;;
    332359        resolv.conf | rc.node.local | rc.local)
    333                 linkin /etc/ ${i}
     360                linkin /etc ${i}
    334361                ;;
    335362        snmpd.local.conf)
    336                 linkin /usr/local/share/snmp/ ${i}
     363                linkin /usr/local/share/snmp ${i}
    337364                ;;
    338365        named.conf)
    339                 linkin/etc/namedb/ ${i}
     366                linkin /etc/namedb ${i}
    340367                ;;
    341368        dhcpd.conf)
    342                 linkin /usr/local/etc/ ${i}
     369                linkin /usr/local/etc ${i}
    343370                ;;
    344371        zebra.conf | ospfd.conf)
    345                 linkin /usr/local/etc/zebra/ ${i}
     372                linkin /usr/local/etc/zebra ${i}
    346373                ;;
    347374        authorized_keys)
     
    403430fi
    404431
     432test ${FORCE} = 'rw' && mount -u -r /
    405433exit 0
Note: See TracChangeset for help on using the changeset viewer.