#!/usr/bin/perl # # The following configurations may be made to modify the install # on your system. # # # Where do you want webstats to be installed # You can use the pattern $(VERSION) as in this # example to use the version number in your path. # Make sure this remains in single quotes. # $DEST = '/usr/local/webstats-$(VERSION)/'; #$DEST = '/root/webstats/installtest/webstats-$(VERSION)/'; # # Where do you want documentation to be installed? # You can use string concatenation, as in this example, # to install the docs below the program. $DOC = $DEST . 'docs/'; # # These set the permissions for all installed files. # FILE_MODE is the default mode for all installed files # including docs, configuration files and libraries. # EXEC_MODE is used for the script. # $FILE_MODE = 0644; $EXEC_MODE = 0755; # # #################### END OF CONFIGURATION #################### # [You should not need to change anything below here] # ############################################################## ############################################################ # # File: Install.PL # # Description: # installs webstats # # # Created: 1999.Oct.18 by Jeremy Wadsack for Wadsack-Allen Digital Group # Copyright (C) Wadsack-Allen. All rights reserved. # # Ripped apart and put together the other way around by Pat Erler # anno 2001 to make him feel good and to install webstats... # ############################################################ # Date Modification Author # ---------------------------------------------------------- # 1999NOV18 First working version JW # 1999DEC16 Rearranged notice to be proper order JW # 2000JAN11 Converted to full install script JW # 2000FEB14 Update for RM 1.3 JW # 2000MAR08 Patched for RM 1.31 JW # 2000MAR30 Added error checking to copy function JW # 2000MAR30 Added install support for GDGraph3d JW # 2000APR04 Added wadg::* libraries to install JW # 2000JUL19 Changed W/WA/WADG/... to GD::Graph3d JW # 2000Jul24 Changed IniConf to Config::IniFiles JW # 2000Aug24 Changed default install to something logical JW # 2000Sep29 Fixed for 2.0 changes JW # 2000Nov28 Added error handling and CPAN autoload JW # 2001Feb05 Changed $DEST on --only-modules mode JW # 2001Jul04 Changed to work with webstats PE ############################################################ use strict; use File::Copy; use File::Path; use Cwd; use vars qw( $DEST $DOC $FILE_MODE $EXEC_MODE $phonehome_name $phonehome); my $cnt = 0; my $VERSION = '0.3'; my %args; my $err_cnt = 0; # Parse command line (webstats installer don't need it, so we # comment it out) #foreach ( @ARGV ) { # if( /^--?([^=]+)=?(.*)$/ ) { # my( $k, $v ) = ($1, $2); # $k =~ s/-/_/; # $args{$k} = $v; # } else { #$DEST = $_; #$DOC = $DEST . 'docs/'; # } # end if #} # end foreach # Convert DEST, DOC $DEST =~ s/\$\(VERSION\)/$VERSION/g; $DOC =~ s/\$\(VERSION\)/$VERSION/g; if( $DEST !~ m#/$# ) { $DEST .= '/'; } # end if if( $DOC !~ m#/$# ) { $DOC .= '/'; } # end if # Get CWD for later ('cause CPAN module is poorly behaved!) my $cwd = cwd; # Output header print qq[ ------------------------------------------------------ Report Magic for Analog $VERSION installation script ------------------------------------------------------ ]; # # Now install webstats # chdir( $cwd ); print "Installing webstats files in $DEST.\n"; # make sure $DEST exisits if( !-d $DEST ) { print "... Path does not exits, making it.\n"; mkpath( $DEST ); } # end if &install( $FILE_MODE, 'README', $DEST ) || $err_cnt++; &install( $FILE_MODE, 'INSTALL', $DEST ) || $err_cnt++; &install( $FILE_MODE, 'GPL', $DEST ) || $err_cnt++; &install( $FILE_MODE, 'VERSION', $DEST ) || $err_cnt++; &install( $FILE_MODE, 'CHANGES', $DEST ) || $err_cnt++; print "... Installing webstats config files.\n"; &install( $FILE_MODE, 'configfiles/serverwide/', $DEST.'configfiles/serverwide/' ) || $err_cnt++; &install( $FILE_MODE, 'configfiles/vhosts/', $DEST.'configfiles/vhosts/' ) || $err_cnt++; print "... Installing the webstats php files.\n"; &install( $FILE_MODE, 'scripts/php/', $DEST.'www/' ) || $err_cnt++; print "... Installing webstats program files.\n"; &install( $EXEC_MODE, 'scripts/perl/', $DEST ) || $err_cnt++; # # Now install Report Magic Documentation # print "Installing documentation in $DOC.\n"; &install( $FILE_MODE, 'docs/', $DOC ) || $err_cnt++; if( $err_cnt ) { print "\n*** Installation Failed! ***\n"; print "Please review the output of the installation above \n"; print "to determine where the problem occurred and try to \n"; print "correct the situation. Often, by reading the error \n"; print "messages you can determine what needs to be changed.\n"; } else { $DOC = 'docs/' if defined $args{only_modules}; print "\nInstallation complete.\n"; print "------------------------------------------------------\n\n"; print "For help on using webstats see $DOC"."index.html.\n"; print "You must agree to the license agreement at $DEST"."GPL before using webstats.\n"; print "\n\n\n\n Would you like to send a success message to the author\n of webstats?\n\n"; print "\nThis would help me to get a feeling how often webstats is used\n"; print "and could even encourage me to do more developement ;)"; print "\n\nSending the success message to me is done by running this command:\n\n"; print "(echo \"\$1 installed webstats $VERSION successfully\") \| mail webstats\@patsplanet.com"; print "\n\nsay \"y\" for yes or press another key for NO! : "; chomp ($phonehome = ); if ($phonehome eq "y"){ print "\n\nTell me your name if you like (press enter if you don't): "; chomp ($phonehome_name = ); unless ($phonehome){ print "\n\nSending..."; print `echo "$phonehome_name installed webstats $VERSION successfully") | mail webstats\@patsplanet.com `; print " Thanks $phonehome_name !\n\n"; } else{ print "\n\nSending..."; print `(echo "anonymous installed webstats $VERSION successfully") | mail webstats\@patsplanet.com `; print " Thanks!\n\n"; } } } # end if exit $err_cnt; # # Install (copy) files from one place to another, setting mode # NOTE: $src CANNOT be an absolute filename. It should be # relative to the $dest directory if $dest is a directory. # sub install { my( $mode, $src, $dest ) = @_; my $rc = 1; if( -d $src ) { # make sure $dest exisits if( !-d $dest ) { mkpath( $dest ); } # end if # copy each file, recursing subdirectories my $file; opendir(DIR, $src) || die "Error: Can not read directory $src: $!"; foreach $file (readdir(DIR)) { next if $file =~ /^\./; $file =~ s/\.dir$// if $^O eq 'VMS' && -d "$src/$file"; &install( $mode, "$src/$file", "$dest/$file" ); } # end foreach closedir DIR; } else { if( -d $dest ) { $dest .= $src; } # end if if( copy( $src, $dest ) ) { chmod( $mode, $dest ); } else { print "\t***Error: Can not copy $src to $dest. $!.\n"; $rc = 0; } # end if } # end if return $rc; } # end install