oscarBravo
07-03-2007, 04:56 PM
Here's something I just hacked together this evening. It only works for v2, since v3 doesn't support the script upload and download functions - something to look forward to.
Basically I'm a vi kinda guy, and editing CBQ scripts without vi seems like a lot of hard work, so I threw this together to download a CBQ script, edit it, and upload it again. #!/bin/bash
if [ -z $2 ]; then
stty -echo
read -p "Password: " PASSWORD; echo
stty echo
else
PASSWORD=$2
fi
TEMP=`tempfile`
RESULT=`starutil $1 $PASSWORD -dscr cbq $TEMP`
if echo "$RESULT" | grep -q success; then
vi $TEMP
read -p "Upload changes? " UPLOAD
if [ $UPLOAD = 'y' ]; then
read -p "Activate after upload? " ACTIVATE
if [ $ACTIVATE = 'y' ]; then
FLAGS="-a"
fi
starutil $1 $PASSWORD -uscr cbq $TEMP $FLAGS &> /dev/null
echo "Success!"
else
echo "Aborted."
fi
else
echo "$RESULT"
fi
rm $TEMP To use it, you type "editcbq <router address> [password]" - if no password is provided it prompts for one.
I'm pretty crap at bash scripting, so any feedback is welcome.
Question: does the -a flag cause a "save" on the router? In other words, does it write to flash?
Edit: mod to remove the temporary file when finished.
Basically I'm a vi kinda guy, and editing CBQ scripts without vi seems like a lot of hard work, so I threw this together to download a CBQ script, edit it, and upload it again. #!/bin/bash
if [ -z $2 ]; then
stty -echo
read -p "Password: " PASSWORD; echo
stty echo
else
PASSWORD=$2
fi
TEMP=`tempfile`
RESULT=`starutil $1 $PASSWORD -dscr cbq $TEMP`
if echo "$RESULT" | grep -q success; then
vi $TEMP
read -p "Upload changes? " UPLOAD
if [ $UPLOAD = 'y' ]; then
read -p "Activate after upload? " ACTIVATE
if [ $ACTIVATE = 'y' ]; then
FLAGS="-a"
fi
starutil $1 $PASSWORD -uscr cbq $TEMP $FLAGS &> /dev/null
echo "Success!"
else
echo "Aborted."
fi
else
echo "$RESULT"
fi
rm $TEMP To use it, you type "editcbq <router address> [password]" - if no password is provided it prompts for one.
I'm pretty crap at bash scripting, so any feedback is welcome.
Question: does the -a flag cause a "save" on the router? In other words, does it write to flash?
Edit: mod to remove the temporary file when finished.