diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-12-03 19:07:54 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-12-03 19:07:54 -0800 |
commit | ed95fe7775d63a777d86779debcd1fd59e2d921f (patch) | |
tree | 39f6c331b7811cae00e2930009404362e37afdc9 | |
parent | 814ec6da0379583108fd2d46dc90811b24fba359 (diff) | |
download | vyatta-cfg-ed95fe7775d63a777d86779debcd1fd59e2d921f.tar.gz vyatta-cfg-ed95fe7775d63a777d86779debcd1fd59e2d921f.zip |
change boot-time config loading to use new implementation in backend.
* add new boot-time config loading script that uses shell API to access backend directly, bypassing wrapper.
* use new loadFile implementation in the backend to perform the actual "load" operation (without "commit"). this reduces the "pre-commit" load time by ~60%.
-rw-r--r-- | Makefile.am | 2 | ||||
-rwxr-xr-x | etc/init.d/vyatta-router | 2 | ||||
-rwxr-xr-x | scripts/vyatta-boot-config-loader | 74 | ||||
-rw-r--r-- | src/cparse/cparse_lex.l | 4 |
4 files changed, 78 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am index 41baca7..9daed20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,7 +86,7 @@ sbin_SCRIPTS = scripts/vyatta-cfg-cmd-wrapper sbin_SCRIPTS += scripts/vyatta-validate-type.pl sbin_SCRIPTS += scripts/vyatta-find-type.pl sbin_SCRIPTS += scripts/priority.pl -sbin_SCRIPTS += scripts/vyatta-config-loader.pl +sbin_SCRIPTS += scripts/vyatta-boot-config-loader sbin_SCRIPTS += scripts/vyatta-config-gen-sets.pl sbin_SCRIPTS += scripts/vyatta-cli-expand-var.pl sbin_SCRIPTS += scripts/vyatta-output-config.pl diff --git a/etc/init.d/vyatta-router b/etc/init.d/vyatta-router index e7a5783..bccd7b7 100755 --- a/etc/init.d/vyatta-router +++ b/etc/init.d/vyatta-router @@ -121,7 +121,7 @@ load_bootfile () # build-specific environment for boot-time config loading source /etc/default/vyatta-load-boot fi - sg ${GROUP} -c "$vyatta_sbindir/vyatta-config-loader.pl $BOOTFILE" + sg ${GROUP} -c "$vyatta_sbindir/vyatta-boot-config-loader $BOOTFILE" ) } diff --git a/scripts/vyatta-boot-config-loader b/scripts/vyatta-boot-config-loader new file mode 100755 index 0000000..3872974 --- /dev/null +++ b/scripts/vyatta-boot-config-loader @@ -0,0 +1,74 @@ +#!/bin/bash + +BOOT_FILE=$1 +shift + +CAPI=/bin/cli-shell-api +CLOG=/tmp/vyatta-config-loader.log +COMMIT=/opt/vyatta/sbin/my_commit +COMMIT_LOG=/tmp/vyatta-commit.log + +do_log () { + local level=$1 + shift + logger -t 'boot-config-loader' -p "local0.$level" -- "$*" +} + +do_commit () { + $COMMIT "$@" >>$COMMIT_LOG +} + +trace () { + echo "$(date +'%F %T') $*" +} + +umask 0002 + +( + trace '== begin boot-config-loader' + # set up config session + SID=$$ + SENV=$($CAPI getSessionEnv $SID) + eval "$SENV" + if ! $CAPI setupSession; then + do_log err 'Cannot set up configuration session.' + trace 'Cannot set up configuration session.' + exit 1 + fi + + # do load + trace '-- begin load' + if ! $CAPI loadFile $BOOT_FILE; then + do_log warn "Failure(s) encountered during load. See $CLOG for details." + trace '-- load finished with failure(s)' + else + trace '-- load finished successfully' + fi + + # do commit + trace '-- begin commit' + ret=0 + export COMMIT_VIA=boot-config-loader + do_commit -a + do_commit -s + if ! do_commit -e -d; then + do_log err 'Commit failed at boot.' + trace '-- commit failed' + ret=1 + else + trace '-- commit succeeded' + fi + + # clean up + if ! $CAPI teardownSession; then + do_log warn 'Failed to tear down configuration session.' + trace '-- teardown failed' + else + trace '-- teardown succeeded' + fi + trace '-- exiting' + exit $ret +) </dev/null >>$CLOG 2>&1 + +exit $? + diff --git a/src/cparse/cparse_lex.l b/src/cparse/cparse_lex.l index 1afe886..61c016f 100644 --- a/src/cparse/cparse_lex.l +++ b/src/cparse/cparse_lex.l @@ -158,8 +158,8 @@ set_ret_str() } <sQStr>\\. { - char tmp[2] = { cparse_text[1], 0 }; - append_str(tmp); + /* this will consume the \" sequence */ + append_str(cparse_text); } <sQStr>\n { |