#!/usr/bin/php /passwd\n\n"); } function xcvs_init($argc, $argv) { $this_file = array_shift($argv); // argv[0] $config_file = array_shift($argv); // argv[1] $passwd_file = array_shift($argv); // argv[2] if ($argc < 3) { xcvs_help($this_file, STDERR); exit(3); } $passwd_file_new = $passwd_file . '.new'; // Load the configuration file and bootstrap Drupal. if (!file_exists($config_file)) { fwrite(STDERR, $this_file . ": Failed to load configuration file.\n"); exit(4); } require_once $config_file; // Do a full Drupal bootstrap. xcvs_bootstrap($xcvs); $repository = versioncontrol_get_repository($xcvs['repo_id']); if (!isset($repository)) { fwrite(STDERR, $this_file . ": The repository for the configured repo id could not be loaded.\n"); exit(5); } // Set the Drupal base path, so that url() returns a proper URL. global $base_url; $base_url = DRUPAL_SITE; // Retrieve the file contents, and write them to the new file. $output = versioncontrol_export_accounts($repository); if (!file_put_contents($passwd_file_new, $output)) { fwrite(STDERR, $this_file . ": Writing to new passwd file failed!\n"); exit(6); } // Rename the file. if (!rename($passwd_file_new, $passwd_file)) { fwrite(STDERR, $this_file . ": Renaming new passwd file failed!\n"); exit(7); } exit(0); } xcvs_init($argc, $argv);