| 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..38423251bbfca516645069b0b88363c09d6a83b2 100755
|
| --- a/remoting/tools/me2me_virtual_host.py
|
| +++ b/remoting/tools/me2me_virtual_host.py
|
| @@ -52,8 +52,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 = HOME_DIR + "/.config/chrome-remote-desktop"
|
| +SESSION_FILE_PATH = HOME_DIR + "/.chrome-remote-desktop-session"
|
|
|
| X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
|
| FIRST_X_DISPLAY_NUMBER = 20
|
| @@ -75,6 +76,29 @@ MAX_LAUNCH_FAILURES = SHORT_BACKOFF_THRESHOLD + 10
|
| g_desktops = []
|
| g_host_hash = hashlib.md5(socket.gethostname()).hexdigest()
|
|
|
| +def load_lsb_release_file():
|
| + result = {}
|
| + try:
|
| + for line in open('/etc/lsb-release').readlines():
|
| + parts = (line.split('#', 2)[0]).split('=', 2)
|
| + if len(parts) == 2:
|
| + result[parts[0].strip()] = parts[1].strip()
|
| + except IOError as e:
|
| + logging.error('Failed to load /etc/lsb-release: ' + str(e))
|
| + return result
|
| +
|
| +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
|
| +
|
| + # Currently the host supports only Goobuntu.
|
| + # TODO(sergeyu): Try other versions of Ubuntu and enable them here.
|
| + lsb_release = load_lsb_release_file()
|
| + return (lsb_release.has_key('GOOGLE_CODENAME') and
|
| + lsb_release['GOOGLE_CODENAME'] == 'precise')
|
| +
|
| class Config:
|
| def __init__(self, path):
|
| self.path = path
|
| @@ -502,7 +526,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 +926,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 +950,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
|
|
|