Statistics
| Branch: | Tag: | Revision:

root / tools / xen-console-wrapper @ 4fe43605

History | View | Annotate | Download (1.4 kB)

1 61631293 Stephen Shirley
#!/bin/bash
2 f299ca21 Michael Hanselmann
#
3 61631293 Stephen Shirley
4 61631293 Stephen Shirley
# Copyright (C) 2011 Google Inc.
5 61631293 Stephen Shirley
#
6 61631293 Stephen Shirley
# This program is free software; you can redistribute it and/or modify
7 61631293 Stephen Shirley
# it under the terms of the GNU General Public License as published by
8 61631293 Stephen Shirley
# the Free Software Foundation; either version 2 of the License, or
9 61631293 Stephen Shirley
# (at your option) any later version.
10 61631293 Stephen Shirley
#
11 61631293 Stephen Shirley
# This program is distributed in the hope that it will be useful, but
12 61631293 Stephen Shirley
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 61631293 Stephen Shirley
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 61631293 Stephen Shirley
# General Public License for more details.
15 61631293 Stephen Shirley
#
16 61631293 Stephen Shirley
# You should have received a copy of the GNU General Public License
17 61631293 Stephen Shirley
# along with this program; if not, write to the Free Software
18 61631293 Stephen Shirley
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 61631293 Stephen Shirley
# 02110-1301, USA.
20 61631293 Stephen Shirley
21 1f5557ca Guido Trotter
XEN_CMD="$1"
22 1f5557ca Guido Trotter
INSTANCE="$2"
23 61631293 Stephen Shirley
24 61631293 Stephen Shirley
unpause() {
25 61631293 Stephen Shirley
  ispaused=$(xm list -l "$INSTANCE" 2>/dev/null |
26 61631293 Stephen Shirley
             sed -n 's/^[[:blank:]]*(state ..\(.\)...)/\1/p')
27 61631293 Stephen Shirley
  [[ "$ispaused" == "p" ]] || return
28 61631293 Stephen Shirley
  # As there is no way to be sure when xm console has actually connected to the
29 61631293 Stephen Shirley
  # instance, sleep for a few seconds before unpausing the instance. This is a
30 61631293 Stephen Shirley
  # tradeoff between missing some console output if the node is overloaded and
31 61631293 Stephen Shirley
  # making the user wait everytime when the node isn't so busy.
32 61631293 Stephen Shirley
  sleep 3
33 61631293 Stephen Shirley
  # Send \r\n after notice as terminal is in raw mode
34 61631293 Stephen Shirley
  printf "Instance $INSTANCE is paused, unpausing\r\n"
35 61631293 Stephen Shirley
  xm unpause "$INSTANCE"
36 61631293 Stephen Shirley
}
37 61631293 Stephen Shirley
38 61631293 Stephen Shirley
unpause &
39 1f5557ca Guido Trotter
exec $XEN_CMD console "$INSTANCE"