FOSSology  4.4.0
Open Source License Compliance by Open Source Software
export_license_ref.php
Go to the documentation of this file.
1 #!/usr/bin/php -q
2 
3 <?php
4 /*
5  SPDX-FileCopyrightText: © 2013 Hewlett-Packard Development Company, L.P.
6 
7  SPDX-License-Identifier: GPL-2.0-only
8 */
9 
17 $Usage = "Usage: " . basename($argv[0]) . "
18  -h help, this message
19  -f {output file}
20  --help help, this message (Note: the user postgres should have write permission on the output file.)
21  ";
22 
23 $Options = getopt("hf:", array("help"));
24 
25 /* command-line options */
26 $SchemaFilePath = "";
27 foreach($Options as $Option => $OptVal)
28 {
29  switch($Option)
30  {
31  case 'f': /* schema file */
32  $SchemaFilePath = $OptVal;
33  break;
34  case 'h': /* help */
35  print $Usage;
36  exit (0);
37  case 'help': /* help */
38  print $Usage;
39  exit (0);
40  default:
41  echo "Invalid Option \"$Option\".\n";
42  print $Usage;
43  exit (1);
44  }
45 }
46 
47 # dump license_ref table into a temp file
48 if (empty($SchemaFilePath)) $SchemaFilePath = "licenseref.sql";
49 $dump_command = "sudo su postgres -c 'pg_dump -f $SchemaFilePath -a -t license_ref --column-inserts fossology'";
50 system($dump_command, $return_var);
51 
52 if(!$return_var) exit (0);
53 else exit (1);