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