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 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} \ | 21 DEFINE_boolean verbose ${FLAGS_FALSE} \ |
22 "Whether to output verbose information for debugging." | 22 "Whether to output verbose information for debugging." |
23 DEFINE_integer devserver_port 8080 \ | 23 DEFINE_integer devserver_port 8080 \ |
24 "Port to use for devserver" | 24 "Port to use for devserver" |
25 DEFINE_string update_url "" "Full url of an update image" | |
25 | 26 |
26 function kill_all_devservers { | 27 function kill_all_devservers { |
27 # Using ! here to avoid exiting with set -e is insufficient, so use | 28 # Using ! here to avoid exiting with set -e is insufficient, so use |
28 # || true instead. | 29 # || true instead. |
29 sudo pkill -f devserver\.py || true | 30 sudo pkill -f devserver\.py || true |
30 } | 31 } |
31 | 32 |
32 function cleanup { | 33 function cleanup { |
33 echo "Killing dev server." | 34 echo "Killing dev server." |
34 kill_all_devservers | 35 kill_all_devservers |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 76 |
76 if [[ ${FLAGS_ignore_version} -eq ${FLAGS_TRUE} ]]; then | 77 if [[ ${FLAGS_ignore_version} -eq ${FLAGS_TRUE} ]]; then |
77 echo "Forcing update independent of the current version" | 78 echo "Forcing update independent of the current version" |
78 remote_sh "cat /etc/lsb-release |\ | 79 remote_sh "cat /etc/lsb-release |\ |
79 grep -v CHROMEOS_RELEASE_VERSION > /etc/lsb-release~;\ | 80 grep -v CHROMEOS_RELEASE_VERSION > /etc/lsb-release~;\ |
80 mv /etc/lsb-release~ /etc/lsb-release; \ | 81 mv /etc/lsb-release~ /etc/lsb-release; \ |
81 echo 'CHROMEOS_RELEASE_VERSION=0.0.0.0' >> /etc/lsb-release" | 82 echo 'CHROMEOS_RELEASE_VERSION=0.0.0.0' >> /etc/lsb-release" |
82 fi | 83 fi |
83 | 84 |
84 if [ ${FLAGS_ignore_hostname} -eq ${FLAGS_TRUE} ]; then | 85 if [ ${FLAGS_ignore_hostname} -eq ${FLAGS_TRUE} ]; then |
85 devserver_url="http://$HOSTNAME:${FLAGS_devserver_port}" | 86 if [ -z ${FLAGS_update_url} ]; then |
87 devserver_url="http://$HOSTNAME:${FLAGS_devserver_port}/update" | |
88 else | |
89 devserver_url="${FLAGS_update_url}" | |
90 fi | |
86 echo "Forcing update from ${devserver_url}" | 91 echo "Forcing update from ${devserver_url}" |
87 remote_sh "cat /etc/lsb-release |\ | 92 remote_sh "cat /etc/lsb-release |\ |
88 grep -v '^CHROMEOS_AUSERVER=' |\ | 93 grep -v '^CHROMEOS_AUSERVER=' |\ |
89 grep -v '^CHROMEOS_DEVSERVER=' > /etc/lsb-release~;\ | 94 grep -v '^CHROMEOS_DEVSERVER=' > /etc/lsb-release~;\ |
90 mv /etc/lsb-release~ /etc/lsb-release; \ | 95 mv /etc/lsb-release~ /etc/lsb-release; \ |
91 echo 'CHROMEOS_AUSERVER=${devserver_url}/update' >> \ | 96 echo 'CHROMEOS_AUSERVER=${devserver_url}' >> \ |
seano
2010/05/12 17:17:42
You don't need to do this, memento_updater.sh acce
ericli
2010/05/12 17:57:08
I guess the problem is the stateful partition upda
| |
92 /etc/lsb-release; \ | 97 /etc/lsb-release; \ |
93 echo 'CHROMEOS_DEVSERVER=${devserver_url}' >> /etc/lsb-release" | 98 echo 'CHROMEOS_DEVSERVER=${devserver_url}' >> /etc/lsb-release" |
94 fi | 99 fi |
95 } | 100 } |
96 | 101 |
97 function run_auto_update { | 102 function run_auto_update { |
98 echo "Starting update" | 103 echo "Starting update" |
99 local update_file=/var/log/softwareupdate.log | 104 local update_file=/var/log/softwareupdate.log |
100 # Clear it out so we don't see a prior run and make sure it | 105 # Clear it out so we don't see a prior run and make sure it |
101 # exists so the first tail below can't fail if it races the | 106 # exists so the first tail below can't fail if it races the |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 | 187 |
183 remote_access_init | 188 remote_access_init |
184 | 189 |
185 if remote_sh [ -e /tmp/memento_autoupdate_completed ]; then | 190 if remote_sh [ -e /tmp/memento_autoupdate_completed ]; then |
186 echo "Machine has been updated but not yet rebooted. Rebooting it now." | 191 echo "Machine has been updated but not yet rebooted. Rebooting it now." |
187 echo "Rerun this script if you still wish to update it." | 192 echo "Rerun this script if you still wish to update it." |
188 remote_reboot | 193 remote_reboot |
189 exit 1 | 194 exit 1 |
190 fi | 195 fi |
191 | 196 |
192 start_dev_server | 197 if [ -z "${FLAGS_update_url}" ]; then |
198 # only start local devserver if no update url specified. | |
199 start_dev_server | |
200 fi | |
193 | 201 |
194 prepare_update_metadata | 202 prepare_update_metadata |
195 | 203 |
196 if ! run_auto_update; then | 204 if ! run_auto_update; then |
197 echo "Update was not successful." | 205 echo "Update was not successful." |
198 exit 1 | 206 exit 1 |
199 fi | 207 fi |
200 | 208 |
201 if ! copy_stateful_update; then | 209 if ! copy_stateful_update; then |
202 echo "Stateful update was not successful." | 210 echo "Stateful update was not successful." |
(...skipping 11 matching lines...) Expand all Loading... | |
214 fi | 222 fi |
215 | 223 |
216 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" | 224 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" |
217 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) | 225 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) |
218 echo "Update was successful and rebooted to $release_description" | 226 echo "Update was successful and rebooted to $release_description" |
219 | 227 |
220 return 0 | 228 return 0 |
221 } | 229 } |
222 | 230 |
223 main $@ | 231 main $@ |
OLD | NEW |