Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: src/scripts/image_to_live.sh

Issue 1572034: Refine image_to_live script to log all output from devserver. (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 update an image onto a live running ChromiumOS instance. 7 # Script to update an image onto a live running ChromiumOS instance.
8 8
9 # Load common constants. This should be the first executable line. 9 # Load common constants. This should be the first executable line.
10 # The path to common.sh should be relative to your script's location. 10 # The path to common.sh should be relative to your script's location.
11 11
12 . "$(dirname $0)/common.sh" 12 . "$(dirname $0)/common.sh"
13 . "$(dirname $0)/remote_access.sh" 13 . "$(dirname $0)/remote_access.sh"
14 14
15 DEFINE_boolean ignore_version ${FLAGS_TRUE} \ 15 DEFINE_boolean ignore_version ${FLAGS_TRUE} \
16 "Ignore existing version on running instance and always update" 16 "Ignore existing version on running instance and always update"
17 DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \ 17 DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \
18 "Ignore existing AU hostname on running instance use this hostname" 18 "Ignore existing AU hostname on running instance use this hostname"
19 DEFINE_boolean update_known_hosts ${FLAGS_FALSE} \ 19 DEFINE_boolean update_known_hosts ${FLAGS_FALSE} \
20 "Update your known_hosts with the new remote instance's key" 20 "Update your known_hosts with the new remote instance's key"
21 DEFINE_boolean verbose ${FLAGS_FALSE} \
22 "Whether to output verbose information for debugging."
21 23
22 function kill_all_devservers { 24 function kill_all_devservers {
23 # Using ! here to avoid exiting with set -e is insufficient, so use 25 # Using ! here to avoid exiting with set -e is insufficient, so use
24 # || true instead. 26 # || true instead.
25 pkill -fx ".*devserver\.py" || true 27 pkill -fx ".*devserver\.py" || true
26 } 28 }
27 29
28 function cleanup { 30 function cleanup {
29 echo "Killing dev server." 31 echo "Killing dev server."
30 kill_all_devservers 32 kill_all_devservers
31 rm -rf "${TMP}" 33 rm -rf "${TMP}"
32 } 34 }
33 35
34 function remote_reboot_sh { 36 function remote_reboot_sh {
35 rm -f "${TMP_KNOWN_HOSTS}" 37 rm -f "${TMP_KNOWN_HOSTS}"
36 remote_sh "$@" 38 remote_sh "$@"
37 } 39 }
38 40
39 function start_dev_server { 41 function start_dev_server {
40 kill_all_devservers 42 kill_all_devservers
41 ./enter_chroot.sh "./start_devserver > /dev/null 2>&1" & 43 if [ ${FLAGS_verbose} -eq ${FLAGS_FALSE} ]; then
44 ./enter_chroot.sh "./start_devserver > /dev/null 2>&1" &
45 else
46 ./enter_chroot.sh "./start_devserver" &
47 fi
42 echo -n "Waiting on devserver to start" 48 echo -n "Waiting on devserver to start"
43 until netstat -anp 2>&1 | grep 8080 > /dev/null; do 49 until netstat -anp 2>&1 | grep 8080 > /dev/null; do
44 sleep .5 50 sleep .5
45 echo -n "." 51 echo -n "."
46 done 52 done
47 echo "" 53 echo ""
48 } 54 }
49 55
50 function prepare_update_metadata { 56 function prepare_update_metadata {
51 remote_sh "mount -norw,remount /" 57 remote_sh "mount -norw,remount /"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 remote_reboot 168 remote_reboot
163 exit 1 169 exit 1
164 fi 170 fi
165 171
166 start_dev_server 172 start_dev_server
167 173
168 prepare_update_metadata 174 prepare_update_metadata
169 175
170 if ! run_auto_update; then 176 if ! run_auto_update; then
171 echo "Update was not successful." 177 echo "Update was not successful."
172 exit 178 exit 1
173 fi 179 fi
174 180
175 remote_reboot 181 remote_reboot
176 182
177 if [[ ${FLAGS_update_hostkey} -eq ${FLAGS_TRUE} ]]; then 183 if [[ ${FLAGS_update_hostkey} -eq ${FLAGS_TRUE} ]]; then
178 local known_hosts="${HOME}/.ssh/known_hosts" 184 local known_hosts="${HOME}/.ssh/known_hosts"
179 cp "${known_hosts}" "${known_hosts}~" 185 cp "${known_hosts}" "${known_hosts}~"
180 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" 186 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts"
181 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" 187 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}"
182 chmod 0640 "${known_hosts}" 188 chmod 0640 "${known_hosts}"
183 echo "New updated in ${known_hosts}, backup made." 189 echo "New updated in ${known_hosts}, backup made."
184 fi 190 fi
185 191
186 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" 192 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release"
187 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) 193 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2)
188 echo "Update was successful and rebooted to $release_description" 194 echo "Update was successful and rebooted to $release_description"
189 195
190 return 0 196 return 0
191 } 197 }
192 198
193 main $@ 199 main $@
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698