| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 parser.add_option("", "--reload", dest="reload", default=False, | 1085 parser.add_option("", "--reload", dest="reload", default=False, |
| 1086 action="store_true", | 1086 action="store_true", |
| 1087 help="Signal currently running host to reload the config.") | 1087 help="Signal currently running host to reload the config.") |
| 1088 parser.add_option("", "--add-user", dest="add_user", default=False, | 1088 parser.add_option("", "--add-user", dest="add_user", default=False, |
| 1089 action="store_true", | 1089 action="store_true", |
| 1090 help="Add current user to the chrome-remote-desktop group.") | 1090 help="Add current user to the chrome-remote-desktop group.") |
| 1091 parser.add_option("", "--add-user-as-root", dest="add_user_as_root", | 1091 parser.add_option("", "--add-user-as-root", dest="add_user_as_root", |
| 1092 action="store", metavar="USER", | 1092 action="store", metavar="USER", |
| 1093 help="Adds the specified user to the chrome-remote-desktop " | 1093 help="Adds the specified user to the chrome-remote-desktop " |
| 1094 "group (must be run as root).") | 1094 "group (must be run as root).") |
| 1095 parser.add_option("", "--host-version", dest="host_version", default=False, | |
| 1096 action="store_true", | |
| 1097 help="Prints version of the host.") | |
| 1098 parser.add_option("", "--watch-resolution", dest="watch_resolution", | 1095 parser.add_option("", "--watch-resolution", dest="watch_resolution", |
| 1099 type="int", nargs=2, default=False, action="store", | 1096 type="int", nargs=2, default=False, action="store", |
| 1100 help=optparse.SUPPRESS_HELP) | 1097 help=optparse.SUPPRESS_HELP) |
| 1101 (options, args) = parser.parse_args() | 1098 (options, args) = parser.parse_args() |
| 1102 | 1099 |
| 1103 # Determine the filename of the host configuration and PID files. | 1100 # Determine the filename of the host configuration and PID files. |
| 1104 if not options.config: | 1101 if not options.config: |
| 1105 options.config = os.path.join(CONFIG_DIR, "host#%s.json" % g_host_hash) | 1102 options.config = os.path.join(CONFIG_DIR, "host#%s.json" % g_host_hash) |
| 1106 | 1103 |
| 1107 # Check for a modal command-line option (start, stop, etc.) | 1104 # Check for a modal command-line option (start, stop, etc.) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 subprocess.check_call(["/usr/sbin/groupadd", "-f", | 1180 subprocess.check_call(["/usr/sbin/groupadd", "-f", |
| 1184 CHROME_REMOTING_GROUP_NAME]) | 1181 CHROME_REMOTING_GROUP_NAME]) |
| 1185 subprocess.check_call(["/usr/bin/gpasswd", "--add", user, | 1182 subprocess.check_call(["/usr/bin/gpasswd", "--add", user, |
| 1186 CHROME_REMOTING_GROUP_NAME]) | 1183 CHROME_REMOTING_GROUP_NAME]) |
| 1187 except (ValueError, OSError, subprocess.CalledProcessError) as e: | 1184 except (ValueError, OSError, subprocess.CalledProcessError) as e: |
| 1188 logging.error("Command failed: " + str(e)) | 1185 logging.error("Command failed: " + str(e)) |
| 1189 return 1 | 1186 return 1 |
| 1190 | 1187 |
| 1191 return 0 | 1188 return 0 |
| 1192 | 1189 |
| 1193 if options.host_version: | |
| 1194 # TODO(sergeyu): Also check RPM package version once we add RPM package. | |
| 1195 return os.system(locate_executable(HOST_BINARY_NAME) + " --version") >> 8 | |
| 1196 | |
| 1197 if options.watch_resolution: | 1190 if options.watch_resolution: |
| 1198 watch_for_resolution_changes(options.watch_resolution) | 1191 watch_for_resolution_changes(options.watch_resolution) |
| 1199 return 0 | 1192 return 0 |
| 1200 | 1193 |
| 1201 if not options.start: | 1194 if not options.start: |
| 1202 # If no modal command-line options specified, print an error and exit. | 1195 # If no modal command-line options specified, print an error and exit. |
| 1203 print(EPILOG, file=sys.stderr) | 1196 print(EPILOG, file=sys.stderr) |
| 1204 return 1 | 1197 return 1 |
| 1205 | 1198 |
| 1206 # If a RANDR-supporting Xvfb is not available, limit the default size to | 1199 # If a RANDR-supporting Xvfb is not available, limit the default size to |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 else: | 1392 else: |
| 1400 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) | 1393 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) |
| 1401 elif os.WIFSIGNALED(status): | 1394 elif os.WIFSIGNALED(status): |
| 1402 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) | 1395 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) |
| 1403 | 1396 |
| 1404 | 1397 |
| 1405 if __name__ == "__main__": | 1398 if __name__ == "__main__": |
| 1406 logging.basicConfig(level=logging.DEBUG, | 1399 logging.basicConfig(level=logging.DEBUG, |
| 1407 format="%(asctime)s:%(levelname)s:%(message)s") | 1400 format="%(asctime)s:%(levelname)s:%(message)s") |
| 1408 sys.exit(main()) | 1401 sys.exit(main()) |
| OLD | NEW |