| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Virtual Me2Me implementation. This script runs and manages the processes | 6 # Virtual Me2Me implementation. This script runs and manages the processes |
| 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop | 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop |
| 8 # session, and Host process. | 8 # session, and Host process. |
| 9 # This script is intended to run continuously as a background daemon | 9 # This script is intended to run continuously as a background daemon |
| 10 # process, running under an ordinary (non-root) user account. | 10 # process, running under an ordinary (non-root) user account. |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 help="Stop the daemon currently running.") | 559 help="Stop the daemon currently running.") |
| 560 parser.add_option("", "--check-running", dest="check_running", default=False, | 560 parser.add_option("", "--check-running", dest="check_running", default=False, |
| 561 action="store_true", | 561 action="store_true", |
| 562 help="Return 0 if the daemon is running, or 1 otherwise.") | 562 help="Return 0 if the daemon is running, or 1 otherwise.") |
| 563 parser.add_option("", "--reload", dest="reload", default=False, | 563 parser.add_option("", "--reload", dest="reload", default=False, |
| 564 action="store_true", | 564 action="store_true", |
| 565 help="Signal currently running host to reload the config.") | 565 help="Signal currently running host to reload the config.") |
| 566 parser.add_option("", "--add-user", dest="add_user", default=False, | 566 parser.add_option("", "--add-user", dest="add_user", default=False, |
| 567 action="store_true", | 567 action="store_true", |
| 568 help="Add current user to the chrome-remote-desktop group.") | 568 help="Add current user to the chrome-remote-desktop group.") |
| 569 parser.add_option("", "--host-version", dest="host_version", default=False, |
| 570 action="store_true", |
| 571 help="Prints version of the host.") |
| 569 (options, args) = parser.parse_args() | 572 (options, args) = parser.parse_args() |
| 570 | 573 |
| 571 host_hash = hashlib.md5(socket.gethostname()).hexdigest() | 574 host_hash = hashlib.md5(socket.gethostname()).hexdigest() |
| 572 pid_filename = os.path.join(CONFIG_DIR, "host#%s.pid" % host_hash) | 575 pid_filename = os.path.join(CONFIG_DIR, "host#%s.pid" % host_hash) |
| 573 | 576 |
| 574 # Check for a modal command-line option (start, stop, etc.) | 577 # Check for a modal command-line option (start, stop, etc.) |
| 575 if options.check_running: | 578 if options.check_running: |
| 576 running, pid = PidFile(pid_filename).check() | 579 running, pid = PidFile(pid_filename).check() |
| 577 return 0 if (running and pid != 0) else 1 | 580 return 0 if (running and pid != 0) else 1 |
| 578 | 581 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 592 os.kill(pid, signal.SIGHUP) | 595 os.kill(pid, signal.SIGHUP) |
| 593 return 0 | 596 return 0 |
| 594 | 597 |
| 595 if options.add_user: | 598 if options.add_user: |
| 596 command = ("sudo -k && gksudo --message " | 599 command = ("sudo -k && gksudo --message " |
| 597 "\"Please enter your password to enable Chrome Remote Desktop\" " | 600 "\"Please enter your password to enable Chrome Remote Desktop\" " |
| 598 "-- sh -c " | 601 "-- sh -c " |
| 599 "\"groupadd -f %(group)s && gpasswd --add %(user)s %(group)s\"" % | 602 "\"groupadd -f %(group)s && gpasswd --add %(user)s %(group)s\"" % |
| 600 { 'group': CHROME_REMOTING_GROUP_NAME, | 603 { 'group': CHROME_REMOTING_GROUP_NAME, |
| 601 'user': getpass.getuser() }) | 604 'user': getpass.getuser() }) |
| 602 return os.system(command) | 605 return os.system(command) >> 8 |
| 606 |
| 607 if options.host_version: |
| 608 # TODO(sergeyu): Also check RPM package version once we add RPM package. |
| 609 return os.system(locate_executable(HOST_BINARY_NAME) + " --version") >> 8 |
| 603 | 610 |
| 604 if not options.start: | 611 if not options.start: |
| 605 # If no modal command-line options specified, print an error and exit. | 612 # If no modal command-line options specified, print an error and exit. |
| 606 print >> sys.stderr, EPILOG | 613 print >> sys.stderr, EPILOG |
| 607 return 1 | 614 return 1 |
| 608 | 615 |
| 609 if not options.size: | 616 if not options.size: |
| 610 options.size = [DEFAULT_SIZE] | 617 options.size = [DEFAULT_SIZE] |
| 611 | 618 |
| 612 sizes = [] | 619 sizes = [] |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 return 0 | 784 return 0 |
| 778 elif os.WEXITSTATUS(status) == 5: | 785 elif os.WEXITSTATUS(status) == 5: |
| 779 logging.info("Host domain is blocked by policy - exiting.") | 786 logging.info("Host domain is blocked by policy - exiting.") |
| 780 os.remove(host.config_file) | 787 os.remove(host.config_file) |
| 781 return 0 | 788 return 0 |
| 782 # Nothing to do for Mac-only status 6 (login screen unsupported) | 789 # Nothing to do for Mac-only status 6 (login screen unsupported) |
| 783 | 790 |
| 784 if __name__ == "__main__": | 791 if __name__ == "__main__": |
| 785 logging.basicConfig(level=logging.DEBUG) | 792 logging.basicConfig(level=logging.DEBUG) |
| 786 sys.exit(main()) | 793 sys.exit(main()) |
| OLD | NEW |