-
Notifications
You must be signed in to change notification settings - Fork 8
/
install-plugin
executable file
·119 lines (96 loc) · 2.75 KB
/
install-plugin
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
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2005 by Open Source Technology Group. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id$
# This is the plugin install script.
# -Brian (brian@tangent.org)
use strict;
use File::Basename;
use FindBin '$Bin';
use Getopt::Std;
use File::Copy;
use Slash::Install;
(my $VERSION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
my $PROGNAME = basename($0);
(my $SLASH_PREFIX = $Bin) =~ s|/[^/]+/?$||;
my %opts;
# Remember to doublecheck these match usage()!
usage() unless getopts('hvlu:L:', \%opts);
usage() if ($opts{'h'} || !keys %opts);
version() if $opts{'v'};
$opts{'u'} ||= 'slash';
$| = 1;
unless (DBIx::Password::checkVirtualUser($opts{'u'})) {
print "You did not supply a valid DBIx::Password virtual name($opts{'u'}).\n";
exit;
}
{
my $install = Slash::Install->new($opts{'u'});
print "\nPlease select which plugins you would like?\n" unless $opts{'l'} ;
my $plugins = $install->getPluginList($SLASH_PREFIX);
for (sort keys %$plugins) {
print "$plugins->{$_}{order}.\t$_ $plugins->{$_}{'description'}\n";
}
exit 0 if $opts{'l'};
my @answers;
my $select = 'a';
print "Hit 'a' to select all, otherwise select comma separated numbers or 'q' to quit\n";
while ($select ne 'q'){
chomp($select = <STDIN>);
if ($select =~ /^\d\,/) {
@answers = split(/\,/, $select);
last;
} elsif ($select eq 'a') {
for (keys %$plugins) {
push @answers, $plugins->{$_}{order};
}
last;
} elsif ($select eq "") {
last;
} elsif ($select ne 'q') {
push @answers, $select;
}
}
my $symlink;
if ($opts{'L'}) {
$symlink = $opts{'L'} =~ /^n/i ? 0 : 1;
} else {
print "
Would you like to install all the files as symlinks
to the original? (If not, each file will be copied to
your Slash directories). [Y] ";
chomp(my $ans = <STDIN>);
$ans ||= 'Y';
$symlink = $ans =~ /^\s*[Yy]/;
}
$install->installPlugins(\@answers, 0, $symlink);
print "\n\nInstalled.\n\n";
print "Please check to see if there are any README files for your site's\n";
print "plugins. If so, now's a good time to read them.\n\n";
}
sub usage {
print "*** $_[0]\n" if $_[0];
# Remember to doublecheck these match getopts()!
print <<EOT;
Usage: $PROGNAME [OPTIONS]
Installs Slash plugins.
Main options:
-h Help (this message)
-v Version
-u Virtual user (default is "slash")
-l Does not install plugins, just lists known plugins
-L Install files in htdocs using symlinks [y/n]
EOT
exit;
}
sub version {
print <<EOT;
$PROGNAME $VERSION
This code is a part of Slash, and is released under the GPL.
Copyright 1997-2005 by Open Source Technology Group. See README
and COPYING for more information, or see http://slashcode.com/.
EOT
exit;
}
__END__