diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2008-02-20 18:19:08 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2008-02-20 18:19:08 -0800 |
commit | ea2f6c3e233d30e4ee37fa74a0d027c7478a1943 (patch) | |
tree | 751669b5e9fa72c5bee4d55957cbdb61830902fe /scripts/vyatta-cfg-cmd-wrapper | |
parent | a77ffd90c19a203b5d0ebcc413c9f8f5b3b86a04 (diff) | |
download | vyatta-cfg-ea2f6c3e233d30e4ee37fa74a0d027c7478a1943.tar.gz vyatta-cfg-ea2f6c3e233d30e4ee37fa74a0d027c7478a1943.zip |
add vyatta-cfg-cmd-wrapper to replace xorp_tmpl_tool.
Diffstat (limited to 'scripts/vyatta-cfg-cmd-wrapper')
-rwxr-xr-x | scripts/vyatta-cfg-cmd-wrapper | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/vyatta-cfg-cmd-wrapper b/scripts/vyatta-cfg-cmd-wrapper new file mode 100755 index 0000000..4a42105 --- /dev/null +++ b/scripts/vyatta-cfg-cmd-wrapper @@ -0,0 +1,65 @@ +#!/bin/bash + +if grep -q union=aufs /proc/cmdline || grep -q aufs /proc/filesystems ; then + export UNIONFS=aufs +else + export UNIONFS=unionfs +fi + +UMASK_SAVE=`umask` +umask 0002 + +export VYATTA_EDIT_LEVEL=/; +export VYATTA_TEMPLATE_LEVEL=/; +export VYATTA_ACTIVE_CONFIGURATION_DIR=/opt/vyatta/config/active; + +export VYATTA_CHANGES_ONLY_DIR=/opt/vyatta/config/tmp/changes_only_$PPID; +export VYATTA_TEMP_CONFIG_DIR=/opt/vyatta/config/tmp/new_config_$PPID; +export VYATTA_CONFIG_TMP=/opt/vyatta/config/tmp/tmp_$PPID; + +RET_STATUS=0 + +case "$1" in + begin) + # set up the environment/directories + mkdir -p $VYATTA_ACTIVE_CONFIGURATION_DIR + mkdir -p $VYATTA_CHANGES_ONLY_DIR + if [ ! -d $VYATTA_TEMP_CONFIG_DIR ]; then + mkdir -p $VYATTA_TEMP_CONFIG_DIR + sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:${VYATTA_ACTIVE_CONFIGURATION_DIR}=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} + fi + mkdir -p $VYATTA_CONFIG_TMP + ;; + end) + # tear down the environment/directories + sudo umount ${VYATTA_TEMP_CONFIG_DIR} + rm -rf ${VYATTA_CHANGES_ONLY_DIR} + rm -rf ${VYATTA_CONFIG_TMP} + rm -rf ${VYATTA_TEMP_CONFIG_DIR} + ;; + cleanup) + sudo umount ${VYATTA_TEMP_CONFIG_DIR} + rm -rf $VYATTA_CHANGES_ONLY_DIR/* $VYATTA_CHANGES_ONLY_DIR/.modified + sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:${VYATTA_ACTIVE_CONFIGURATION_DIR}=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR} + ;; + set) + /opt/vyatta/sbin/my_set "${@:2}" + RET_STATUS=$? + ;; + delete) + /opt/vyatta/sbin/my_delete "${@:2}" + RET_STATUS=$? + ;; + commit) + /opt/vyatta/sbin/my_commit + RET_STATUS=$? + ;; + *) + echo "Invalid command \"$1\" for vyatta-cfg-cmd-wrapper" + RET_STATUS=1 + ;; +esac + +umask ${UMASK_SAVE} +exit $RET_STATUS + |