-
Notifications
You must be signed in to change notification settings - Fork 8
/
install-theme
executable file
·115 lines (93 loc) · 2.6 KB
/
install-theme
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
#!/usr/bin/perl -w
# This code is a part of Slash, and is released under the GPL.
# Copyright 1997-2003 by Open Source Development Network. See README
# and COPYING for more information, or see http://slashcode.com/.
# $Id$
# This is a theme install script.
# chromatic (chromatic@wgz.org), based on install-plugin by Krow
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 themes you would like?\n" unless $opts{'l'} ;
my $themes = $install->getThemeList($SLASH_PREFIX);
for (sort keys %$themes) {
print "$themes->{$_}{'order'}.\t$_ $themes->{$_}{'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 %$themes) {
push @answers, $themes->{$_}{'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->installThemes(\@answers, 0, $symlink);
}
sub usage {
print "*** $_[0]\n" if $_[0];
# Remember to doublecheck these match getopts()!
print <<EOT;
Usage: $PROGNAME [OPTIONS]
Installs Slash themes.
Main options:
-h Help (this message)
-v Version
-u Virtual user (default is "slash")
-l Does not install themes, just lists known themes
-L Install files 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-2003 by Open Source Development Network. See README
and COPYING for more information, or see http://slashcode.com/.
EOT
exit;
}
__END__