Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: remoting/tools/me2me_virtual_host.py

Issue 10909090: Implement DaemonController::GetVersion() method on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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("set -o pipefail;" +
610 "dpkg -s chrome-remote-desktop | awk '/^Version:/ { print $2; }'") >> 8
Jamie 2012/09/06 01:29:50 Yikes! I wonder if it would be cleaner to use @@VE
Sergey Ulanov 2012/09/06 19:31:58 Done.
603 611
604 if not options.start: 612 if not options.start:
605 # If no modal command-line options specified, print an error and exit. 613 # If no modal command-line options specified, print an error and exit.
606 print >> sys.stderr, EPILOG 614 print >> sys.stderr, EPILOG
607 return 1 615 return 1
608 616
609 if not options.size: 617 if not options.size:
610 options.size = [DEFAULT_SIZE] 618 options.size = [DEFAULT_SIZE]
611 619
612 sizes = [] 620 sizes = []
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 return 0 785 return 0
778 elif os.WEXITSTATUS(status) == 5: 786 elif os.WEXITSTATUS(status) == 5:
779 logging.info("Host domain is blocked by policy - exiting.") 787 logging.info("Host domain is blocked by policy - exiting.")
780 os.remove(host.config_file) 788 os.remove(host.config_file)
781 return 0 789 return 0
782 # Nothing to do for Mac-only status 6 (login screen unsupported) 790 # Nothing to do for Mac-only status 6 (login screen unsupported)
783 791
784 if __name__ == "__main__": 792 if __name__ == "__main__":
785 logging.basicConfig(level=logging.DEBUG) 793 logging.basicConfig(level=logging.DEBUG)
786 sys.exit(main()) 794 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698