summaryrefslogtreecommitdiff
path: root/scripts/xorp_tmpl_tool
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-02-20 18:19:08 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-02-20 18:19:08 -0800
commitea2f6c3e233d30e4ee37fa74a0d027c7478a1943 (patch)
tree751669b5e9fa72c5bee4d55957cbdb61830902fe /scripts/xorp_tmpl_tool
parenta77ffd90c19a203b5d0ebcc413c9f8f5b3b86a04 (diff)
downloadvyatta-cfg-ea2f6c3e233d30e4ee37fa74a0d027c7478a1943.tar.gz
vyatta-cfg-ea2f6c3e233d30e4ee37fa74a0d027c7478a1943.zip
add vyatta-cfg-cmd-wrapper to replace xorp_tmpl_tool.
Diffstat (limited to 'scripts/xorp_tmpl_tool')
-rwxr-xr-xscripts/xorp_tmpl_tool162
1 files changed, 0 insertions, 162 deletions
diff --git a/scripts/xorp_tmpl_tool b/scripts/xorp_tmpl_tool
deleted file mode 100755
index 014a53b..0000000
--- a/scripts/xorp_tmpl_tool
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/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_G=`umask`
-umask 0111
-XORPLOGFILE=/tmp/xorp_tmpl_tool.log
-touch ${XORPLOGFILE}
-
-umask 0002
-
-#need to pass in value to change... as part of set command...
-## cli ENV_EDIT_LEVEL
-export VYATTA_EDIT_LEVEL=/;
-## cli ENV_TEMPLATE_LEVEL
-export VYATTA_TEMPLATE_LEVEL=/;
-
-## cli ENV_A_DIR
-export VYATTA_ACTIVE_CONFIGURATION_DIR=/opt/vyatta/config/active;
-mkdir -p $VYATTA_ACTIVE_CONFIGURATION_DIR
-
-#now need to grab the parent pid.
-## XXX eventually, we will use each session's bash shell pid for this.
-## however, for now, to interact with XORP we will rely on a global lock
-## instead of separate config dirs.
-#export VTID=$PPID
-export VTID=XORP
-
-# lock for XORP
-export XORP_LOCK="/opt/vyatta/config/active/.xorp.lck"
-
-## cli ENV_C_DIR
-export VYATTA_CHANGES_ONLY_DIR=/opt/vyatta/config/tmp/changes_only_$VTID;
-mkdir -p $VYATTA_CHANGES_ONLY_DIR
-
-## cli ENV_M_DIR
-export VYATTA_TEMP_CONFIG_DIR=/opt/vyatta/config/tmp/new_config_$VTID;
-if [ ! -d $VYATTA_TEMP_CONFIG_DIR ]
-then
- mkdir -p $VYATTA_TEMP_CONFIG_DIR
- sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR}
-fi
-
-## cli ENV_TMP_DIR
-export VYATTA_CONFIG_TMP=/opt/vyatta/config/tmp/tmp_$VTID;
-mkdir -p $VYATTA_CONFIG_TMP
-
-RET_STATUS=0
-#this needs to be the array string of commands, something like $[*] or whatever
-
-echo "Command: ${@}" | grep -v -i password >> ${XORPLOGFILE}
-
-#echo "ConfigDirectories BEFORE ========>>>>>>" >> ${XORPLOGFILE}
-#find /opt/vyatta/config -name "*" -print | grep interface >> ${XORPLOGFILE}
-#echo "<=========ConfigDirectories BEFORE" >> ${XORPLOGFILE}
-
-## for tracing command-line XRL calls.
-## 1 => info level
-## 2 => warning level
-#export CL_XRLTRACE=2
-
-UMASK_SAVE=`umask`
-umask 0111
-MYCMDERRLOGFILE=/tmp/my_cmd_err_${RANDOM}.log
-rm -rf ${MYCMDERRLOGFILE}
-umask ${UMASK_SAVE}
-
-case "$1" in
- set)
- /opt/vyatta/sbin/my_set "${@:2}" >>${XORPLOGFILE} 2>>${MYCMDERRLOGFILE}
- RET_STATUS=$?
- if [ $RET_STATUS != 0 ]; then
- rm -rf $XORP_LOCK >&/dev/null
- fi
- ;;
- delete)
- /opt/vyatta/sbin/my_delete "${@:2}" >>${XORPLOGFILE} 2>>${MYCMDERRLOGFILE}
- RET_STATUS=$?
- if [ $RET_STATUS != 0 ]; then
- rm -rf $XORP_LOCK >&/dev/null
- fi
- ;;
- commit)
- /opt/vyatta/sbin/my_commit >>${XORPLOGFILE} 2>>${MYCMDERRLOGFILE}
- RET_STATUS=$?
- rm -rf $XORP_LOCK >&/dev/null
- ;;
- test)
- "${@:2}"
- RET_STATUS=$?
- ;;
- cleanup)
-
- LOCKTRYCOUNTER=0
- LOCKTRYSTATUS=-1
-
- while [[ ${LOCKTRYCOUNTER} -lt 60 && ${LOCKTRYSTATUS} -ne 0 ]] ; do
-
- if mkdir $XORP_LOCK >&/dev/null ; then
- LOCKTRYSTATUS=0
- else
- LOCKTRYCOUNTER=`expr ${LOCKTRYCOUNTER} + 1`
- sleep 1;
- fi
- done
-
- if [ ${LOCKTRYCOUNTER} -ge 60 ] ; then
- echo "Cannot unlock configuration" >> ${MYCMDERRLOGFILE}
- rm -rf ${XORP_LOCK}
- mkdir $XORP_LOCK >&/dev/null
- fi
-
- sudo umount ${VYATTA_TEMP_CONFIG_DIR}
- sudo rm -rf $VYATTA_CHANGES_ONLY_DIR/* $VYATTA_CHANGES_ONLY_DIR/.modified
- sudo mount -t $UNIONFS -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:/opt/vyatta/config/active=ro $UNIONFS ${VYATTA_TEMP_CONFIG_DIR}
- RET_STATUS=0
- ;;
- end_loading)
- sudo umount ${VYATTA_TEMP_CONFIG_DIR}
- sudo rm -rf ${VYATTA_CHANGES_ONLY_DIR}
- sudo rm -rf ${VYATTA_CONFIG_TMP}
- sudo rm -rf ${VYATTA_TEMP_CONFIG_DIR}
- RET_STATUS=0
- ;;
- rtrmgr_indirect_cleanup)
- # do nothing now that we handle XORP interaction differently.
- RET_STATUS=0
- ;;
- *)
- rm -rf ${MYCMDERRLOGFILE}
- exit 1
- ;;
-esac
-
-if [ -f ${MYCMDERRLOGFILE} ] ; then
-
- echo -n "STDERR:" >>${XORPLOGFILE}
- cat ${MYCMDERRLOGFILE} >>${XORPLOGFILE}
- echo "end of STDERR" >>${XORPLOGFILE}
-
- cat ${MYCMDERRLOGFILE} 1>&2
-
- rm -rf ${MYCMDERRLOGFILE}
-
-fi
-
-#echo "ConfigDirectories AFTER ========>>>>>>" >> ${XORPLOGFILE}
-#find /opt/vyatta/config -name "*" -print | grep interface >> ${XORPLOGFILE}
-#echo "<=========ConfigDirectories AFTER" >> ${XORPLOGFILE}
-
-echo "ret=${RET_STATUS}" >> ${XORPLOGFILE}
-umask ${UMASK_SAVE_G}
-exit $RET_STATUS
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 4
-# End: