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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
=debian
use POSIX;
$is_root=1 if ($> == 0 );
=cut
open (VERSION, "VERSION");
$version=<VERSION>;
chop $version;
close VERSION;
=debian
print <<"EOF";
Welcome to the installation of SMB2WWW, release $version.
Press <Return> to continue, or press <Ctrl-C> to stop.
EOF
$foo=<STDIN>;
if ($is_root == 1) {
while (! getpwnam($uname)) {
print "$uname is not a valid username.\n" if (! $uname eq "");
print "What username shall I use to install smb2www [www-data] ? ";
$uname=<STDIN>;
chop $uname;
$uname = "www-data" if ($uname eq "");
}
while (! getgrnam($gname)) {
print "$gname is not a valid groupname.\n" if (! $gname eq "");
print "What groupname shall I use to install smb2www [www-data] ? ";
$gname= <STDIN>;
chop $gname;
$gname = "www-data" if ($gname eq "");
}
}
print "Where shall I put smb2www [/usr/local/smb2www] ? ";
$dir=<STDIN>; chop $dir;
if ( $dir eq "") { $dir = "/usr/local/smb2www" };
print "\n";
die "Directory already exists ! Move first before continuing !" if ( -d $dir);
mkdir "$dir",0755 or die "Unable to create directory ! Check your permissions.";
print "\nDirectory $dir created successfully.\nNow creating subdirectories.\n";
mkdir "$dir/images",0755 or die "$!\n";
mkdir "$dir/cgi-bin",0755 or die "$!\n";
mkdir "$dir/bin",0755 or die "$!\n";
mkdir "$dir/etc",0755 or die "$!\n";
print "Subdirectories bin, etc, images and cgi-bin successfully created.\n\n";
if ($is_root) {
print "Setting ownership to $uname:$gname...";
$uid=getpwnam($uname);
$gid=getgrnam($gname);
chown $uid,$gid,$dir,"$dir/images","$dir/cgi-bin","$dir/bin","$dir/etc" or die "\n$!\n";
print "done.\n\n";
}
$smbc = "";
while (not -x "$smbc/smbclient" ) {
print "In which directory is smbclient located [/usr/local/samba/bin] ? ";
$smbc=<STDIN>; chop $smbc;
if ( $smbc eq "") { $smbc = "/usr/local/samba/bin" };
print "\n";
}
symlink "$smbc/smbclient","$dir/bin/smbclient" or die "unable to symlink smbclient to $dir/bin !\n";
$perl = "";
while (not -x "$perl" ){
print "What is your perl 5 binary [/usr/bin/perl] ? ";
$perl=<STDIN>; chop $perl;
if ( $perl eq "") { $perl = "/usr/bin/perl" };
print "\n";
}
print "Which server shall I use as master browser ? ";
$mbrowse=<STDIN>; chop $mbrowse;
print "\n";
srand ( time ^ ($$ + ($$ << 15)) );
while (length $key < 25) {
$key = $key.chr(rand(64)+64);
}
print "Which language would you like to use with SMB2WWW ?\n (english dutch finnish) [english] ";
$language = <STDIN>; chop $language;
if ( $language eq "" ) { $language = "english" };
print "\n";
print "Which path shall I use for SMB2WWW pictures on your webserver\n[/smbimg] ? ";
$imgpath=<STDIN>; chop $imgpath;
if ( $imgpath eq "" ) { $imgpath = "/smbimg" };
print "\n";
print "Which path shall I use as SMB2WWW root on your webserver [/samba] ? ";
$cgiroot=<STDIN>; chop $cgiroot;
if ( $cgiroot eq "" ) { $cgiroot = "/samba" };
print "\n";
print "Where is your mime.types file [/etc] ? ";
$mime=<STDIN>; chop $mime;
if ( $mime eq "" ) { $mime = "/etc" };
$mime= $mime."/mime.types";
print "\n";
print "Now modifying scripts and configuration files...\n\n";
print "To make modifications later, edit $dir/etc/smb2www.conf\n";
# smb2www.conf
open OUT, ">$dir/etc/smb2www.conf" or die "unable to create file $dir/etc/smb2www.conf !\n";
print OUT <<"EOF";
=cut
$fcfg='/etc/smb2www/smb2www.conf';
print <<EOF;
###
### This file is read by smb2www before $fcfg
###
### !!! Please do not edit !!!
###
### If you want to change some variables, please add relevant
### lines to $fcfg
###
version = $version
### enabled = ### Must be set in $fcfg ###
### masterbrowser = ### Must be set in $fcfg ###
username = nobody
refresh = 300
cache = max-age = 300
bindir = /usr/bin
cfgdir = /usr/share/smb2www/lang
imgroot = /samba-images
cgiroot = /cgi-bin/samba
linkto_other = http://samba.anu.edu.au/samba/smb2www/
background = cloud.gif
icon_other = world.gif
icon_all = network.gif
icon_group = group.gif
icon_computer = computer.gif
icon_share = share.gif
icon_printer = printer.gif
icon_dir = folder.gif
icon_file = file.gif
icon_archive = archive.gif
icon_help = help.gif
icon_message = message.gif
link = #7f0000
vlink = #4f0000
mimetype = /etc/mime.types
### language = ### Must be set in $fcfg ###
### key = ### Must be set in $fcfg ###
html_header_file = /usr/share/smb2www/header.template
html_trailer_file = /usr/share/smb2www/trailer.template
EOF
=debian
close OUT;
# All .pl files
@pl = ("smbfile.pl","smbtar.pl","smbhelp.pl","smbshr.pl",
"smbdir.pl","smbgrp.pl","smb2www.pl","smbmsg.pl");
foreach $plfile ( @pl) {
open IN, "cgi-bin/$plfile";
$pline = <IN>;
open OUT, ">$dir/cgi-bin/$plfile" or die "$!\n";
print OUT "#! $perl\n";
while (<IN>) {
print OUT $_;
}
close OUT;
chmod 0550,"$dir/cgi-bin/$plfile";
if ($is_root) { chown $uid,$gid, "$dir/cgi-bin/$plfile" }
close IN;
}
# smb2www.pm
open IN, "cgi-bin/smb2www.pm";
open OUT, ">$dir/cgi-bin/smb2www.pm";
while (<IN>) {
$_ =~ s#/usr/local/smb2www/etc/smb2www.conf#$dir/etc/smb2www.conf#;
print OUT $_;
}
close OUT;
if ($is_root) { chown $uid, $gid, "$dir/cgi-bin/smb2www.pm" }
close IN;
# copy all images
`cp -v images/* $dir/images/`;
if ($is_root) {
opendir IMGDIR, "$dir/images";
@allfiles = grep !/^\./, readdir IMGDIR;
closedir IMGDIR;
foreach $file (@allfiles) {
chown $uid,$gid, "$dir/images/$file";
}
}
# copy all language files
`cp -v etc/*.lang $dir/etc/`;
if ($is_root) {
opendir ETCDIR, "$dir/etc";
@allfiles = grep !/^\./, readdir ETCDIR;
closedir ETCDIR;
foreach $file (@allfiles) {
chown $uid, $gid, "$dir/etc/$file"
}
}
# Setting permissions
chmod 0550,"$dir/cgi-bin";
print "\nAdd this to your apache config:\n";
print "-------------------------------\n\n";
print "Alias $imgpath $dir/images\n";
print "ScriptAlias $cgiroot/ $dir/cgi-bin\n";
print "\nThank you for using SMB2WWW.\n\n";
=cut
|