vRouter: vr_cfg: style consistency fixes

This commit is contained in:
Ronald van Zantvoort 2017-05-08 14:08:29 +02:00
parent 8f5275399e
commit a2eb0f23a9

View File

@ -27,39 +27,28 @@ log_it() {
echo "$(date) : $*" >> $log echo "$(date) : $*" >> $log
} }
while getopts 'c:' OPTION while getopts 'c:' OPTION; do
do
case $OPTION in case $OPTION in
c) cfg="$OPTARG" c) cfg="$OPTARG" ;;
;; esac; done
esac
done
while read line while read line; do
do
#comment #comment
if [[ $line == \#* ]] if [[ $line == \#* ]]; then
then
continue continue
fi
if [ "$line" == "<version>" ] elif [ "$line" == "<version>" ]; then
then
read line read line
version=$line version=$line
log_it "VR config: configuation format version $version" log_it "VR config: configuation format version $version"
#skip </version> #skip </version>
read line read line
continue
fi
if [ "$line" == "<script>" ] elif [ "$line" == "<script>" ]; then
then
read line read line
log_it "VR config: executing: $line" log_it "VR config: executing: $line"
eval $line >> $log 2>&1 eval $line >> $log 2>&1
if [ $? -ne 0 ] if [ $? -ne 0 ]; then
then
log_it "VR config: executing failed: $line" log_it "VR config: executing failed: $line"
# expose error info to mgmt server # expose error info to mgmt server
echo "VR config: execution failed: \"$line\", check $log in VR for details " 1>&2 echo "VR config: execution failed: \"$line\", check $log in VR for details " 1>&2
@ -68,26 +57,22 @@ do
#skip </script> #skip </script>
read line read line
log_it "VR config: execution success " log_it "VR config: execution success "
continue
fi
if [ "$line" == "<file>" ] elif [ "$line" == "<file>" ]; then
then
read line read line
file=$line file=$line
log_it "VR config: creating file: $file" log_it "VR config: creating file: $file"
rm -f $file rm -f $file
while read -r line while read -r line; do
do if [ "$line" == "</file>" ]; then
if [ "$line" == "</file>" ]
then
break break
fi fi
echo $line >> $file echo $line >> $file
done done
log_it "VR config: create file success" log_it "VR config: create file success"
continue
fi fi
done < $cfg done < $cfg
# archive the configuration file # archive the configuration file