| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | my $smapiurl = "http://voxel.dl.sourceforge.net/sourceforge/husky/smapi-2.2.4-src.tar.gz"; |
|---|
| 14 | my $os = $^O; |
|---|
| 15 | my $origsysop = "Mercyful Fate"; |
|---|
| 16 | my $systemuser = "bbs"; |
|---|
| 17 | my $commentfield = "Enthral"; |
|---|
| 18 | my $homedir = "/home/$systemuser"; |
|---|
| 19 | use File::Copy; |
|---|
| 20 | use File::Find; |
|---|
| 21 | use Cwd; |
|---|
| 22 | my $trunk = getcwd; |
|---|
| 23 | $|=1; |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | my $name = `whoami`; |
|---|
| 27 | chomp ( $name ); |
|---|
| 28 | if ($name ne "root") { die "\nYou must be root in order to install Enthral.\n\n"; } |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | system("clear"); |
|---|
| 32 | print "Welcome to the Enthral BBS install script.\r\n"; |
|---|
| 33 | print " - Build 429 Alpha Install process (10/18/2010).\r\n\r\n"; |
|---|
| 34 | |
|---|
| 35 | print "This script will ask you for your Sysop Name and BBS Name and\r\n"; |
|---|
| 36 | print "then download and compile smpai (which is required for JAM Message Areas),\r\n"; |
|---|
| 37 | print "add the sysop name to the config.ini file, and compile snoop and stats.\r\n"; |
|---|
| 38 | print "The script will also create a new user called \"enthral\" which will be the\r\n"; |
|---|
| 39 | print "primary user that Enthral runs off\r\n\r\n"; |
|---|
| 40 | |
|---|
| 41 | print "WARNING. We am not responsible for anything that might occur with your\r\n"; |
|---|
| 42 | print "system. While we have done our best to ensure that the script functions as\r\n"; |
|---|
| 43 | print "promised, things may go wrong from time to time. Please ensure you make\r\n"; |
|---|
| 44 | print "a complete backup of your system before attempting to use this.\r\n\r\n"; |
|---|
| 45 | |
|---|
| 46 | print "Are you ready to continue? (y/n): "; |
|---|
| 47 | |
|---|
| 48 | if (<STDIN> =~ /^[yY]/) |
|---|
| 49 | { |
|---|
| 50 | print "\r\nSysop Name/Handle (Has to match exactly what you plan on using) \r\n[Sysop Name]: "; |
|---|
| 51 | my $sysop = <>; |
|---|
| 52 | chomp ( $sysop ); |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | chdir "ini/"; |
|---|
| 56 | my $dir = getcwd; |
|---|
| 57 | print "\r\n[*] Replacing $origsysop with $sysop in config.ini\r\n\r\n"; |
|---|
| 58 | sleep 2; |
|---|
| 59 | find(\&wanted,$dir); |
|---|
| 60 | |
|---|
| 61 | print "\r\n[*] Finished\r\n"; |
|---|
| 62 | sleep 2; |
|---|
| 63 | |
|---|
| 64 | sub wanted{ |
|---|
| 65 | |
|---|
| 66 | /\.ini$/ or return; |
|---|
| 67 | my $file=$_; |
|---|
| 68 | my $found = 0; |
|---|
| 69 | print "Searching $file.\n"; |
|---|
| 70 | open(INFILE,$file) or (print "Could not open $file for reading: $!\r\n" and return); |
|---|
| 71 | my @text=<INFILE>; |
|---|
| 72 | close(INFILE); |
|---|
| 73 | for(my $x=0;$x<=$#text;$x++){ |
|---|
| 74 | $text[$x]=~s/$origsysop/$sysop/g and $found = 1 and |
|---|
| 75 | print " -Found in $file (line ".($x+1).")\r\n"; |
|---|
| 76 | } |
|---|
| 77 | if($found){ |
|---|
| 78 | open(OUTFILE,">$file") or (print "Unable to open $file for writing: $!\r\n\t$file must be changed manually\r\n." and return); |
|---|
| 79 | foreach(@text){ |
|---|
| 80 | print OUTFILE $_; |
|---|
| 81 | } |
|---|
| 82 | close(OUTFILE); |
|---|
| 83 | } |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | sleep 2; |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | chdir $trunk; |
|---|
| 90 | |
|---|
| 91 | $count = `awk -F":" '{print \$3}' /etc/passwd|sort -n|tail -1`; |
|---|
| 92 | chomp($count); |
|---|
| 93 | $usernumber = ++$count; |
|---|
| 94 | |
|---|
| 95 | open(A, ">>/etc/passwd"); |
|---|
| 96 | print A "$systemuser:x:$usernumber:$usernumber:$systemuser,,,:$homedir:/bin/bash\n"; |
|---|
| 97 | close(A); |
|---|
| 98 | |
|---|
| 99 | open(A, ">>/etc/group"); |
|---|
| 100 | print A "$systemuser:x:$usernumber:\n"; |
|---|
| 101 | close(A); |
|---|
| 102 | |
|---|
| 103 | open(A, ">>/etc/shadow"); |
|---|
| 104 | print A "$systemuser:*LK*:::::::\n"; |
|---|
| 105 | close(A); |
|---|
| 106 | |
|---|
| 107 | mkdir($homedir, 0755); |
|---|
| 108 | |
|---|
| 109 | print "\r\n[*] Password for user $systemuser\r\n\r\n"; |
|---|
| 110 | system("/usr/bin/passwd $systemuser"); |
|---|
| 111 | print "\r\n"; |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | chdir $trunk; |
|---|
| 115 | print "\r\n[*] Downloading smapi-2.2.4-src.tar.gz\r\n"; |
|---|
| 116 | sleep 1; |
|---|
| 117 | |
|---|
| 118 | mkdir("/tmp/enthral", 0777) || print $!; |
|---|
| 119 | mkdir("smapi_src", 0777) || print $!; |
|---|
| 120 | chdir "smapi_src/"; |
|---|
| 121 | system "wget $smapiurl"; |
|---|
| 122 | |
|---|
| 123 | system "tar xzvf smapi-2.2.4-src.tar.gz"; |
|---|
| 124 | unlink <*.tar.gz*>; |
|---|
| 125 | print "\r\n[*] smapi-2.2.4-src.tar.gz successfully downloaded and unpacked.\r\n"; |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | chdir "smapi/"; |
|---|
| 129 | |
|---|
| 130 | sleep 1; |
|---|
| 131 | |
|---|
| 132 | print "\r\n[*] Compiling Husky SMAPI Lib for JAM Message Support.\r\n"; |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | copy("makefile.lnx","Makefile") or die "Copy failed: $!"; |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | my $foundIt = 0; |
|---|
| 139 | print "\r\n[*] Searching Makefile.\n"; |
|---|
| 140 | open(INFILE,"Makefile") or (print "Could not open Makefile for reading\r\n" and return); |
|---|
| 141 | |
|---|
| 142 | my @text=<INFILE>; |
|---|
| 143 | close(INFILE); |
|---|
| 144 | |
|---|
| 145 | for(my $x=0;$x<=$#text;$x++){ |
|---|
| 146 | $text[$x]=~s/-DNOSEMAPHORES/-DNOSEMAPHORES -U_FORTIFY_SOURCE -m32 /g and $foundIt = 1 and |
|---|
| 147 | print " -Added -U_FORTIFY_SOURCE -m32 for gcc 4.3+ and 64 bit compability (line ".($x+1).")\n"; |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | if($foundIt){ |
|---|
| 151 | open(OUTFILE,">Makefile") or (print "must be changed manually\r\n." and return); |
|---|
| 152 | print OUTFILE @text; |
|---|
| 153 | close(OUTFILE); |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | sleep 2; |
|---|
| 157 | |
|---|
| 158 | system "make"; |
|---|
| 159 | |
|---|
| 160 | print "\r\n[*] libsmapilnx.a compiled successfully. Moving to compile Enthral.\r\n"; |
|---|
| 161 | copy("libsmapilnx.a","../../src/libsmapilnx.a") or die "Copy failed: $!"; |
|---|
| 162 | chdir "../../"; |
|---|
| 163 | |
|---|
| 164 | sleep 1; |
|---|
| 165 | |
|---|
| 166 | print "\r\n[*] Building Base Enthral System...\r\n"; |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | print "\r\n[*] Cleaning Root directory\r\n"; |
|---|
| 170 | sleep 1; |
|---|
| 171 | system "rm -f m4/{lt,lib}*.m4"; |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | print "\r\n[*] Running AutoMake (Autogen.sh)\r\n"; |
|---|
| 175 | sleep 1; |
|---|
| 176 | system "./autogen.sh"; |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | print "\r\n[*] Running configure\r\n"; |
|---|
| 180 | sleep 1; |
|---|
| 181 | system "make distclean"; |
|---|
| 182 | system "./configure"; |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | print "\r\n[*] Running make distclean\r\n"; |
|---|
| 186 | sleep 1; |
|---|
| 187 | system "make clean"; |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | print "\r\n[*] Running make\r\n"; |
|---|
| 191 | sleep 1; |
|---|
| 192 | system "make"; |
|---|
| 193 | |
|---|
| 194 | sleep 2; |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | chdir "src/stats"; |
|---|
| 198 | print "\r\n[*] Compiling Stats Program. You will need to update main.txt for your paths!\n"; |
|---|
| 199 | system "g++ -o stats main.cpp process2.cpp userdat.cpp"; |
|---|
| 200 | sleep 1; |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | chdir "../snoop"; |
|---|
| 204 | print "\r\n[*] Compiling Snoop, basic console program.\r\n"; |
|---|
| 205 | system "g++ -o snoop snoop.cpp"; |
|---|
| 206 | sleep 1; |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | chdir "../ddtelnetd"; |
|---|
| 210 | print "\r\n[*] Compiling ddtelnetd, telnet server.\r\n"; |
|---|
| 211 | system("g++ -o ddtelnetd ddtelnetd.c -lutil"); |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | print "\r\n[*] Moving everything to $homedir\r\n"; |
|---|
| 215 | mkdir("$homedir/source"); |
|---|
| 216 | system("mv $trunk/* $homedir/source/"); |
|---|
| 217 | |
|---|
| 218 | mkdir("$homedir/enthral", 0777); |
|---|
| 219 | mkdir("$homedir/enthral/stats", 0777); |
|---|
| 220 | system("mv $homedir/source/src/ddtelnetd/ddtelnetd $homedir/source/src/ansi $homedir/source/src/dareas $homedir/source/src/data $homedir/source/src/enthral $homedir/source/src/files $homedir/source/src/ini $homedir/source/src/lock $homedir/source/src/menu $homedir/source/src/msgs $homedir/source/src/node $homedir/source/src/scripts $homedir/source/src/usersig $homedir/source/src/snoop/snoop $homedir/enthral/"); |
|---|
| 221 | copy("$homedir/source/src/stats/stats","$homedir/enthral/stats/"); |
|---|
| 222 | copy("$homedir/source/src/stats/toppc.ans","$homedir/enthral/stats/"); |
|---|
| 223 | copy("$homedir/source/src/stats/topud.ans","$homedir/enthral/stats/"); |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | system "chown -R $systemuser:$systemuser $homedir"; |
|---|
| 227 | system "chmod -R 0777 $homedir"; |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | print "\r\n[*] Checking if your system uses inetd or xinetd.\r\n\r\n"; |
|---|
| 231 | if (-e "/etc/inetd.conf") { |
|---|
| 232 | print "[*] inetd found. Adding ddtelnetd to inetd.conf\r\n"; |
|---|
| 233 | open(A, ">>/etc/inetd.conf"); |
|---|
| 234 | print A "# enthral telnet server setup\n"; |
|---|
| 235 | print A "telnet stream tcp nowait root $homedir/enthral/ddtelnetd -u $systemuser -l $homedir/enthral/enthral\n"; |
|---|
| 236 | close(A); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | if (-d "/etc/xinetd.d") { |
|---|
| 240 | print "[*] xinetd found. Adding ddtelnetd to xinetd.d\r\n"; |
|---|
| 241 | |
|---|
| 242 | open INPUTFILE, "<", "$homedir/source/src/ddtelnetd/telnet" or die $!; |
|---|
| 243 | open OUTPUTFILE, ">", "/etc/xinetd.d/telnet" or die $!; |
|---|
| 244 | |
|---|
| 245 | while (<INPUTFILE>) { |
|---|
| 246 | $_ =~ s/\/path\/to\//$homedir\/enthral\//g; |
|---|
| 247 | print OUTPUTFILE $_; |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | print "\r\n[*] Finished Install.\r\n"; |
|---|
| 253 | print "\r\n[*] Source Files loacated in the $homedir/source/ folder\r\n"; |
|---|
| 254 | print "\r\n[*] Main system located in the $homedir/enthral/ folder\r\n\r\n"; |
|---|
| 255 | |
|---|
| 256 | print "Remember this is still a rough Alpha and a Work in Progress.\r\n"; |
|---|
| 257 | sleep 2; |
|---|
| 258 | |
|---|
| 259 | print "\r\nCongradulations, Enthral compile complete.\r\n"; |
|---|
| 260 | print "Please restart your system so that the services can take effect\r\n"; |
|---|
| 261 | |
|---|
| 262 | print "For support, drop by irc.bbs-scene.org #enthral and #bbs.\r\n\r\n"; |
|---|
| 263 | |
|---|
| 264 | } |
|---|