| 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 | use File::Find; |
|---|
| 33 | use Cwd; |
|---|
| 34 | use File::Copy; |
|---|
| 35 | use strict; |
|---|
| 36 | |
|---|
| 37 | my $enthralsvn = "http://svn.enthralbbs.com/trunk"; |
|---|
| 38 | my $origsysop = "Mercyful Fate"; |
|---|
| 39 | my $trunk = getcwd; |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | system("clear"); |
|---|
| 44 | print "Welcome to the Enthral BBS auto updater script.\n\n"; |
|---|
| 45 | print "This script will ask you for your Sysop Name and BBS Name and then\n"; |
|---|
| 46 | print "update your src to the latest build via svn, replace all instances of\n"; |
|---|
| 47 | print "the deafult sysop and bbs name and run configure, make clean, and\n"; |
|---|
| 48 | print "make for you. It will also compile snoop and stats.\n\n"; |
|---|
| 49 | print "This script assumes that you have already compiled husky's smapi library\n"; |
|---|
| 50 | print "and have the libsmapilnx.a library in your trunk path.\n\n"; |
|---|
| 51 | print "WARNING. This script was originally created for my own personal use.\n"; |
|---|
| 52 | print "I am not responsible for anything that it might cause to your Enthral\n"; |
|---|
| 53 | print "system. While I have done my best to ensure that the script functions as\n"; |
|---|
| 54 | print "promised, things may go wrong from time to time. Please ensure you make\n"; |
|---|
| 55 | print "a complete backup of your system before attempting to use this.\n\n"; |
|---|
| 56 | print "Are you ready to continue? (y/n): "; |
|---|
| 57 | |
|---|
| 58 | if (<STDIN> =~ /^[yY]/) |
|---|
| 59 | |
|---|
| 60 | { |
|---|
| 61 | print "\nSysop Name : "; |
|---|
| 62 | my $sysop = <>; |
|---|
| 63 | chomp ( $sysop ); |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | chdir "../"; |
|---|
| 67 | print "\nChecking SVN for any updates.\n"; |
|---|
| 68 | sleep 1; |
|---|
| 69 | system("svn --username svn co $enthralsvn") == 0 or die "SVN update failed ($?): $!"; |
|---|
| 70 | print "\nSVN check out succesfull. On to Sysop and BBS name replace.\n"; |
|---|
| 71 | sleep 1; |
|---|
| 72 | chdir "trunk/ini/"; |
|---|
| 73 | my $dir = getcwd; |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | print "\nSearching for: $origsysop\nReplacing with: $sysop\n\n"; |
|---|
| 78 | sleep 1; |
|---|
| 79 | find(\&wanted,$dir); |
|---|
| 80 | |
|---|
| 81 | print "\nFinished\n"; |
|---|
| 82 | sleep 1; |
|---|
| 83 | |
|---|
| 84 | sub wanted{ |
|---|
| 85 | |
|---|
| 86 | /\.ini$/ or return; |
|---|
| 87 | my $file=$_; |
|---|
| 88 | my $found = 0; |
|---|
| 89 | print "Searching $file.\n"; |
|---|
| 90 | open(INFILE,$file) or (print "Could not open $file for reading: $!\n" and return); |
|---|
| 91 | my @text=<INFILE>; |
|---|
| 92 | close(INFILE); |
|---|
| 93 | for(my $x=0;$x<=$#text;$x++){ |
|---|
| 94 | $text[$x]=~s/$origsysop/$sysop/g and $found = 1 and |
|---|
| 95 | print " -Found in $file (line ".($x+1).")\n"; |
|---|
| 96 | } |
|---|
| 97 | if($found){ |
|---|
| 98 | open(OUTFILE,">$file") or (print "Unable to open $file for writing: $!\n\t$file must be changed manually\n." and return); |
|---|
| 99 | foreach(@text){ |
|---|
| 100 | print OUTFILE $_; |
|---|
| 101 | } |
|---|
| 102 | close(OUTFILE); |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | sleep 1; |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | chdir $trunk; |
|---|
| 110 | print "\nRunning configure\n"; |
|---|
| 111 | sleep 1; |
|---|
| 112 | system "./configure"; |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | print "\nRunning make clean\n"; |
|---|
| 116 | sleep 1; |
|---|
| 117 | system "make clean"; |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | print "\nRunning make\n"; |
|---|
| 121 | sleep 1; |
|---|
| 122 | system "make"; |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | chdir "src/stats"; |
|---|
| 126 | print "\nCompiling Stats\n"; |
|---|
| 127 | system "g++ -o stats main.cpp process2.cpp userdat.cpp"; |
|---|
| 128 | sleep 1; |
|---|
| 129 | print "\nStats compile succsessful\n"; |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | chdir "../snoop"; |
|---|
| 133 | print "\nCompiling Snoop\n"; |
|---|
| 134 | system "g++ -o snoop snoop.cpp"; |
|---|
| 135 | sleep 1; |
|---|
| 136 | print "\nSnoop compile succsessful\n"; |
|---|
| 137 | |
|---|
| 138 | print "\nEnthral update and compalation complete.\n\n"; |
|---|
| 139 | } |
|---|