root/source/install.pl

Revision 169, 7.9 kB (checked in by frank, 19 months ago)

Fixed a typo in install.pl

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy Id
Line 
1#! /usr/bin/perl -w
2
3# Enthral SVN: $Id$
4# Source: $HeadURL: http://svn.enthralbbs.com/trunk/install.pl $
5# $LastChangedDate$
6# $LastChangedRevision$
7# $LastChangedBy$
8
9# Enthral BBS Auto Install script
10
11# Standard variables and system requests
12
13my $smapiurl = "http://voxel.dl.sourceforge.net/sourceforge/husky/smapi-2.2.4-src.tar.gz";
14my $os = $^O;
15my $origsysop = "Mercyful Fate";
16my $systemuser = "bbs";
17my $commentfield = "Enthral";
18my $homedir = "/home/$systemuser";
19use File::Copy;
20use File::Find;
21use Cwd;
22my $trunk = getcwd;
23$|=1;
24
25# Make sure user is root
26my $name = `whoami`;
27chomp ( $name );
28if ($name ne "root") { die "\nYou must be root in order to install Enthral.\n\n"; }
29
30# Capture User Input
31system("clear");
32print "Welcome to the Enthral BBS install script.\r\n";
33print " - Build 429 Alpha Install process (10/18/2010).\r\n\r\n";
34
35print "This script will ask you for your Sysop Name and BBS Name and\r\n";
36print "then download and compile smpai (which is required for JAM Message Areas),\r\n";
37print "add the sysop name to the config.ini file, and compile snoop and stats.\r\n";
38print "The script will also create a new user called \"enthral\" which will be the\r\n";
39print "primary user that Enthral runs off\r\n\r\n";
40
41print "WARNING. We am not responsible for anything that might occur with your\r\n";
42print "system.  While we have done our best to ensure that the script functions as\r\n";
43print "promised, things may go wrong from time to time.  Please ensure you make\r\n";
44print "a complete backup of your system before attempting to use this.\r\n\r\n";
45
46print "Are you ready to continue? (y/n): ";
47
48if (<STDIN> =~ /^[yY]/)
49{
50print "\r\nSysop Name/Handle (Has to match exactly what you plan on using) \r\n[Sysop Name]: ";
51my $sysop = <>;
52chomp ( $sysop );
53
54# Replace Sysop Name in config.ini
55chdir "ini/";
56my $dir = getcwd;
57print "\r\n[*] Replacing $origsysop with $sysop in config.ini\r\n\r\n";
58sleep 2;
59find(\&wanted,$dir);
60
61print "\r\n[*] Finished\r\n";
62sleep 2;
63
64sub wanted{
65#       (-f $_ && -w $_ && -T $_) or return;
66        /\.ini$/ or return;
67        my $file=$_;
68        my $found = 0; # If the string was found in $file
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
86sleep 2;
87
88# add user enthral
89chdir $trunk;
90
91$count = `awk -F":" '{print \$3}' /etc/passwd|sort -n|tail -1`;
92chomp($count);
93$usernumber = ++$count;
94
95open(A, ">>/etc/passwd");
96print A "$systemuser:x:$usernumber:$usernumber:$systemuser,,,:$homedir:/bin/bash\n";
97close(A);
98
99open(A, ">>/etc/group");
100print A "$systemuser:x:$usernumber:\n";
101close(A);
102
103open(A, ">>/etc/shadow");
104print A "$systemuser:*LK*:::::::\n";
105close(A);
106
107mkdir($homedir, 0755);
108
109print "\r\n[*] Password for user $systemuser\r\n\r\n";
110system("/usr/bin/passwd $systemuser");
111print "\r\n";
112
113# Download and unpack smapi 2.2
114chdir $trunk;
115print "\r\n[*] Downloading smapi-2.2.4-src.tar.gz\r\n";
116sleep 1;
117
118mkdir("/tmp/enthral", 0777) || print $!;
119mkdir("smapi_src", 0777) || print $!;
120chdir "smapi_src/";
121system "wget $smapiurl";
122
123system "tar xzvf smapi-2.2.4-src.tar.gz";
124unlink <*.tar.gz*>;
125print "\r\n[*] smapi-2.2.4-src.tar.gz successfully downloaded and unpacked.\r\n";
126
127# Configuring smapi
128chdir "smapi/";
129
130sleep 1;
131
132print "\r\n[*] Compiling Husky SMAPI Lib for JAM Message Support.\r\n";
133
134# makefile.lnx compiles for both linux and bsd.
135copy("makefile.lnx","Makefile") or die "Copy failed: $!";
136
137# Add special compiler flags to SMAPI for compile on gcc 4.3+ and 64 Bit Systems.
138my $foundIt = 0; # If the string was found in $file
139print "\r\n[*] Searching Makefile.\n";
140open(INFILE,"Makefile") or (print "Could not open Makefile for reading\r\n" and return);
141
142my @text=<INFILE>;
143close(INFILE);
144
145for(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
150if($foundIt){
151    open(OUTFILE,">Makefile") or (print "must be changed manually\r\n." and return);
152    print OUTFILE @text;
153    close(OUTFILE);
154}
155
156sleep 2;
157
158system "make";
159
160print "\r\n[*] libsmapilnx.a compiled successfully.  Moving to compile Enthral.\r\n";
161copy("libsmapilnx.a","../../src/libsmapilnx.a") or die "Copy failed: $!";
162chdir "../../";
163
164sleep 1;
165
166print "\r\n[*] Building Base Enthral System...\r\n";
167
168# Cleaning any left over files
169print "\r\n[*] Cleaning Root directory\r\n";
170sleep 1;
171system "rm -f m4/{lt,lib}*.m4";
172
173# run AutoMake
174print "\r\n[*] Running AutoMake (Autogen.sh)\r\n";
175sleep 1;
176system "./autogen.sh";
177
178# run Configure
179print "\r\n[*] Running configure\r\n";
180sleep 1;
181system "make distclean";
182system "./configure";
183
184# run make clean
185print "\r\n[*] Running make distclean\r\n";
186sleep 1;
187system "make clean";
188
189# run make
190print "\r\n[*] Running make\r\n";
191sleep 1;
192system "make";
193
194sleep 2;
195
196# compile stats
197chdir "src/stats";
198print "\r\n[*] Compiling Stats Program. You will need to update main.txt for your paths!\n";
199system "g++ -o stats main.cpp process2.cpp userdat.cpp";
200sleep 1;
201
202# compile snoop
203chdir "../snoop";
204print "\r\n[*] Compiling Snoop, basic console program.\r\n";
205system "g++ -o snoop snoop.cpp";
206sleep 1;
207
208# compile ddtelnetd
209chdir "../ddtelnetd";
210print "\r\n[*] Compiling ddtelnetd, telnet server.\r\n";
211system("g++ -o ddtelnetd ddtelnetd.c -lutil");
212
213# move system to new homedir
214print "\r\n[*] Moving everything to $homedir\r\n";
215mkdir("$homedir/source");
216system("mv $trunk/* $homedir/source/");
217
218mkdir("$homedir/enthral", 0777);
219mkdir("$homedir/enthral/stats", 0777);
220system("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/");
221copy("$homedir/source/src/stats/stats","$homedir/enthral/stats/");
222copy("$homedir/source/src/stats/toppc.ans","$homedir/enthral/stats/");
223copy("$homedir/source/src/stats/topud.ans","$homedir/enthral/stats/");
224
225# set permissions and ownership
226system "chown -R $systemuser:$systemuser $homedir";
227system "chmod -R 0777 $homedir";
228
229# check which services manager is running
230print "\r\n[*] Checking if your system uses inetd or xinetd.\r\n\r\n";
231if (-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
239if (-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
252print "\r\n[*] Finished Install.\r\n";
253print "\r\n[*] Source Files loacated in the $homedir/source/ folder\r\n";
254print "\r\n[*] Main system located in the $homedir/enthral/ folder\r\n\r\n";
255
256print "Remember this is still a rough Alpha and a Work in Progress.\r\n";
257sleep 2;
258
259print "\r\nCongradulations, Enthral compile complete.\r\n";
260print "Please restart your system so that the services can take effect\r\n";
261
262print "For support, drop by irc.bbs-scene.org #enthral and #bbs.\r\n\r\n";
263
264}
Note: See TracBrowser for help on using the browser.