| Index: remoting/tools/me2me_virtual_host.py
|
| diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py
|
| index c1eaa99b7cb9a59de5b2b79660e60c7014f5e7dd..3cd1fc0920431bb1414a68ce3833deb9ae9ec739 100755
|
| --- a/remoting/tools/me2me_virtual_host.py
|
| +++ b/remoting/tools/me2me_virtual_host.py
|
| @@ -21,6 +21,7 @@ import optparse
|
| import os
|
| import pipes
|
| import psutil
|
| +import platform
|
| import signal
|
| import socket
|
| import subprocess
|
| @@ -52,8 +53,9 @@ else:
|
|
|
| CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop"
|
|
|
| -CONFIG_DIR = os.path.expanduser("~/.config/chrome-remote-desktop")
|
| HOME_DIR = os.environ["HOME"]
|
| +CONFIG_DIR = os.path.join(HOME_DIR, ".config/chrome-remote-desktop")
|
| +SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session")
|
|
|
| X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
|
| FIRST_X_DISPLAY_NUMBER = 20
|
| @@ -75,6 +77,16 @@ MAX_LAUNCH_FAILURES = SHORT_BACKOFF_THRESHOLD + 10
|
| g_desktops = []
|
| g_host_hash = hashlib.md5(socket.gethostname()).hexdigest()
|
|
|
| +def is_supported_platform():
|
| + # Always assume that the system is supported if the config directory or
|
| + # session file exist.
|
| + if os.path.isdir(CONFIG_DIR) or os.path.isfile(SESSION_FILE_PATH):
|
| + return True
|
| +
|
| + # The host has been tested only on Ubuntu.
|
| + distribution = platform.linux_distribution()
|
| + return (distribution[0]).lower() == 'ubuntu'
|
| +
|
| class Config:
|
| def __init__(self, path):
|
| self.path = path
|
| @@ -502,7 +514,7 @@ def choose_x_session():
|
| # session instead of looking for custom .xsession files in the home directory.
|
| # So it's necessary to test for these files here.
|
| XSESSION_FILES = [
|
| - "~/.chrome-remote-desktop-session",
|
| + SESSION_FILE_PATH,
|
| "~/.xsession",
|
| "~/.Xsession" ]
|
| for startup_file in XSESSION_FILES:
|
| @@ -902,6 +914,9 @@ Web Store: https://chrome.google.com/remotedesktop"""
|
| parser.add_option("-k", "--stop", dest="stop", default=False,
|
| action="store_true",
|
| help="Stop the daemon currently running.")
|
| + parser.add_option("", "--get-status", dest="get_status", default=False,
|
| + action="store_true",
|
| + help="Prints host status")
|
| parser.add_option("", "--check-running", dest="check_running", default=False,
|
| action="store_true",
|
| help="Return 0 if the daemon is running, or 1 otherwise.")
|
| @@ -923,6 +938,19 @@ Web Store: https://chrome.google.com/remotedesktop"""
|
| options.config = os.path.join(CONFIG_DIR, "host#%s.json" % g_host_hash)
|
|
|
| # Check for a modal command-line option (start, stop, etc.)
|
| +
|
| + if options.get_status:
|
| + pid = get_daemon_pid()
|
| + if pid != 0:
|
| + print "STARTED"
|
| + elif is_supported_platform():
|
| + print "STOPPED"
|
| + else:
|
| + print "NOT_IMPLEMENTED"
|
| + return 0
|
| +
|
| + # TODO(sergeyu): Remove --check-running once NPAPI plugin and NM host are
|
| + # updated to always use get-status flag instead.
|
| if options.check_running:
|
| pid = get_daemon_pid()
|
| return 0 if pid != 0 else 1
|
|
|