forked from plainblack/webgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installClass.pl
executable file
·147 lines (106 loc) · 3.18 KB
/
installClass.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use File::Basename ();
use File::Spec;
my $webguiRoot;
BEGIN {
$webguiRoot = File::Spec->rel2abs(File::Spec->catdir(File::Basename::dirname(__FILE__), File::Spec->updir));
unshift @INC, File::Spec->catdir($webguiRoot, 'lib');
}
use Getopt::Long;
use Pod::Usage;
use WebGUI::Pluggable;
use WebGUI::Session;
$|++;
# Get options
my ( $configFile, $remove, $check, $upgrade, $help, $man );
GetOptions(
'configFile=s' => \$configFile,
'remove' => \$remove,
'check' => \$check,
'upgrade' => \$upgrade,
'help' => \$help,
'man' => \$man,
);
# Get arguments
my $class = $ARGV[0];
pod2usage( -verbose => 1 )
if $help;
pod2usage( -verbose => 2 )
if $man;
pod2usage("$0: Must specify a configFile")
if !$configFile;
die "Config file '$configFile' does not exist!\n"
if !-f '../etc/' . $configFile;
# Open the session
my $session = WebGUI::Session->open( "..", $configFile );
$session->user( { userId => 3 } );
# Install or uninstall the asset
WebGUI::Pluggable::load($class);
if ($check) {
if ( $class->isInstalled($session) ) {
print "$class is installed!\n";
}
else {
print "$class is NOT installed!\n";
}
}
elsif ($remove) {
print "Removing $class... ";
if ( !$class->isInstalled($session) ) {
die "Can't remove $class because: Not installed\n";
}
$class->uninstall($session);
print "DONE!\n";
print "Please restart Apache.\n";
}
elsif ( $upgrade || $class->isInstalled($session) ) {
print "Upgrading $class... ";
$class->upgrade($session);
print "DONE!\n";
print "Please restart Apache.\n";
}
else {
print "Installing $class... ";
$class->install($session);
print "DONE!\n";
print "Please restart Apache.\n";
}
# End the session
$session->var->end;
$session->close;
__END__
=head1 NAME
installClass.pl -- Run class install methods
=head1 SYNOPSIS
installClass.pl [--remove|--check|--upgrade] <class> --configFile=<configFile>
=head1 DESCRIPTION
This helper script installs a class that is using the correct interface.
If your class has not told you to use this script, then it probably won't work!
=head1 ARGUMENTS
=over 4
=item class
The class name of the asset to install. Something like WebGUI::Asset::Yourasset
=back
=head1 OPTIONS
=over 4
=item check
If specified, will check if the class is installed or not.
=item upgrade
If specified, will upgrade the class.
=item remove
If specified, will uninstall the class.
=item configFile
The configuration file for the site to install the class into
=back
=head1 SEE ALSO
WebGUI::AssetAspect::Installable