Home | History | Annotate | Download | only in xmlGenerator
      1 #!/bin/bash
      2 
      3 # Copyright (c) 2011-2014, Intel Corporation
      4 # All rights reserved.
      5 #
      6 # Redistribution and use in source and binary forms, with or without modification,
      7 # are permitted provided that the following conditions are met:
      8 #
      9 # 1. Redistributions of source code must retain the above copyright notice, this
     10 # list of conditions and the following disclaimer.
     11 #
     12 # 2. Redistributions in binary form must reproduce the above copyright notice,
     13 # this list of conditions and the following disclaimer in the documentation and/or
     14 # other materials provided with the distribution.
     15 #
     16 # 3. Neither the name of the copyright holder nor the names of its contributors
     17 # may be used to endorse or promote products derived from this software without
     18 # specific prior written permission.
     19 #
     20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     23 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
     24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     25 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     27 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     29 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30 
     31 
     32 
     33 # Execute a PFW script on the target
     34 # In order to regenerate all domains
     35 
     36 set -e
     37 
     38 
     39 if test "$1" == "-" -o ! "$1" ; then
     40     file="stdin"
     41 elif  test -a "$1"  ; then
     42     file="$1"
     43 else
     44     echo "Usage: The argurment must be a file that exists"
     45     exit 2
     46 fi
     47 
     48 #as the shell do not interprete quotes in varable, force it with eval
     49 parameter="$PFWtest_prefixCommand eval remote-process $PFWtest_ParameterFramworkHost"
     50 
     51 function echoColor ()
     52 {
     53     color="$1"
     54     shift
     55     if test -t 1  ;
     56     then
     57         # stdout is a tty => colors
     58         /bin/echo -e "\033[${color}m${@}\033[0m"
     59     else
     60         # stdout is not a tty => no color
     61         /bin/echo -e "$@"
     62     fi
     63 }
     64 
     65 echoGreenColor ()
     66 {
     67         echoColor "32" "$@"
     68 }
     69 
     70 echoBlueColor ()
     71 {
     72         echoColor "34" "$@"
     73 }
     74 
     75 
     76 function parameterExecute ()
     77 {
     78     echoGreenColor "   \$ $parameter $@"
     79     result="$($parameter $@)"
     80 
     81     if [[ "$result" != "Done"* ]]; then
     82          echo "$result"
     83          return 2
     84     fi
     85     return 0
     86 }
     87 
     88 
     89 echoBlueColor "Set tuning mode on"
     90 parameterExecute setTuningMode on
     91 
     92 echoBlueColor "Set auto sync off"
     93 parameterExecute setAutoSync off
     94 
     95 echoBlueColor "deleting old Domains"
     96 parameterExecute deleteAllDomains
     97 
     98 echoBlueColor "executing file '$file'"
     99 cat $1 | \
    100 while read line
    101 do
    102 
    103     if [[ "$line" ==  *[a-z]* ]]
    104     then
    105 
    106         parameterExecute $line
    107     fi
    108 done
    109 
    110 if test $2 != --keep-autoSync-disable
    111 then
    112     echoBlueColor "Set auto sync on"
    113     parameterExecute setAutoSync on
    114 fi
    115