Black Box 1101 Marine Safety Devices User Manual


 
Chapter 15: Advanced Configuration
724-746-5500 | blackbox.com
139
NEWTOTAL=$[ $TOTAL -1 ]
# Make backup copy of config file
cp /etc/config/config.xml /etc/config/config.bak
echo "backup of /etc/config/config.xml saved in /etc/config/config.bak"
if [ -z $NUMBER ] # test whether a singular node is being \
#deleted e.g. config.sdt.hosts
then
echo "deleting $1"
config -d "$1"
echo Done
exit 0
elif [ $NUMBER = $TOTAL ] # Test if only one item exists
then
echo "only one item exists"
# Deleting node
echo "Deleting $1"
config -d "$1"
# Modifying item total.
config -s "$TOTALNODE=0"
echo Done
exit 0
elif [ $NUMBER -lt $TOTAL ] # more than one item exists
then
# Modify the users list so user numbers are sequential
# by shifting the users into the gap one at a time...
echo "Deleting $1"
LASTFIELDTEXT=`echo $LASTFIELD | sed 's/[0-9]//g'`
CHECKTOTAL=`config -g $ROOTNODE.$LASTFIELDTEXT$TOTAL`
if [ -z "$CHECKTOTAL" ]
then
echo "WARNING: "$TOTALNODE" greater than number of items"
fi
COUNTER=1
while [ $COUNTER != $((TOTAL-NUMBER+1)) ]
do
config -g $ROOTNODE.$LASTFIELDTEXT$((NUMBER+COUNTER)) \
| while read LINE
do
config -s \
"`echo "$LINE" | sed -e "s/$LASTFIELDTEXT$((NUMBER+ \
COUNTER))/$LASTFIELDTEXT$((NUMBER+COUNTER-1))/" \
-e 's/ /=/'`"
done
let COUNTER++
done
# deleting last user
config -d $ROOTNODE.$LASTFIELDTEXT$TOTAL
# Modifying item total.
config -s "$TOTALNODE=$NEWTOTAL"