OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to generate a factory install partition set and miniomaha.conf | 7 # Script to generate a factory install partition set and miniomaha.conf |
8 # file from a release image and a factory image. This creates a server | 8 # file from a release image and a factory image. This creates a server |
9 # configuration that can be installed using a factory install shim. | 9 # configuration that can be installed using a factory install shim. |
10 # | 10 # |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` | 159 firmware_hash=`cat firmware.gz | openssl sha1 -binary | openssl base64` |
160 mv firmware.gz ${OMAHA_DATA_DIR} | 160 mv firmware.gz ${OMAHA_DATA_DIR} |
161 echo "firmware: ${firmware_hash}" | 161 echo "firmware: ${firmware_hash}" |
162 fi | 162 fi |
163 | 163 |
164 # If the file does exist and we are using the subfolder flag we are going to | 164 # If the file does exist and we are using the subfolder flag we are going to |
165 # append another config. | 165 # append another config. |
166 if [ -n "${FLAGS_subfolder}" ] && \ | 166 if [ -n "${FLAGS_subfolder}" ] && \ |
167 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then | 167 [ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then |
168 # Remove the ']' from the last line of the file so we can add another config. | 168 # Remove the ']' from the last line of the file so we can add another config. |
169 sed -i '$d' ${OMAHA_DIR}/miniomaha.conf | 169 while [ true ] |
Hung-Te
2010/11/10 05:10:27
you don't need the []. Simply a "while true; do" w
| |
170 do | |
171 # If the last line is null | |
172 if [ -z `tail -1 ${OMAHA_DIR}/miniomaha.conf` ]; | |
Hung-Te
2010/11/10 05:10:27
Please use -z "$(tail -l "${OMAHA_DIR}/miniomaha.c
| |
173 then | |
174 sed '$d' < ${OMAHA_DIR}/miniomaha.conf > /tmp/tmp.txt | |
175 mv /tmp/tmp.txt ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/11/10 05:10:27
Please replace this by
sed -i '$d' "${OMAHA_DIR}/m
| |
176 else | |
177 # If the last line is some other character that is not ] then it is | |
178 # garbage and we don't need it | |
179 if [ `tail -1 ${OMAHA_DIR}/miniomaha.conf` != ']' ]; | |
180 then | |
Hung-Te
2010/11/10 05:10:27
"if []; then" is better.
| |
181 sed '$d' < ${OMAHA_DIR}/miniomaha.conf > /tmp/tmp.txt | |
182 mv /tmp/tmp.txt ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/11/10 05:10:27
Please replace sed+mv with "sed -i"
| |
183 else | |
184 # Otherwise it is the ] we are looking for | |
185 sed '$d' < ${OMAHA_DIR}/miniomaha.conf > /tmp/tmp.txt | |
186 mv /tmp/tmp.txt ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/11/10 05:10:27
Please replace sed+mv by "sed -i"
| |
187 break | |
188 fi | |
189 fi | |
190 # If the file is empty, add what we need and break | |
191 if [ ! -s ${OMAHA_DIR}/miniomaha.conf ]; | |
192 then | |
193 echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf | |
Hung-Te
2010/11/10 05:10:27
You don't need the "-e" since you don't have escap
| |
194 break | |
195 fi | |
196 done | |
170 else | 197 else |
171 echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf | 198 echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf |
172 fi | 199 fi |
173 | 200 |
174 if [ -n "${FLAGS_subfolder}" ] ; then | 201 if [ -n "${FLAGS_subfolder}" ] ; then |
175 subfolder="${FLAGS_subfolder}/" | 202 subfolder="${FLAGS_subfolder}/" |
176 fi | 203 fi |
177 | 204 |
178 echo -n "{ | 205 echo -n "{ |
179 'qual_ids': set([\"${FLAGS_board}\"]), | 206 'qual_ids': set([\"${FLAGS_board}\"]), |
(...skipping 18 matching lines...) Expand all Loading... | |
198 }, | 225 }, |
199 ] | 226 ] |
200 " >> ${OMAHA_DIR}/miniomaha.conf | 227 " >> ${OMAHA_DIR}/miniomaha.conf |
201 | 228 |
202 echo "The miniomaha server lives in src/platform/dev" | 229 echo "The miniomaha server lives in src/platform/dev" |
203 echo "to validate the configutarion, run:" | 230 echo "to validate the configutarion, run:" |
204 echo " python2.6 devserver.py --factory_config miniomaha.conf \ | 231 echo " python2.6 devserver.py --factory_config miniomaha.conf \ |
205 --validate_factory_config" | 232 --validate_factory_config" |
206 echo "To run the server:" | 233 echo "To run the server:" |
207 echo " python2.6 devserver.py --factory_config miniomaha.conf" | 234 echo " python2.6 devserver.py --factory_config miniomaha.conf" |
OLD | NEW |