Import/Export Config Trees

This topic summarizes how to create a script to automate importing and exporting config tree settings.

Legato automatically creates copies of config trees during updating.

An import/export script is an easy way to create a copy of your config trees in case you want to reinstate without rebuilding them.

This code sample shows how you can wrap update in a shell script that will automate the import/export functions:

#!/bin/bash
 
APP_NAME=$1
 
if [ -z "$APP_NAME" ]
then
>&2 echo "Application name not specified."
exit 1
fi
 
 
if [ -z "$2" ]
then
if [ -z "$DEST_IP" ]
then
>&2 echo "Device IP address not specified."
exit 1
fi
DEVICE_IP=$DEST_IP
else
DEVICE_IP=$2
fi
 
 
function cfg
{
CMD=$1
#echo "Test: "
ssh root@$DEVICE_IP "/usr/local/bin/config $CMD $APP_NAME:/ ~/$APP_NAME.cfg"
}
 
 
cfg export
update $APP_NAME.wp85.update $DEVICE_IP
cfg import

If you save this script as inst.sh, you can run like this:

$ inst.sh <myApp> <myDeviceIP>

or

$ export DEST_IP=<myDeviceIP>
$ inst.sh myApp