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

Side by Side Diff: src/platform/memento_softwareupdate/memento_updater.sh

Issue 503088: add -f option to force a client update (Closed)
Patch Set: Created 10 years, 12 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 | « src/platform/dev/autoupdate.py ('k') | 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 # This is the autoupdater for Memento. When called it consults Omaha to see 7 # This is the autoupdater for Memento. When called it consults Omaha to see
8 # if there's an update available. If so, it downloads it to the other 8 # if there's an update available. If so, it downloads it to the other
9 # partition on the Memento USB stick, then alters the MBR and partitions 9 # partition on the Memento USB stick, then alters the MBR and partitions
10 # as needed so the next reboot will boot into the newly installed partition. 10 # as needed so the next reboot will boot into the newly installed partition.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 true 51 true
52 else 52 else
53 log "Failed to acquire lockfile: $PID_FILE." 53 log "Failed to acquire lockfile: $PID_FILE."
54 log "Held by $(cat $PID_FILE)" 54 log "Held by $(cat $PID_FILE)"
55 exit 1 55 exit 1
56 fi 56 fi
57 # remove lockfile when we exit 57 # remove lockfile when we exit
58 trap 'rm -f "$PID_FILE"; log Memento AutoUpdate terminating; exit $?' \ 58 trap 'rm -f "$PID_FILE"; log Memento AutoUpdate terminating; exit $?' \
59 INT TERM EXIT 59 INT TERM EXIT
60 60
61 if [ x$1 = "x-f" ]; then
62 log "Forced update requested"
63 ForceUpdate="yes"
64 shift
65 fi
66
61 log Memento AutoUpdate starting 67 log Memento AutoUpdate starting
62 68
63 # Get local version 69 # Get local version
64 APP_VERSION=$(grep ^CHROMEOS_RELEASE_VERSION \ 70 APP_VERSION=$(grep ^CHROMEOS_RELEASE_VERSION \
65 /mnt/stateful_partition/etc/lsb-release | \ 71 /mnt/stateful_partition/etc/lsb-release | \
66 cut -d = -f 2-) 72 cut -d = -f 2-)
67 if [ "x" = "x$APP_VERSION" ] 73 if [ "x" = "x$APP_VERSION" ]
68 then 74 then
69 # look in the main file 75 # look in the main file
70 APP_VERSION=$(grep ^CHROMEOS_RELEASE_VERSION \ 76 APP_VERSION=$(grep ^CHROMEOS_RELEASE_VERSION \
71 /etc/lsb-release | cut -d = -f 2-) 77 /etc/lsb-release | cut -d = -f 2-)
72 fi 78 fi
73 79
74 # See if we're forcing an update from a specific URL 80 # See if we're forcing an update from a specific URL
75 if [ "x" = "x$1" ] 81 if [ "x" = "x$1" ]
76 then 82 then
77 # abort if autoupdates have been disabled, but only when an update image 83 # abort if autoupdates have been disabled, but only when an update image
78 # isn't forced 84 # isn't forced
79 UPDATES_DISABLED_FILE="/var/local/disable_software_update" 85 UPDATES_DISABLED_FILE="/var/local/disable_software_update"
80 if [ -f "$UPDATES_DISABLED_FILE" ] 86 if [ -f "$UPDATES_DISABLED_FILE" ]
81 then 87 then
82 log Updates disabled. Aborting. 88 log Updates disabled. Aborting.
83 exit 0 89 exit 0
84 fi 90 fi
85 91
86 # check w/ omaha to see if there's an update 92 # check w/ omaha to see if there's an update
87 OMAHA_CHECK_OUTPUT=$(`dirname "$0"`/ping_omaha.sh $APP_VERSION) 93 if [ "$ForceUpdate" = "yes" ]; then
94 OMAHA_CHECK_OUTPUT=$(`dirname "$0"`/ping_omaha.sh "ForcedUpdate")
95 else
96 OMAHA_CHECK_OUTPUT=$(`dirname "$0"`/ping_omaha.sh $APP_VERSION)
97 fi
88 IMG_URL=$(echo "$OMAHA_CHECK_OUTPUT" | grep '^URL=' | cut -d = -f 2-) 98 IMG_URL=$(echo "$OMAHA_CHECK_OUTPUT" | grep '^URL=' | cut -d = -f 2-)
89 CHECKSUM=$(echo "$OMAHA_CHECK_OUTPUT" | grep '^HASH=' | cut -d = -f 2-) 99 CHECKSUM=$(echo "$OMAHA_CHECK_OUTPUT" | grep '^HASH=' | cut -d = -f 2-)
90 else 100 else
91 log User forced an update from: "$1" checksum: "$2" 101 log User forced an update from: "$1" checksum: "$2"
92 IMG_URL="$1" 102 IMG_URL="$1"
93 CHECKSUM="$2" 103 CHECKSUM="$2"
94 fi 104 fi
95 105
96 if [[ -z "$IMG_URL" || -z "$CHECKSUM" ]] 106 if [[ -z "$IMG_URL" || -z "$CHECKSUM" ]]
97 then 107 then
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 NEW_VERSION=$(grep ^GOOGLE_RELEASE "$MOUNTPOINT"/etc/lsb-release | \ 227 NEW_VERSION=$(grep ^GOOGLE_RELEASE "$MOUNTPOINT"/etc/lsb-release | \
218 cut -d = -f 2-) 228 cut -d = -f 2-)
219 if [ "x$NEW_VERSION" = "x" ] 229 if [ "x$NEW_VERSION" = "x" ]
220 then 230 then
221 log "Can't find new version number. aborting update" 231 log "Can't find new version number. aborting update"
222 umount "$MOUNTPOINT" 232 umount "$MOUNTPOINT"
223 rmdir "$MOUNTPOINT" 233 rmdir "$MOUNTPOINT"
224 exit 1 234 exit 1
225 else 235 else
226 # See if it's newer than us 236 # See if it's newer than us
227 if version_number_greater_than "$APP_VERSION" "$NEW_VERSION" 237 if [ "$ForceUpdate" != "yes" ] &&
238 version_number_greater_than "$APP_VERSION" "$NEW_VERSION"
228 then 239 then
229 log "Can't upgrade to older version: " "$NEW_VERSION" 240 log "Can't upgrade to older version: " "$NEW_VERSION"
230 umount "$MOUNTPOINT" 241 umount "$MOUNTPOINT"
231 rmdir "$MOUNTPOINT" 242 rmdir "$MOUNTPOINT"
232 exit 1 243 exit 1
233 fi 244 fi
234 fi 245 fi
235 246
236 "$MOUNTPOINT"/postinst "$INSTALL_DEV" 2>&1 | cat >> "$MEMENTO_AU_LOG"; \ 247 "$MOUNTPOINT"/postinst "$INSTALL_DEV" 2>&1 | cat >> "$MEMENTO_AU_LOG"; \
237 [ "${PIPESTATUS[*]}" = "0 0" ] 248 [ "${PIPESTATUS[*]}" = "0 0" ]
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 -e "s/\(${LOCAL_DEV//\//\\/} .*\), bootable/\1/" \ 283 -e "s/\(${LOCAL_DEV//\//\\/} .*\), bootable/\1/" \
273 > "$LAYOUT_FILE" 284 > "$LAYOUT_FILE"
274 sfdisk --force $ROOT_DEV < "$LAYOUT_FILE" 2>&1 | cat >> "$MEMENTO_AU_LOG" 285 sfdisk --force $ROOT_DEV < "$LAYOUT_FILE" 2>&1 | cat >> "$MEMENTO_AU_LOG"
275 abort_update_if_cmd_failed 286 abort_update_if_cmd_failed
276 287
277 # mark update as complete so we don't try to update again 288 # mark update as complete so we don't try to update again
278 touch "$UPDATED_COMPLETED_FILE" 289 touch "$UPDATED_COMPLETED_FILE"
279 290
280 # tell user to reboot 291 # tell user to reboot
281 log Autoupdate applied. You should now reboot 292 log Autoupdate applied. You should now reboot
OLDNEW
« no previous file with comments | « src/platform/dev/autoupdate.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698