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 | 21 |
22 function kill_all_devservers { | 22 function kill_all_devservers { |
23 # Using ! here to avoid exiting with set -e is insufficient, so use | 23 # Using ! here to avoid exiting with set -e is insufficient, so use |
24 # || true instead. | 24 # || true instead. |
25 pkill -f 'python devserver.py' || true | 25 pkill -fx ".*devserver\.py" || true |
26 } | 26 } |
27 | 27 |
28 function cleanup { | 28 function cleanup { |
| 29 echo "Killing dev server." |
29 kill_all_devservers | 30 kill_all_devservers |
30 rm -rf "${TMP}" | 31 rm -rf "${TMP}" |
31 } | 32 } |
32 | 33 |
33 function remote_reboot_sh { | 34 function remote_reboot_sh { |
34 rm -f "${TMP_KNOWN_HOSTS}" | 35 rm -f "${TMP_KNOWN_HOSTS}" |
35 remote_sh "$@" | 36 remote_sh "$@" |
36 } | 37 } |
37 | 38 |
38 function start_dev_server { | 39 function start_dev_server { |
39 kill_all_devservers | 40 kill_all_devservers |
40 sudo -v | |
41 ./enter_chroot.sh "cd ../platform/dev; ./start-devserver.sh>/dev/null 2>&1" & | 41 ./enter_chroot.sh "cd ../platform/dev; ./start-devserver.sh>/dev/null 2>&1" & |
42 echo -n "Waiting on devserver to start" | 42 echo -n "Waiting on devserver to start" |
43 until netstat -anp 2>&1 | grep 8080 > /dev/null; do | 43 until netstat -anp 2>&1 | grep 8080 > /dev/null; do |
44 sleep .5 | 44 sleep .5 |
45 echo -n "." | 45 echo -n "." |
46 done | 46 done |
47 echo "" | 47 echo "" |
48 } | 48 } |
49 | 49 |
50 function prepare_update_metadata { | 50 function prepare_update_metadata { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 then | 104 then |
105 echo "Autoupdate was successful." | 105 echo "Autoupdate was successful." |
106 update_error=0 | 106 update_error=0 |
107 fi | 107 fi |
108 if grep -q 'Memento AutoUpdate terminating' "${output_file}"; then | 108 if grep -q 'Memento AutoUpdate terminating' "${output_file}"; then |
109 break | 109 break |
110 fi | 110 fi |
111 # Sleep for a while so that ssh handling doesn't slow down the install | 111 # Sleep for a while so that ssh handling doesn't slow down the install |
112 sleep 2 | 112 sleep 2 |
113 done | 113 done |
114 | 114 |
115 return ${update_error} | 115 return ${update_error} |
116 } | 116 } |
117 | 117 |
118 function remote_reboot { | 118 function remote_reboot { |
119 echo "Rebooting." | 119 echo "Rebooting." |
120 remote_sh "touch /tmp/awaiting_reboot; reboot" | 120 remote_sh "touch /tmp/awaiting_reboot; reboot" |
121 local output_file | 121 local output_file |
122 output_file="${TMP}/output" | 122 output_file="${TMP}/output" |
123 | 123 |
124 while true; do | 124 while true; do |
125 REMOTE_OUT="" | 125 REMOTE_OUT="" |
126 # This may fail while the machine is done so generate output and a | 126 # This may fail while the machine is down so generate output and a |
127 # boolean result to distinguish between down/timeout and real failure | 127 # boolean result to distinguish between down/timeout and real failure |
128 ! remote_sh_allow_changed_host_key \ | 128 ! remote_sh_allow_changed_host_key \ |
129 "echo 0; [ -e /tmp/awaiting_reboot ] && echo '1'; true" | 129 "echo 0; [ -e /tmp/awaiting_reboot ] && echo '1'; true" |
130 echo "${REMOTE_OUT}" > "${output_file}" | 130 echo "${REMOTE_OUT}" > "${output_file}" |
131 if grep -q "0" "${output_file}"; then | 131 if grep -q "0" "${output_file}"; then |
132 if grep -q "1" "${output_file}"; then | 132 if grep -q "1" "${output_file}"; then |
133 echo "Not yet rebooted" | 133 echo "Not yet rebooted" |
134 else | 134 else |
135 echo "Rebooted and responding" | 135 echo "Rebooted and responding" |
136 break | 136 break |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 cp "${known_hosts}" "${known_hosts}~" | 179 cp "${known_hosts}" "${known_hosts}~" |
180 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" | 180 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" |
181 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" | 181 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" |
182 chmod 0640 "${known_hosts}" | 182 chmod 0640 "${known_hosts}" |
183 echo "New updated in ${known_hosts}, backup made." | 183 echo "New updated in ${known_hosts}, backup made." |
184 fi | 184 fi |
185 | 185 |
186 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" | 186 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" |
187 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) | 187 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) |
188 echo "Update was successful and rebooted to $release_description" | 188 echo "Update was successful and rebooted to $release_description" |
189 | 189 |
190 return 0 | 190 return 0 |
191 } | 191 } |
192 | 192 |
193 main $@ | 193 main $@ |
OLD | NEW |