961ce1c2 |
1 | #! @PERL@ |
2 | # -*-perl-*- |
3 | # |
9796a787 |
4 | # $Id: sw.in,v 1.3 2004/04/08 01:52:19 mdw Exp $ |
961ce1c2 |
5 | # |
6 | # CGI interface for software installations |
7 | # |
8 | # (c) 1999 EBI |
9 | # |
10 | |
11 | #----- Licensing notice ----------------------------------------------------- |
12 | # |
13 | # This file is part of sw-tools. |
14 | # |
15 | # sw-tools is free software; you can redistribute it and/or modify |
16 | # it under the terms of the GNU General Public License as published by |
17 | # the Free Software Foundation; either version 2 of the License, or |
18 | # (at your option) any later version. |
19 | # |
20 | # sw-tools is distributed in the hope that it will be useful, |
21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | # GNU General Public License for more details. |
24 | # |
25 | # You should have received a copy of the GNU General Public License |
26 | # along with sw-tools; if not, write to the Free Software Foundation, |
27 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
28 | |
961ce1c2 |
29 | #----- Required packages ---------------------------------------------------- |
30 | |
31 | use lib qw(@pkgdatadir@); |
32 | |
33 | use POSIX; |
34 | use IO; |
35 | |
36 | use SWConfig; |
37 | use SW; |
38 | use SWCGI qw(:DEFAULT :debug); |
39 | |
40 | #----- Get packages implementing various actions ---------------------------- |
41 | |
42 | BEGIN { %ACT = (); } |
43 | use SWList; |
44 | use SWDoc; |
45 | use SWMan; |
46 | use SWInfo; |
47 | |
48 | #----- Some built-in debugging actions -------------------------------------- |
49 | |
50 | sub debug($\%) { |
51 | my ($what, $h) = @_; |
52 | SWCGI::header($what); |
53 | SWCGI::dumphash(%$h); |
54 | SWCGI::footer(); |
55 | } |
56 | |
57 | $ACT{"show-config"} = sub { debug("configuration", %C); }; |
9abee809 |
58 | $ACT{"show-environment"} = sub { debug("environment", %ENV); }; |
59 | $ACT{"show-query"} = sub { debug("query", %Q); }; |
961ce1c2 |
60 | |
61 | #----- Snarf arguments ------------------------------------------------------ |
62 | |
63 | $C{"edited-config-file"} eq "yes" or |
64 | barf("Config file $C{datadir}/sw.conf hasn't been edited."); |
65 | |
66 | SWCGI::read(); |
67 | $act = $Q{"act"} || "list"; |
68 | if ($ACT{$act}) { |
69 | &{$ACT{$act}}; |
70 | } else { |
71 | barf("unknown action `$act'"); |
72 | } |
73 | |
74 | #----- That's all, folks ---------------------------------------------------- |
75 | |
76 | exit; |