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

Side by Side Diff: bin/cros_copy_upgrade_server.sh

Issue 2919009: Clean up command line arguments and user output (Closed) Base URL: ssh://gitrw.chromium.org/crosutils.git
Patch Set: Tiny whitespace corrections Created 10 years, 5 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/sh 1 #!/bin/sh
2 2
3 # Load common constants. This should be the first executable line. 3 # Load common constants. This should be the first executable line.
4 # The path to common.sh should be relative to your script's location. 4 # The path to common.sh should be relative to your script's location.
5 . "$(dirname "$0")/common.sh" 5 . "$(dirname "$0")/common.sh"
6 6
7 # Flags 7 # Flags
8 DEFINE_string upgrade_server "" "SSH-capable host for upgrade server install" 8 DEFINE_string upgrade_server "" "SSH-capable host for upgrade server install"
9 DEFINE_string dest_path "" "Directory on host to do install" 9 DEFINE_string dest_path "" "Directory on host to do install"
10 DEFINE_string client_address "" "IP Address of netbook to update" 10 DEFINE_string client_address "" "IP Address of netbook to update"
11 DEFINE_string server_address "" "IP Address of upgrade server" 11 DEFINE_string server_address "" "IP Address of upgrade server"
12 DEFINE_boolean start_server ${FLAGS_TRUE} "Start up the server" 12 DEFINE_boolean start_server ${FLAGS_TRUE} "Start up the server"
13 DEFINE_boolean stop_server ${FLAGS_FALSE} "Start up the server" 13 DEFINE_boolean stop_server ${FLAGS_FALSE} "Start up the server"
14 DEFINE_boolean no_copy_archive ${FLAGS_FALSE} "Skip copy of files to server"
14 DEFINE_string from "" "Image directory to upload to server" 15 DEFINE_string from "" "Image directory to upload to server"
15 16
16 # Parse command line 17 # Parse command line
17 FLAGS "$@" || exit 1 18 FLAGS "$@" || exit 1
18 eval set -- "${FLAGS_ARGV}" 19 eval set -- "${FLAGS_ARGV}"
19 20
20 set -e 21 set -e
21 22
22 # Make sure dev server argument has been set 23 # Make sure dev server argument has been set
23 require_upgrade_server () { 24 require_upgrade_server () {
24 if [ -z "${FLAGS_upgrade_server}" ] ; then 25 if [ -z "${FLAGS_upgrade_server}" ] ; then
25 echo "The --upgrade-server= argument is mandatory" 26 echo "The --upgrade-server= argument is mandatory"
26 exit 1 27 exit 1
27 fi 28 fi
28 } 29 }
29 30
30 # Make sure a pointer to the latest image has been created 31 # Make sure a pointer to the latest image has been created
31 require_latest_image () { 32 require_latest_image () {
32 [ -n "$latest_image" ] && return 33 [ -n "$latest_image" ] && return
33 if [ -n "${FLAGS_from}" ] ; then 34 if [ -n "${FLAGS_from}" ] ; then
34 latest_image=$(readlink -f ${FLAGS_from}) 35 latest_image=$(readlink -f ${FLAGS_from})
35 else 36 else
36 latest_image=$(env CHROMEOS_BUILD_ROOT=${SCRIPTS_DIR}/../build \ 37 latest_image=$(env CHROMEOS_BUILD_ROOT=${SCRIPTS_DIR}/../build \
37 » ${SCRIPTS_DIR}/get_latest_image.sh) 38 ${SCRIPTS_DIR}/get_latest_image.sh)
38 fi 39 fi
39 } 40 }
40 41
41 validate_devserver_path () { 42 validate_devserver_path () {
42 if [ $(expr "${FLAGS_dest_path}" : '\.\.') != 0 ]; then 43 if [ $(expr "${FLAGS_dest_path}" : '\.\.') != 0 ]; then
43 echo "Error: --dest_path argument (${FLAGS_dest_path}) must not be relative" 44 echo "Error: --dest_path argument (${FLAGS_dest_path}) must not be relative"
44 exit 1 45 exit 1
45 fi 46 fi
46 FLAGS_dest_path=/tmp/devserver/${FLAGS_dest_path##/tmp/devserver/} 47 FLAGS_dest_path=/tmp/devserver/${FLAGS_dest_path##/tmp/devserver/}
47 } 48 }
48 49
49 # Copy the various bits of the dev server scripts over to our remote host 50 # Copy the various bits of the dev server scripts over to our remote host
50 create_devserver () { 51 create_devserver () {
51 FLAGS_dest_path=$1 52 FLAGS_dest_path=$1
52 validate_devserver_path 53 validate_devserver_path
53 54
54 echo "Creating dev server in ${FLAGS_upgrade_server}:${FLAGS_dest_path}..." 55 echo "Creating dev server in ${FLAGS_upgrade_server}:${FLAGS_dest_path}..."
55 56
56 require_upgrade_server 57 require_upgrade_server
57 # Create new empty directory to hold server components 58 # Create new empty directory to hold server components
58 ssh "${FLAGS_upgrade_server}" rm -rf "${FLAGS_dest_path}" || true 59 ssh "${FLAGS_upgrade_server}" rm -rf "${FLAGS_dest_path}" || true
59 ssh "${FLAGS_upgrade_server}" mkdir -p "${FLAGS_dest_path}/python" 60 ssh "${FLAGS_upgrade_server}" mkdir -p "${FLAGS_dest_path}/python"
60 61
61 # Copy server components into place 62 # Copy server components into place
62 (cd ${SCRIPTS_DIR}/../.. && \ 63 (cd ${SCRIPTS_DIR}/../.. && \
63 tar zcf - --exclude=.git --exclude=.svn \ 64 tar zcf - --exclude=.git --exclude=.svn \
64 src/scripts/start_devserver \ 65 src/scripts/start_devserver \
65 src/scripts/{common,get_latest_image,mk_memento_images}.sh \ 66 src/scripts/{common,get_latest_image,mk_memento_images}.sh \
(...skipping 30 matching lines...) Expand all
96 # Since we are in static-only mode, we need to create a few links 97 # Since we are in static-only mode, we need to create a few links
97 for file in update.gz stateful.image.gz ; do 98 for file in update.gz stateful.image.gz ; do
98 ssh ${FLAGS_upgrade_server} "cd ${archive_dir} && ln -sf ${image_path}/$file ." 99 ssh ${FLAGS_upgrade_server} "cd ${archive_dir} && ln -sf ${image_path}/$file ."
99 ssh ${FLAGS_upgrade_server} "ln -sf ${archive_dir}/$file ${FLAGS_dest_path}/ src/platform/dev/static" 100 ssh ${FLAGS_upgrade_server} "ln -sf ${archive_dir}/$file ${FLAGS_dest_path}/ src/platform/dev/static"
100 done 101 done
101 } 102 }
102 103
103 stop_server () { 104 stop_server () {
104 require_upgrade_server 105 require_upgrade_server
105 echo "Stopping remote devserver..." 106 echo "Stopping remote devserver..."
106 echo "(Fast restart using \"$0 --upgrade_server=${FLAGS_upgrade_server} --dest _path=${FLAGS_dest_path} --archive_dir=${archive_dir}\")" 107 echo "(Fast restart using \"$0 --upgrade_server=${FLAGS_upgrade_server} --dest _path=${FLAGS_dest_path} --no_copy_archive\")"
107 ssh ${FLAGS_upgrade_server} pkill -f ${archive_dir} || /bin/true 108 ssh ${FLAGS_upgrade_server} pkill -f ${archive_dir} || /bin/true
108 } 109 }
109 110
110 # Start remote server 111 # Start remote server
111 start_server () { 112 start_server () {
112 require_upgrade_server 113 require_upgrade_server
113 echo "Starting remote devserver..." 114 echo "Starting remote devserver..."
114 server_logfile=/tmp/devserver_log.$$ 115 server_logfile=/tmp/devserver_log.$$
115 portlist=/tmp/devserver_portlist.$$ 116 portlist=/tmp/devserver_portlist.$$
116 echo "Server will be logging locally to $server_logfile" 117 echo "Server will be logging locally to $server_logfile"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 require_latest_image 154 require_latest_image
154 hostname=$(uname -n) 155 hostname=$(uname -n)
155 hostname=${hostname%%.*} 156 hostname=${hostname%%.*}
156 image_name=${latest_image##*/} 157 image_name=${latest_image##*/}
157 create_devserver ${hostname}_${image_name} 158 create_devserver ${hostname}_${image_name}
158 FLAGS_start_server=${FLAGS_TRUE} 159 FLAGS_start_server=${FLAGS_TRUE}
159 else 160 else
160 validate_devserver_path 161 validate_devserver_path
161 fi 162 fi
162 163
163 if [ ${FLAGS_stop_server} -eq ${FLAGS_FALSE} ] ; then 164 if [ ${FLAGS_stop_server} -eq ${FLAGS_FALSE} -a \
165 ${FLAGS_no_copy_archive} -eq ${FLAGS_FALSE} ] ; then
164 create_archive_dir "${FLAGS_dest_path}/archive" 166 create_archive_dir "${FLAGS_dest_path}/archive"
165 FLAGS_start_server=${FLAGS_TRUE} 167 FLAGS_start_server=${FLAGS_TRUE}
166 else 168 else
167 archive_dir="${FLAGS_dest_path}/archive" 169 archive_dir="${FLAGS_dest_path}/archive"
168 fi 170 fi
169 171
170 if [ "${FLAGS_stop_server}" -eq ${FLAGS_TRUE} ] ; then 172 if [ "${FLAGS_stop_server}" -eq ${FLAGS_TRUE} ] ; then
171 stop_server 173 stop_server
172 exit 0 174 exit 0
173 fi 175 fi
174 176
175 # Make sure old devserver is dead, then restart it 177 # Make sure old devserver is dead, then restart it
176 if [ "${FLAGS_start_server}" -eq ${FLAGS_TRUE} ] ; then 178 if [ "${FLAGS_start_server}" -eq ${FLAGS_TRUE} ] ; then
177 stop_server 179 stop_server
178 start_server 180 start_server
179 181
180 tail -f ${server_logfile} & 182 tail -f ${server_logfile} &
181 183
182 # Now tell the client to load from the server 184 # Now tell the client to load from the server
185 if [ -z "${FLAGS_server_address}" ] ; then
186 FLAGS_server_address=${FLAGS_upgrade_server}
187 fi
188 live_args="--update_url=http://${FLAGS_server_address}:${server_port}/update \
189 --remote=${FLAGS_client_address}"
183 if [ -n "${FLAGS_client_address}" ] ; then 190 if [ -n "${FLAGS_client_address}" ] ; then
184 if [ -z "${FLAGS_server_address}" ] ; then
185 FLAGS_server_address=${FLAGS_upgrade_server}
186 fi
187 live_args="--update_url=http://${FLAGS_server_address}:${server_port}/update \
188 --remote=${FLAGS_client_address}"
189 echo "Running ${SCRIPTS_DIR}/image_to_live.sh $live_args" 191 echo "Running ${SCRIPTS_DIR}/image_to_live.sh $live_args"
190 ${SCRIPTS_DIR}/image_to_live.sh $live_args & 192 ${SCRIPTS_DIR}/image_to_live.sh $live_args &
193 else
194 echo "Start client upgrade using:"
195 echo " ${SCRIPTS_DIR}/image_to_live.sh ${live_args}<client_ip_address>"
191 fi 196 fi
192 197
193 wait ${server_pid} 198 wait ${server_pid}
194 fi 199 fi
195 200
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