FOSSology  3.2.0rc1
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  Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License
9  version 2 as published by the Free Software Foundation.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  ***********************************************************/
20 
28 $Usage = "Usage: " . basename($argv[0]) . "
29  -h help, this message
30  -f {output file}
31  --help help, this message (Note: the user postgres should have write permission on the output file.)
32  ";
33 
34 $Options = getopt("hf:", array("help"));
35 
36 /* command-line options */
37 $SchemaFilePath = "";
38 foreach($Options as $Option => $OptVal)
39 {
40  switch($Option)
41  {
42  case 'f': /* schema file */
43  $SchemaFilePath = $OptVal;
44  break;
45  case 'h': /* help */
46  print $Usage;
47  exit (0);
48  case 'help': /* help */
49  print $Usage;
50  exit (0);
51  default:
52  echo "Invalid Option \"$Option\".\n";
53  print $Usage;
54  exit (1);
55  }
56 }
57 
58 # dump license_ref table into a temp file
59 if (empty($SchemaFilePath)) $SchemaFilePath = "licenseref.sql";
60 $dump_command = "sudo su postgres -c 'pg_dump -f $SchemaFilePath -a -t license_ref --column-inserts fossology'";
61 system($dump_command, $return_var);
62 
63 if(!$return_var) exit (0);
64 else exit (1);
65 ?>