1 #!/usr/bin/php4 -q
2 <?php
3 /*
4 This code is part of GOsa (https://gosa.gonicus.de)
5 Copyright (C) 2003 Cajus Pollmeier
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
22 /* Need to set this currently. May change later. */
23 $BASE_DIR= "/home/cajus/gosa";
25 /* Prepare setup */
26 error_reporting (E_ALL);
27 $variables_order= "ES";
28 ini_set("register_globals",0);
29 ini_set("track_vars",1);
30 ini_set("include_path",".:$BASE_DIR/include");
32 /* Load required functions */
33 require_once ("functions.inc");
34 require_once ("functions_cli.inc");
36 /* Find all class files and include them */
37 get_dir_list("$BASE_DIR/plugins");
39 if (!file_exists(CONFIG_DIR."/gosa.conf")){
40 echo "Can't find config file ".CONFIG_DIR."/gosa.conf. Aborting.\n";
41 exit(8);
42 }
44 /* Check if gosa.conf is accessable */
45 if (!is_readable(CONFIG_DIR."/gosa.conf")){
46 echo sprintf("GOsa configuration %s/gosa.conf is not readable. Aborted.", CONFIG_DIR)."\n";
47 exit(8);
48 }
50 /* Authorized? This is not checked yet. I guess, having access to the config file
51 via UNIX rights is enough for now. Making this script setgid www-data has no
52 effect, of course. Thinking about a better way. */
54 /* Parse configuration file */
55 $config= new config(CONFIG_DIR."/gosa.conf", $BASE_DIR);
57 if (count($argv)==1){
58 print_usage();
59 exit (1);
60 }
62 /* Check for wanted LDAP location */
63 if (!isset($config->data["MAIN"]["DEFAULT"])){
64 echo "Error: need at least a defined default location in gosa.conf";
65 exit (1);
66 }
67 $location= $config->data["MAIN"]["DEFAULT"];
68 for ($i= 1; $i<count($argv); $i++){
69 if (preg_match('/^--location=.*$/', $argv[$i])){
70 $location= preg_replace('/^--location=(.*)$/', "$1", $argv[$i]);
71 }
72 }
73 $config->set_current($location);
75 /* Check for plugin list / help */
76 for ($i= 1; $i<count($argv); $i++){
77 if (preg_match('/^--plugin=list$/', $argv[$i])){
78 show_plugin_list($config);
79 exit (1);
80 }
81 if (preg_match('/^--plugin=[^-]+-help$/', $argv[$i])){
82 $plugin= preg_replace('/--plugin=([^-]+)-help$/', '$1', $argv[$i]);
83 show_plugin_help($plugin);
84 exit (1);
85 }
86 }
88 /* Go for actions */
89 switch ($argv[1]){
90 case 'create':
91 echo "create\n";
92 break;
93 case 'delete':
94 echo "delete\n";
95 break;
96 case 'list':
97 echo "list\n";
98 break;
99 case 'modify':
100 echo "modify\n";
101 break;
102 default:
103 echo "Error: Supplied command not known\n\n";
104 print_usage();
105 break;
106 }
108 #print_r ($config);
109 exit (0);
111 ?>