1 |
--- smeserver-oats-2.0.3/root/etc/e-smith/db/configuration/migrate/80oats.db_httpd_templates-01 2006-12-17 15:58:52.000000000 -0700 |
2 |
+++ smeserver-oats-2.0.3/root/etc/e-smith/db/configuration/migrate/80oats 2008-02-01 15:18:54.000000000 -0700 |
3 |
@@ -1,37 +1,10 @@ |
4 |
{ |
5 |
- my $rec = $DB->get('oats') |
6 |
- || $DB->new_record('oats', {type => 'service'}); |
7 |
- |
8 |
- my $pw = $rec->prop('DbPassword'); |
9 |
- |
10 |
- return "" if $pw; |
11 |
- if (not $pw or length($pw) < 57) |
12 |
- { |
13 |
- use MIME::Base64 qw(encode_base64); |
14 |
- |
15 |
- $pw = "not set due to error"; |
16 |
- |
17 |
- if ( open( RANDOM, "/dev/urandom" ) ) |
18 |
- { |
19 |
- my $buf; |
20 |
- # 57 bytes is a full line of Base64 coding, and contains |
21 |
- # 456 bits of randomness - given a perfectly random /dev/random |
22 |
- if ( read( RANDOM, $buf, 57 ) != 57 ) |
23 |
- { |
24 |
- warn("Short read from /dev/random: $!"); |
25 |
- } |
26 |
- else |
27 |
- { |
28 |
- $pw = encode_base64($buf); |
29 |
- chomp $pw; |
30 |
- } |
31 |
- close RANDOM; |
32 |
- } |
33 |
- else |
34 |
- { |
35 |
- warn "Could not open /dev/urandom: $!"; |
36 |
- } |
37 |
- |
38 |
- $rec->set_prop('DbPassword', $pw); |
39 |
- } |
40 |
+ use MIME::Base64 qw(encode_base64); |
41 |
+ |
42 |
+ my $rec = $DB->get('oats') || $DB->new_record('oats', {type => 'service'}); |
43 |
+ |
44 |
+ my $pw = $rec->prop('DbPassword'); |
45 |
+ return "" if $pw; |
46 |
+ |
47 |
+ $rec->set_prop('DbPassword', sprintf("%15.0f", int( (1000000000000000) * rand() ))); |
48 |
} |
49 |
--- smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/88OptDomainOats.db_httpd_templates-01 2008-02-01 17:20:44.000000000 -0700 |
50 |
+++ smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/88OptDomainOats 2008-02-01 17:33:06.000000000 -0700 |
51 |
@@ -0,0 +1,24 @@ |
52 |
+{ |
53 |
+ my $status = $oats{'status'} || "disabled"; |
54 |
+ return " # oats-status is disabled.\n" |
55 |
+ unless $status eq 'enabled'; |
56 |
+ |
57 |
+ my $domain = $oats{'domain'} || "disabled"; |
58 |
+ return " # no hostname or domain for oats defined\n" |
59 |
+ if $domain eq 'disabled'; |
60 |
+ |
61 |
+ my $DocRoot = "/opt/oats"; |
62 |
+ |
63 |
+ $OUT = ""; |
64 |
+ $OUT .= "\n"; |
65 |
+ $OUT .= "# Redirect an existing hostname or domain to $DocRoot.\n"; |
66 |
+ $OUT .=<VirtualHost 0.0.0.0:80>\n"; |
67 |
+ $OUT .= ServerName $domain\n"; |
68 |
+ $OUT .= DocumentRoot $DocRoot\n"; |
69 |
+ $OUT .=</VirtualHost>\n"; |
70 |
+ $OUT .=<VirtualHost 0.0.0.0:443>\n"; |
71 |
+ $OUT .= ServerName $domain\n"; |
72 |
+ $OUT .= DocumentRoot $DocRoot\n"; |
73 |
+ $OUT .= SSLEngine on\n"; |
74 |
+ $OUT .=</VirtualHost>\n"; |
75 |
+} |
76 |
--- smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/30oatsAlias.db_httpd_templates-01 2008-02-01 17:34:39.000000000 -0700 |
77 |
+++ smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/30oatsAlias 2008-02-01 17:38:20.000000000 -0700 |
78 |
@@ -0,0 +1,10 @@ |
79 |
+{ |
80 |
+ my $status = $oats{'status'} || "disabled"; |
81 |
+ return " # oats is disabled in this VirtualHost" |
82 |
+ unless $status eq 'enabled'; |
83 |
+ |
84 |
+ if ($port eq "443") |
85 |
+ { |
86 |
+ $OUT .= " ProxyPass /oats http://127.0.0.1/oats\n"; |
87 |
+ } |
88 |
+} |
89 |
--- smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/e-smith/sql/init/80oats.sql.db_httpd_templates-01 2007-01-19 18:22:14.000000000 -0700 |
90 |
+++ smeserver-oats-2.0.3/root/etc/e-smith/templates/etc/e-smith/sql/init/80oats.sql 2008-02-01 16:51:13.000000000 -0700 |
91 |
@@ -1,18 +1,20 @@ |
92 |
-# Create the user account and password. (This is harmless if the |
93 |
-# user account and password already exist.) Note the reference |
94 |
-# to the 'moodle' database which will be created in the next |
95 |
-# few statements. |
96 |
- |
97 |
-USE mysql; |
98 |
- |
99 |
-REPLACE INTO user (host, user, password) |
100 |
- VALUES ('localhost', 'oats', PASSWORD ('{ $oats{DbPassword} }')); |
101 |
- |
102 |
-REPLACE INTO db (host, db, user, select_priv, insert_priv, update_priv, delete_priv, create_priv, create_tmp_table_priv, drop_priv, index_priv, alter_priv ) |
103 |
- VALUES ('localhost', 'oats', 'oats', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y'); |
104 |
- |
105 |
-FLUSH PRIVILEGES; |
106 |
- |
107 |
-# Create 'oats' database. (Do nothing if the database already exists.) |
108 |
- |
109 |
-CREATE DATABASE IF NOT EXISTS oats; |
110 |
+{ |
111 |
+ my $db = $oats{DbName} || 'oats'; |
112 |
+ my $user = $oats{DbUser} || 'oats'; |
113 |
+ my $pass = $oats{DbPassword} || 'pleasechangeme'; |
114 |
+ OUT .= <<END |
115 |
+#! /bin/sh |
116 |
+ if [ -d /var/lib/mysql/$db ]; then |
117 |
+ exit |
118 |
+ fi |
119 |
+ /usr/bin/mysql <<EOF |
120 |
+ CREATE DATABASE $db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; |
121 |
+ use $db; |
122 |
+ # |
123 |
+ use mysql; |
124 |
+ GRANT ALL PRIVILEGES ON $db.* TO $useer\@localhost |
125 |
+ IDENTIFIED BY '$pass'; |
126 |
+ flush privileges; |
127 |
+EOF |
128 |
+END |
129 |
+} |
130 |
\ No newline at end of file |