Commit 4e1471fc authored by jamiewalch@google.com's avatar jamiewalch@google.com

Handle updates to the wrapper script.

BUG=139919

Review URL: https://chromiumcodereview.appspot.com/10860024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152402 0039d316-1c4b-4281-b951-d872f2087c98
parent 4b68c12a
......@@ -15,14 +15,12 @@ SHARE = $(DESTDIR)/usr/share/chrome-remote-desktop
all:
# TODO(lambroslambrou): Decide what to do about bundling Xvfb-randr.
# For now, treat it as if it were a build artifact from the Chrome tree, and
# pull it from $(RELEASE).
install:
install -d $(BIN) $(LIB) $(SHARE)
install $(TOOLS)/me2me_virtual_host.py -m 0755 \
$(BIN)/me2me_virtual_host
install $(TOOLS)/gaia_auth.py -m 0644 $(SHARE)
install $(TOOLS)/keygen.py -m 0644 $(SHARE)
install $(TOOLS)/is_me2me_desktop $(LIB)
install $(RELEASE)/remoting_host_keygen -m 0755 $(LIB)
install $(RELEASE)/remoting_me2me_host -m 0755 $(LIB)
......@@ -12,7 +12,7 @@ Homepage: https://chrome.google.com/remotedesktop
Package: chrome-remote-desktop
Architecture: any
Depends: xvfb-randr, python (>= 2.6), ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
Depends: xvfb-randr, python (>= 2.6), update-notifier, ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
Suggests: google-chrome-stable | google-chrome-beta | google-chrome-unstable
Description: Access your computer securely over the Internet.
Chrome Remote Desktop allows you to securely access your computer remotely
......
#!/bin/bash
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
case $1 in
LOGOUT_MSG="
Name: Please log out to update
Priority: Medium
OnlyAdminUsers: False
DontShowAfterReboot: true
DisplayIf: /usr/lib/chrome-remote-desktop/is_me2me_desktop
Description: Chrome Remote Desktop has been updated. Please save your work and log out in order to apply this update. Your virtual desktop will be restarted automatically.
"
NOTIFIER_DIR="/var/lib/update-notifier/user.d"
VAR_DIR="/var/lib/chrome-remote-desktop"
HASHES_FILE="$VAR_DIR/hashes"
case "$1" in
"configure")
# Kill me2me host processes. The wrapper script will restart them.
echo "Shutting down remoting hosts (they will restart automatically)..."
killall -q remoting_me2me_host || true
# If any files have changed that require the user to restart their virtual
# desktops (eg, the wrapper script itself) then notify them but don't do
# anything that would result in them losing state.
if [ -f "$HASHES_FILE" ]; then
if [ -d "$NOTIFIER_DIR" ]; then
if ! md5sum --status -c "$HASHES_FILE"; then
echo "Sending logout notification messages to virtual desktops."
echo "$LOGOUT_MSG" > "$NOTIFIER_DIR/chrome-remote-desktop-logout"
fi
fi
rm "$HASHES_FILE"
rmdir --ignore-fail-on-non-empty "$VAR_DIR"
fi
;;
esac
......
#!/bin/bash
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
VAR_DIR="/var/lib/chrome-remote-desktop"
HASHES_FILE="$VAR_DIR/hashes"
save_hash() {
if [ -f "$1" ]; then
mkdir -p "$VAR_DIR"
md5sum "$1" >> "$HASHES_FILE"
fi
}
case "$1" in
"install" | "upgrade")
rm -f "$HASHES_FILE"
save_hash /usr/bin/me2me_virtual_host
;;
esac
#DEBHELPER#
#!/bin/bash
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Test whether or not the current desktop is virtual Me2Me.
[ -n "$REMOTING_ME2ME_SESSION" ]
......@@ -634,16 +634,20 @@ def daemonize(log_filename):
def cleanup():
logging.info("Cleanup.")
global g_pidfile
if g_pidfile:
try:
g_pidfile.delete_file()
g_pidfile = None
except Exception, e:
logging.error("Unexpected error deleting PID file: " + str(e))
global g_desktops
for desktop in g_desktops:
if desktop.x_proc:
logging.info("Terminating Xvfb")
desktop.x_proc.terminate()
g_desktops = []
def reload_config():
......@@ -661,6 +665,11 @@ def signal_handler(signum, stackframe):
raise SystemExit
def relaunch_self():
cleanup()
os.execvp(sys.argv[0], sys.argv)
def main():
DEFAULT_SIZE = "1280x800"
parser = optparse.OptionParser(
......@@ -871,32 +880,35 @@ def main():
last_launch_time = 0
while True:
# If the session process stops running (e.g. because the user logged out),
# the X server should be reset and the session restarted, to provide a
# completely clean new session.
# If the session process or X server stops running (e.g. because the user
# logged out), kill the other. This will trigger the next conditional block
# as soon as the os.wait() call (below) returns.
if desktop.session_proc is None and desktop.x_proc is not None:
logging.info("Terminating X server")
desktop.x_proc.terminate()
if desktop.x_proc is None:
if desktop.session_proc is not None:
# The X session would probably die soon if the X server is not
# running (because of the loss of the X connection). Terminate it
# anyway, to be sure.
logging.info("Terminating X session")
desktop.session_proc.terminate()
else:
# Neither X server nor X session are running.
elapsed = time.time() - last_launch_time
if elapsed < 60:
logging.error("The session lasted less than 1 minute. Waiting " +
"before starting new session.")
time.sleep(60 - elapsed)
logging.info("Launching X server and X session")
elif desktop.x_proc is None and desktop.session_proc is not None:
logging.info("Terminating X session")
desktop.session_proc.terminate()
elif desktop.x_proc is None and desktop.session_proc is None:
# Neither X server nor X session are running.
elapsed = time.time() - last_launch_time
if elapsed < 60:
logging.error("The session lasted less than 1 minute. Waiting " +
"before starting new session.")
time.sleep(60 - elapsed)
if last_launch_time == 0:
# Neither process has been started yet. Do so now.
logging.info("Launching X server and X session.")
last_launch_time = time.time()
desktop.launch_x_server(args)
desktop.launch_x_session()
else:
# Both processes have terminated. Since the user's desktop is already
# gone at this point, there's no state to lose and now is a good time
# to pick up any updates to this script that might have been installed.
logging.info("Relaunching self")
relaunch_self()
if desktop.host_proc is None:
logging.info("Launching host process")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment