Fixed overwriting of CXXFLAGS.
[staging/basesystem.git] / service / system / config / library / system_manager_config / xml / launch_cfg2xml.sh
1 #!/bin/bash
2
3 #
4 # Copyright (c) 2019-2020 TOYOTA MOTOR CORPORATION
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18  
19 export infile=$1
20 export g_group=1
21
22 if ! [[ "$infile" =~ .+\.cfg ]] ;then
23   echo "$infile is not *.cfg"
24   exit 1
25 elif ! [ -e $infile ];then
26   echo "$infile not found"
27   exit 1
28 fi
29
30 #GROUP extraction
31 cat ${infile} | while read line 
32 do
33   if ! [[ "${line}" =~ ^[#\[] ]]; then    #Remove first #[
34     echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f1-4
35   fi
36 done | uniq | while read line
37 do
38   echo "<!-- group_id=$g_group -->"
39   echo "<group name=\"`echo $line | cut -d '|' -f1`\" wait_time=\"`echo $line | cut -d '|' -f3`\" trigger=\"`echo $line | cut -d '|' -f4`\" >"
40   
41   cat ${infile} | while read line 
42   do
43     if ! [[ "${line}" =~ ^[#\[] ]]; then    #Remove first #[
44       l_group=`echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f2`
45
46       #Extract only LAUNCH applicable to g_group
47       if [ ${l_group} = ${g_group} ]; then
48         echo $line | sed 's/Launch[0-9]\+=//g' | cut -d '|' -f5-
49       fi
50     fi
51   done  | while read line
52   do
53     echo "  <launch "
54     echo "    name=\"`echo $line | cut -d '|' -f1`\" path=\"`echo $line | cut -d '|' -f2`\" priority=\"`echo $line | cut -d '|' -f3`\""
55     echo "    critical=\"`echo $line | cut -d '|' -f4`\" retry_cnt=\"`echo $line | cut -d '|' -f5`\" arguments=\"`echo $line | cut -d '|' -f6`\""
56     echo "    logging_mask=\"`echo $line | cut -d '|' -f7`\" restart=\"`echo $line | cut -d '|' -f8`\" is_start_required=\"`echo $line | cut -d '|' -f9`\""
57     echo "    shutdown_critical=\"`echo $line | cut -d '|' -f10`\" shutdown_wait_time=\"`echo $line | cut -d '|' -f11`\" fast_shutdown_wait_time=\"`echo $line | cut -d '|' -f12`\""
58     echo "    user_name=\"`echo $line | cut -d '|' -f13`\""
59     echo "  />"
60   done
61
62   echo "</group>"
63   
64   g_group=$(($g_group + 1))
65 done
66
67
68
69