[127] | 1 | #!/usr/bin/perl |
---|
| 2 | use strict; |
---|
[1222] | 3 | use FindBin qw($Bin); |
---|
| 4 | use lib $Bin; |
---|
[127] | 5 | use onserver; |
---|
[474] | 6 | use File::Path; |
---|
[127] | 7 | |
---|
| 8 | setup(); |
---|
| 9 | |
---|
| 10 | print "\nPlease decide upon a title for your site and enter it below.\n"; |
---|
| 11 | print "Desired title: "; |
---|
| 12 | my $title = <STDIN>; |
---|
| 13 | chomp($title); |
---|
| 14 | |
---|
[1207] | 15 | print "\nSetting up your configuration file...\n"; |
---|
| 16 | open CONFIGTEMPLATE, "configuration.php-dist"; |
---|
| 17 | open CONFIGURATION, ">configuration.php"; |
---|
| 18 | while (<CONFIGTEMPLATE>) { |
---|
| 19 | chomp; |
---|
| 20 | if (/var \$sitename /) { |
---|
| 21 | $_ = " var \$sitename = '$title';"; |
---|
| 22 | } elsif (/var \$dbtype /) { |
---|
| 23 | $_ = " var \$dbtype = 'mysql';"; |
---|
| 24 | } elsif (/var \$host /) { |
---|
| 25 | $_ = " var \$host = '$sqlhost';"; |
---|
| 26 | } elsif (/var \$user /) { |
---|
| 27 | $_ = " var \$user = '$sqluser';"; |
---|
| 28 | } elsif (/var \$password /) { |
---|
| 29 | $_ = " var \$password = '$sqlpass';"; |
---|
| 30 | } elsif (/var \$db /) { |
---|
| 31 | $_ = " var \$db = '$sqldb';"; |
---|
| 32 | } elsif (/var \$dbprefix /) { |
---|
| 33 | $_ = " var \$dbprefix = 'jos_';"; |
---|
| 34 | } elsif (/var \$secret /) { |
---|
| 35 | my $random = `dd if=/dev/urandom bs=1k count=1 | md5sum | cut -c1-32`; |
---|
| 36 | $random =~ s/\n//; |
---|
| 37 | $_ = " var \$secret = '$random';"; |
---|
| 38 | } elsif (/var \$mailfrom /) { |
---|
| 39 | $_ = " var \$mailfrom = '$email';"; |
---|
| 40 | } elsif (/var \$fromname /) { |
---|
| 41 | $_ = " var \$fromname = '$title';"; |
---|
| 42 | } |
---|
| 43 | print CONFIGURATION "$_\n"; |
---|
| 44 | } |
---|
| 45 | close CONFIGURATION; |
---|
| 46 | close CONFIGTEMPLATE; |
---|
[127] | 47 | |
---|
[1207] | 48 | print "\nInitializing database schema...\n"; |
---|
| 49 | my $schemafile = "installation/sql/mysql/joomla-real.sql"; |
---|
| 50 | open SCHEMATEMPLATE, "installation/sql/mysql/joomla.sql"; |
---|
| 51 | open SCHEMA, ">$schemafile"; |
---|
| 52 | while (<SCHEMATEMPLATE>) { |
---|
| 53 | if (/#__/) { |
---|
| 54 | $_ =~ s/#__/jos_/g; |
---|
| 55 | } |
---|
| 56 | print SCHEMA "$_"; |
---|
| 57 | } |
---|
| 58 | close SCHEMA; |
---|
| 59 | close SCHEMATEMPLATE; |
---|
| 60 | system("cat $schemafile | mysql $sqldb"); |
---|
[472] | 61 | |
---|
[1207] | 62 | print "\nLoading sample data...\n"; |
---|
| 63 | my $sampledatafile = "installation/sql/mysql/sample_data-real.sql"; |
---|
| 64 | open SAMPLETEMPLATE, "installation/sql/mysql/sample_data.sql"; |
---|
| 65 | open SAMPLE, ">$sampledatafile"; |
---|
| 66 | while (<SAMPLETEMPLATE>) { |
---|
| 67 | if (/#__/) { |
---|
| 68 | $_ =~ s/#__/jos_/g; |
---|
| 69 | } |
---|
| 70 | print SAMPLE "$_"; |
---|
| 71 | } |
---|
| 72 | close SAMPLE; |
---|
| 73 | close SAMPLETEMPLATE; |
---|
| 74 | system("cat $sampledatafile | mysql $sqldb"); |
---|
| 75 | |
---|
| 76 | print "\nCreating your admin account...\n"; |
---|
| 77 | system("mysql -e \"INSERT INTO jos_users VALUES (62, 'Administrator', '$admin_username', '$email', MD5('$admin_password'), 'Super Administrator', 0, 1, 25, NOW(), NOW(), '', '')\" $sqldb"); |
---|
| 78 | system("mysql -e \"INSERT INTO jos_core_acl_aro VALUES (10, 'users', '62', 0, 'Administrator', 0)\" $sqldb"); |
---|
| 79 | system("mysql -e \"INSERT INTO jos_core_acl_groups_aro_map VALUES (25, '', 10)\" $sqldb"); |
---|
| 80 | |
---|
| 81 | print "\nCleaning up installation tree...\n"; |
---|
[697] | 82 | rmtree('installation'); |
---|
[1207] | 83 | |
---|
| 84 | print "\nDone!\n"; |
---|
| 85 | exit 0; |
---|
| 86 | |
---|