annotate DVN-web/installer/dvninstall/install~ @ 6:1b2188262ae9

adding the installer.
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Wed, 13 May 2015 11:50:21 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1 #!/usr/bin/perl
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
2
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
3 use Getopt::Long;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
4 use Socket;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
5 use File::Copy;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
6
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
7 my( %opts ) = ( );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
8 my( $rez ) = GetOptions( \%opts, "pg_only!");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
9
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
10 my $postgresonly = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
11
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
12 my @CONFIG_VARIABLES = ();
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
13
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
14 unless ($opts{pg_only})
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
15 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
16 @CONFIG_VARIABLES = (
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
17 'HOST_DNS_ADDRESS',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
18 'GLASSFISH_DIRECTORY',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
19 'MAIL_SERVER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
20
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
21 'POSTGRES_SERVER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
22 'POSTGRES_PORT',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
23 'POSTGRES_DATABASE',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
24 'POSTGRES_USER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
25 'POSTGRES_PASSWORD',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
26
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
27 'RSERVE_HOST',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
28 'RSERVE_PORT',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
29 'RSERVE_USER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
30 'RSERVE_PASSWORD'
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
31
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
32 );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
33 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
34 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
35 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
36 @CONFIG_VARIABLES = (
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
37 'POSTGRES_SERVER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
38 'POSTGRES_PORT',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
39 'POSTGRES_DATABASE',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
40 'POSTGRES_USER',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
41 'POSTGRES_PASSWORD'
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
42 );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
43
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
44 $postgresonly = 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
45 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
46
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
47 my %CONFIG_DEFAULTS =
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
48 (
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
49 'HOST_DNS_ADDRESS', '',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
50 'GLASSFISH_DIRECTORY', '/home/glassfish/glassfish',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
51 'MAIL_SERVER', 'localhost',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
52
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
53 'POSTGRES_SERVER', 'localhost',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
54 'POSTGRES_PORT', 5432,
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
55 'POSTGRES_DATABASE','dvnDb',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
56 'POSTGRES_USER', 'postgres',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
57 'POSTGRES_PASSWORD','admin',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
58
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
59 'RSERVE_HOST', 'localhost',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
60 'RSERVE_PORT', 6311,
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
61 'RSERVE_USER', 'rserve',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
62 'RSERVE_PASSWORD', 'rserve'
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
63
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
64 );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
65
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
66
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
67 my %CONFIG_PROMPTS =
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
68 (
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
69 'HOST_DNS_ADDRESS', 'Internet Address of your host',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
70 'GLASSFISH_DIRECTORY', 'Glassfish Directory',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
71 'MAIL_SERVER', 'SMTP (mail) server to relay notification messages',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
72
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
73 'POSTGRES_SERVER', 'Postgres Server',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
74 'POSTGRES_PORT', 'Postgres Server Port',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
75 'POSTGRES_DATABASE','Name of the Postgres Database',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
76 'POSTGRES_USER', 'Name of the Postgres User',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
77 'POSTGRES_PASSWORD','Postgres user password',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
78
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
79 'RSERVE_HOST', 'Rserve Server',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
80 'RSERVE_PORT', 'Rserve Server Port',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
81 'RSERVE_USER', 'Rserve User Name',
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
82 'RSERVE_PASSWORD', 'Rserve User Password'
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
83
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
84 );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
85
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
86 # Supported Posstgres JDBC drivers:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
87 # (have to be configured explicitely, so that Perl "taint" (security) mode
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
88 # doesn't get paranoid)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
89
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
90 my $POSTGRES_DRIVER_8_3 = "postgresql-8.3-603.jdbc4.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
91 #my $POSTGRES_DRIVER_8_4 = "postgresql-8.4-703.jdbc4.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
92 my $POSTGRES_DRIVER_8_4 = "postgresql-8.3-603.jdbc4.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
93 my $POSTGRES_DRIVER_9_0 = "postgresql-9.0-802.jdbc4.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
94 my $POSTGRES_DRIVER_9_1 = "postgresql-9.1-902.jdbc4.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
95
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
96
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
97 # A few preliminary checks:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
98
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
99 # user -- must be root:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
100
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
101 $user_real = `who am i`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
102 chop $user_real;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
103 $user_real =~s/ .*$//;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
104
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
105 if ( $< != 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
106 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
107 print STDERR "\nERROR: You must be logged in as root to run the installer.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
108 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
109 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
110
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
111 # OS:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
112
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
113 my $uname_out = `uname -a`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
114
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
115 # hostname:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
116
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
117 my $hostname_from_cmdline = `hostname`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
118 chop $hostname_from_cmdline;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
119
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
120 $CONFIG_DEFAULTS{'HOST_DNS_ADDRESS'} = $hostname_from_cmdline;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
121
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
122
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
123 print "\nWelcome to the DVN installer.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
124 unless ($opts{pg_only})
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
125 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
126 print "You will be guided through the process of setting up a NEW\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
127 print "instance of the DVN application\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
128 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
129 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
130 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
131 print "You will be guided through the process of configuring the\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
132 print "LOCAL instance of PostgreSQL database for use by the DVN\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
133 print "application.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
134 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
135
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
136 my @uname_tokens = split (" ", $uname_out);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
137
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
138 if ( $uname_tokens[0] eq "Darwin" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
139 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
140 print "\nThis appears to be a MacOS X system; good.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
141 # TODO: check the OS version
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
142
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
143 $WORKING_OS = "MacOSX";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
144 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
145 elsif ( $uname_tokens[0] eq "Linux" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
146 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
147 if ( -f "/etc/redhat-release" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
148 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
149 print "\nThis appears to be a RedHat system; good.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
150 $WORKING_OS = "RedHat";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
151 # TODO: check the distro version
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
152 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
153 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
154 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
155 print "\nThis appears to be a non-RedHat Linux system;\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
156 print "this installation *may* succeed; but we're not making any promises!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
157 $WORKING_OS = "Linux";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
158 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
159 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
160 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
161 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
162 print "\nWARNING: This appears to be neither a Linux or MacOS X system!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
163 print "This installer script will most likely fail. Please refer to the\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
164 print "DVN Installers Guide for more information.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
165
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
166 $WORKING_OS = "Unknown";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
167
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
168 print "Do you wish to continue?\n [y/n] ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
169
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
170
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
171 my $yesnocont = <>; chop $yesnocont;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
172
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
173 while ( $yesnocont ne "y" && $yesnocont ne "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
174 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
175 print "Please enter 'y' or 'n'!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
176 print "(or ctrl-C to exit the installer)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
177 $yesnocont = <>; chop $yesnocont;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
178 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
179
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
180 if ( $yesnocont eq "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
181 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
182 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
183 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
184
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
185 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
186
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
187 ENTERCONFIG:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
188
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
189 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
190 print "Please enter the following configuration values:\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
191 print "(hit [RETURN] to accept the default value)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
192 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
193
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
194 for $ENTRY (@CONFIG_VARIABLES)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
195 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
196 print $CONFIG_PROMPTS{$ENTRY} . ": ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
197 print "[" . $CONFIG_DEFAULTS{$ENTRY} . "] ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
198
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
199 $user_entry = <>;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
200 chop $user_entry;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
201
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
202 if ($user_entry ne "")
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
203 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
204 $CONFIG_DEFAULTS{$ENTRY} = $user_entry;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
205 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
206
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
207 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
208 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
209
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
210 # CONFIRM VALUES ENTERED:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
211
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
212
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
213 print "\nOK, please confirm what you've entered:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
214
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
215 for $ENTRY (@CONFIG_VARIABLES)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
216 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
217 print $CONFIG_PROMPTS{$ENTRY} . ": " . $CONFIG_DEFAULTS{$ENTRY} . "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
218 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
219
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
220 print "\nIs this correct? [y/n] ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
221
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
222
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
223 my $yesno = <>; chop $yesno;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
224
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
225 while ( $yesno ne "y" && $yesno ne "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
226 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
227 print "Please enter 'y' or 'n'!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
228 print "(or ctrl-C to exit the installer)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
229 $yesno = <>; chop $yesno;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
230 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
231
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
232 if ( $yesno eq "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
233 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
234 goto ENTERCONFIG;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
235 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
236
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
237 # VALIDATION/VERIFICATION OF THE CONFIGURATION VALUES:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
238 # 1. VERIFY MAIL SERVER THEY CONFIGURED:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
239
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
240 =pod
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
241
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
242 unless ( $postgresonly )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
243 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
244
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
245 my ( $mail_server_iaddr, $mail_server__paddr, $mail_server_proto, $mail_server_status );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
246
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
247 $mail_server_status = 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
248
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
249 unless ( $mail_server_iaddr = inet_aton($CONFIG_DEFAULTS{'MAIL_SERVER'}) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
250 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
251 print STDERR "Could not look up $CONFIG_DEFAULTS{'MAIL_SERVER'},\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
252 print STDERR "the host you specified as your mail server.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
253 $mail_server_status = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
254 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
255
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
256 if ($mail_server_status) {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
257 $mail_server_paddr = sockaddr_in(25, $mail_server_iaddr);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
258 $mail_server_proto = getprotobyname('tcp');
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
259
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
260 unless ( socket(SOCK, PF_INET, SOCK_STREAM, $mail_server_proto) &&
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
261 connect(SOCK, $mail_server_paddr) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
262 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
263 print STDERR "Could not establish connection to $CONFIG_DEFAULTS{'MAIL_SERVER'},\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
264 print STDERR "the address you provided for your Mail server.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
265 print STDERR "Please select a valid mail server, and try again.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
266
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
267 $mail_server_status = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
268 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
269
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
270 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
271
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
272 close (SOCK);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
273
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
274 unless ($mail_server_status)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
275 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
276 goto ENTERCONFIG;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
277 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
278 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
279 =cut
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
280
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
281 # 2. CHECK IF THE WAR FILE IS AVAILABLE:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
282 unless ( -f "appdeploy/dist/DVN-web.war" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
283 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
284 print "\nWARNING: Can't find the project .war file in appdeploy/dist/!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
285 print "\tAre you running the installer in the right directory?\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
286 print "\tHave you built the war file?\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
287 print "\t(if not, build the project and run the installer again)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
288
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
289 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
290 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
291
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
292 # check the working (installer) dir:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
293 my $cwd;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
294 chomp($cwd = `pwd`);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
295
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
296 # 2b. CHECK IF THE SQL TEMPLATE IS IN PLACE AND CREATE THE SQL FILE
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
297
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
298 $SQL_REFERENCE_DATA = "referenceData.sql";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
299 $SQL_REFERENCE_TEMPLATE = "referenceData.sql.TEMPLATE";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
300
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
301 unless ( -f $SQL_REFERENCE_TEMPLATE )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
302 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
303 print "\nWARNING: Can't find .sql data template!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
304 print "(are you running the installer in the right directory?)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
305
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
306 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
307 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
308
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
309 open DATATEMPLATEIN, $SQL_REFERENCE_TEMPLATE || die $@;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
310 open SQLDATAOUT, '>'.$SQL_REFERENCE_DATA || die $@;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
311
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
312 while( <DATATEMPLATEIN> )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
313 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
314 s/%POSTGRES_USER%/$CONFIG_DEFAULTS{'POSTGRES_USER'}/g;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
315 print SQLDATAOUT $_;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
316 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
317
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
318
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
319 close DATATEMPLATEIN;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
320 close SQLDATAOUT;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
321
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
322 # 3. CHECK POSTGRES AVAILABILITY:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
323
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
324 my $pg_local_connection = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
325
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
326 if ( $CONFIG_DEFAULTS{'POSTGRES_SERVER'} eq 'localhost' )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
327 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
328 $pg_local_connection = 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
329
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
330 # 3a. CHECK FOR USER postgres:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
331
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
332 print "\nChecking system user \"postgres\"... ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
333
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
334 $POSTGRES_SYS_NAME = "postgres";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
335 $POSTGRES_SYS_UID = (getpwnam ("postgres"))[2];
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
336
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
337 if ($POSTGRES_SYS_UID == undef) {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
338 print STDERR "\nERROR: I haven't been able to find user \"postgres\" on the system!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
339 print STDERR "(TODO: prompt the user instead to supply an alternative username, if\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
340 print STDERR "available)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
341
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
342 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
343 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
344
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
345 print "OK.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
346
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
347 # 3b. LOCATE THE EXECUTABLE:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
348
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
349 $sys_path = $ENV{'PATH'};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
350 @sys_path_dirs = split ( ":", $sys_path );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
351
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
352 $psql_exec = "";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
353
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
354 for $sys_path_dir ( @sys_path_dirs )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
355 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
356 if ( -x $sys_path_dir . "/psql" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
357 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
358 $psql_exec = $sys_path_dir;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
359 last;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
360 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
361 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
362
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
363 $pg_major_version = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
364 $pg_minor_version = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
365
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
366 if ( $psql_exec eq "" && $WORKING_OS eq "MacOSX" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
367 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
368 for $pg_minor_version ( "1", "0" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
369 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
370 if ( -x "/Library/PostgreSQL/9." . $pg_minor_version . "/bin/psql" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
371 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
372 $pg_major_version = 9;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
373 $psql_exec = "/Library/PostgreSQL/9." . $pg_minor_version . "/bin";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
374 last;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
375 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
376 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
377 if (!$pg_major_version)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
378 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
379 for $pg_minor_version ( "4", "3" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
380 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
381 if ( -x "/Library/PostgreSQL/8." . $pg_minor_version . "/bin/psql" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
382 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
383 $pg_major_version = 8;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
384 $psql_exec = "/Library/PostgreSQL/8." . $pg_minor_version . "/bin";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
385 last;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
386 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
387 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
388 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
389 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
390
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
391 if ( $psql_exec eq "" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
392 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
393 print STDERR "\nERROR: I haven't been able to find the psql command in your PATH!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
394 print STDERR "Please make sure PostgresQL is properly installed and try again.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
395
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
396 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
397 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
398
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
399
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
400
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
401 # 3c. CHECK POSTGRES VERSION:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
402
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
403 open (PSQLOUT, $psql_exec . "/psql --version|");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
404
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
405 $psql_version_line = <PSQLOUT>;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
406 chop $psql_version_line;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
407 close PSQLOUT;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
408
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
409 my ($postgresName, $postgresNameLong, $postgresVersion) = split ( " ", $psql_version_line );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
410
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
411 unless ( $postgresName eq "psql" && $postgresVersion =~ /^[0-9][0-9\.]*$/ )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
412 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
413 print STDERR "\nERROR: Unexpected output from psql command!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
414 print STDERR "Please make sure PostgresQL is properly installed and try again.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
415
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
416 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
417 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
418
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
419
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
420 my (@postgres_version_tokens) = split ( '\.', $postgresVersion );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
421
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
422 unless ( ($postgres_version_tokens[0] == 8 && $postgres_version_tokens[1] >= 3) || ($postgres_version_tokens[0] >= 9) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
423 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
424 print STDERR "\nERROR: PostgresQL version 8.3, or newer, is required!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
425 print STDERR "Found a copy of psql ($psql_exec/psql) that belongs to version $postgresVersion.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
426 print STDERR "Please make sure the right version of PostgresQL is properly installed,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
427 print STDERR "and the right version of psql comes first in the PATH,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
428 print STDERR "then try again.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
429
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
430 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
431 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
432
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
433 print "\n\nFound Postgres psql command, version $postgresVersion. Good.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
434
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
435 $pg_major_version = $postgres_version_tokens[0];
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
436 $pg_minor_version = $postgres_version_tokens[1];
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
437
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
438 # 4. CONFIGURE POSTGRES:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
439
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
440 print "\nConfiguring Postgres Database:\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
441
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
442
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
443
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
444 $< = $POSTGRES_SYS_UID;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
445 $> = $POSTGRES_SYS_UID;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
446
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
447 # 4a. CHECK IF POSTGRES IS RUNNING:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
448 print "Checking if a local instance of Postgres is running and accessible...\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
449
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
450 # (change to /tmp before executing the command below -
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
451 # we are trying to do it as user postgres, and it may not have
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
452 # access to the current, installer directory; the command would still
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
453 # work, but there would be an error message from the shell init on screen
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
454 # - potentially confusing)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
455 chdir ("/tmp");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
456
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
457 if (!system ($psql_exec . "/psql -c 'SELECT * FROM pg_roles' > /dev/null 2>&1"))
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
458 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
459 print "Yes, it is.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
460 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
461 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
462 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
463 print "Nope, I haven't been able to connect to the local instance of PostgresQL.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
464 print "daemon. Is postgresql running? \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
465 print "On a RedHat system, you can check the status of the daemon with\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
466 print " service postgresql status\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
467 print "and, if it's not running, start the daemon with\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
468 print " service postgresql start\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
469 print "On MacOSX, use Applications -> PostgresQL -> Start Server.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
470 print "Also, please make sure that the daemon is listening to network connections,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
471 print "at leaset on the localhost interface. (See \"Installing Postgres\" section\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
472 print "of the installation manual).\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
473 print "Finally, please make sure that the postgres user can make localhost \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
474 print "connections without supplying a password. (That's controlled by the \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
475 print "\"localhost ... ident\" line in pg_hba.conf; again, please consult the \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
476 print "installation manual).\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
477
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
478
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
479 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
480 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
481
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
482
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
483 # 4c. CHECK IF THIS DB ALREADY EXISTS:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
484
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
485 $psql_command_dbcheck = $psql_exec . "/psql -c \"\" -d " . $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} . ">/dev/null 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
486 if ( ($exitcode = system($psql_command_dbcheck)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
487 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
488 # switch back to root uid:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
489 $> = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
490 $< = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
491 chdir ($cwd);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
492
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
493 print "WARNING! Database " . $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} . " already exists!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
494 print "\nPlease note that you can only use this installer to create a blank, \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
495 print "new and shiny DVN database. I.e., you cannot install on top of an \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
496 print "existing database. Please enter a different name for the DVN database.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
497 print "\nPress any key to continue, or ctrl-C to exit the installer...\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
498
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
499 system "stty cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
500 my $key = getc(STDIN);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
501 system "stty -cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
502 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
503
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
504 goto ENTERCONFIG;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
505
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
506 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
507
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
508 # 4d. CHECK IF THIS USER ALREADY EXISTS:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
509
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
510 $psql_command_rolecheck = $psql_exec . "/psql -c \"\" -d postgres " . $CONFIG_DEFAULTS{'POSTGRES_USER'} . " >/dev/null 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
511 if ( ($exitcode = system($psql_command_rolecheck)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
512 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
513 print "User (role) . " . $CONFIG_DEFAULTS{'POSTGRES_USER'} . " already exists;\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
514 print "Proceeding.";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
515 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
516 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
517 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
518 # 4e. CREATE DVN DB USER:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
519
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
520 print "\nCreating Postgres user (role) for the DVN:\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
521
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
522 open TMPCMD, ">/tmp/pgcmd.$$.tmp";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
523
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
524 # with unencrypted password:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
525 #print TMPCMD "CREATE ROLE ".$CONFIG_DEFAULTS{'POSTGRES_USER'}." UNENCRYPTED PASSWORD '".$CONFIG_DEFAULTS{'POSTGRES_PASSWORD'}."' NOSUPERUSER CREATEDB CREATEROLE NOINHERIT LOGIN";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
526
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
527 # with md5-encrypted password:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
528 $pg_password_md5 = &create_pg_hash ($CONFIG_DEFAULTS{'POSTGRES_USER'},$CONFIG_DEFAULTS{'POSTGRES_PASSWORD'});
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
529 my $sql_command = "CREATE ROLE \"".$CONFIG_DEFAULTS{'POSTGRES_USER'}."\" PASSWORD 'md5". $pg_password_md5 ."' NOSUPERUSER CREATEDB CREATEROLE INHERIT LOGIN";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
530
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
531 print TMPCMD $sql_command;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
532 close TMPCMD;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
533
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
534 my $psql_commandline = $psql_exec . "/psql -f /tmp/pgcmd.$$.tmp";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
535
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
536 unless ( ($exitcode = system($psql_commandline)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
537 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
538 print STDERR "Could not create the DVN Postgres user role!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
539 print STDERR "(SQL: " . $sql_command . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
540 print STDERR "(psql exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
541 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
542 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
543
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
544 unlink "/tmp/pgcmd.$$.tmp";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
545 print "done.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
546 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
547
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
548 # 4f. CREATE DVN DB:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
549
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
550 print "\nCreating Postgres database:\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
551
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
552 $psql_command = $psql_exec . "/createdb ".$CONFIG_DEFAULTS{'POSTGRES_DATABASE'}." --owner=".$CONFIG_DEFAULTS{'POSTGRES_USER'};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
553
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
554 unless ( ($exitcode = system("$psql_command")) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
555 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
556 print STDERR "Could not create Postgres database for the DVN app!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
557 print STDERR "(command: " . $psql_command . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
558 print STDERR "(psql exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
559 print STDERR "\naborting the installation (sorry!)\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
560 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
561 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
562
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
563
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
564 # Changing back to root UID:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
565
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
566 $> = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
567 $< = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
568
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
569 chdir ($cwd);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
570
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
571 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
572 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
573 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
574 if (0) # DEV. INSTALLER ONLY:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
575 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
576 print "\nIt is strongly recommended that you use a local PostgresQL server,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
577 print "running on localhost, in your development environment!\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
578
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
579 print "Do you wish to continue?\n [y/n] ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
580
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
581
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
582 my $yesnocont = <>; chop $yesnocont;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
583
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
584 while ( $yesnocont ne "y" && $yesnocont ne "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
585 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
586 print "Please enter 'y' or 'n'!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
587 print "(or ctrl-C to exit the installer)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
588 $yesnocont = <>; chop $yesnocont;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
589 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
590
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
591 if ( $yesnocont eq "n" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
592 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
593 print "(aborting the installation)\n".
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
594 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
595 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
596 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
597
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
598 if ( $opts{$pg_only} )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
599 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
600 print "The script must be run in the --pg_only mode ONLY locally,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
601 print "i.e., on the server where PostgresQL is running.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
602
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
603 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
604 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
605
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
606 print "In order to use a PostgresQL database running on a remote server,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
607 print "Please run this installer on that host with the \"--pg_only\" option:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
608 print "./install --pg_only\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
609
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
610 print "Press any key to continue the installation process once that has been\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
611 print "done. Or press ctrl-C to exit the installer.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
612
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
613 chdir ("/tmp");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
614 system "stty cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
615 my $key = getc(STDIN);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
616 system "stty -cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
617 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
618 chdir ($cwd);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
619
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
620 # Check if the role and database have been created on the remote server:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
621 # -- TODO;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
622
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
623 # Find out what Postgres version is running remotely:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
624
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
625 $pg_major_version = 9;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
626 $pg_minor_version = 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
627
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
628 print "What version of PostgresQL is installed on the remote server?\n [" . $pg_major_version . "." . $pg_minor_version . "] ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
629
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
630
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
631 my $postgresVersion = <>; chop $postgresVersion;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
632
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
633 while ( $postgresVersion ne "" && !($postgresVersion =~/^[0-9]+\.[0-9]+$/) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
634 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
635 print "Please enter valid Postgres version!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
636 print "(or ctrl-C to exit the installer)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
637 $postgresVersion = <>; chop $postgresVersion;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
638 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
639
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
640 unless ( $postgresVersion eq "" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
641 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
642 my (@postgres_version_tokens) = split ( '\.', $postgresVersion );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
643
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
644 unless ( ($postgres_version_tokens[0] == 8 && $postgres_version_tokens[1] >= 3) || ($postgres_version_tokens[0] >= 9) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
645 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
646 print STDERR "\nERROR: PostgresQL version 8.3, or newer, is required!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
647 print STDERR "Please make sure the right version of PostgresQL is properly installed\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
648 print STDERR "on the remote server, then try again.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
649
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
650 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
651 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
652
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
653 $pg_major_version = $postgres_version_tokens[0];
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
654 $pg_minor_version = $postgres_version_tokens[1];
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
655 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
656
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
657 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
658
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
659
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
660 if ( $postgresonly )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
661 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
662 print "\nOK, done.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
663 print "You can now resume the installation on the main DVN host.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
664
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
665 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
666 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
667
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
668
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
669 # 5. CONFIGURE GLASSFISH
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
670
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
671 print "\nProceeding with the Glassfish setup.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
672 print "\nChecking your Glassfish installation...";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
673
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
674 my $glassfish_dir = $CONFIG_DEFAULTS{'GLASSFISH_DIRECTORY'};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
675
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
676 # 5a. CHECK IF GLASSFISH DIR LOOKS OK:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
677
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
678 print $glassfish_dir."/glassfish/domains/domain1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
679
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
680 unless ( -d $glassfish_dir."/glassfish/domains/domain1" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
681 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
682 # TODO: need better check than this
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
683
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
684 while ( ! ( -d $glassfish_dir."/glassfish/domains/domain1" ) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
685 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
686 print "\nInvalid Glassfish directory " . $glassfish_dir . "!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
687 print "Enter the root directory of your Glassfish installation:\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
688 print "(Or ctrl-C to exit the installer): ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
689
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
690 $glassfish_dir = <>;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
691 chop $glassfish_dir;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
692 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
693 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
694
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
695 print "OK!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
696
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
697 # 5b. DETERMINE HOW MUCH MEMORY TO GIVE TO GLASSFISH AS HEAP:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
698
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
699 $gf_heap_default = "2048m";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
700 $sys_mem_total = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
701
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
702 if ( -e "/proc/meminfo" && open MEMINFO, "/proc/meminfo" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
703 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
704 # Linux
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
705
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
706 while ( $mline = <MEMINFO> )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
707 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
708 if ( $mline =~ /MemTotal:[ \t]*([0-9]*) kB/ )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
709 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
710 $sys_mem_total = $1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
711 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
712 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
713
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
714 close MEMINFO;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
715
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
716 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
717 elsif ( -x "/usr/sbin/sysctl" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
718 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
719 # MacOS X, probably...
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
720
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
721 $sys_mem_total = `/usr/sbin/sysctl -n hw.memsize`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
722 chop $sys_mem_total;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
723 if ($sys_mem_total > 0)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
724 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
725 $sys_mem_total = int ($sys_mem_total / 1024);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
726 # size in kb
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
727 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
728 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
729
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
730 if ( $sys_mem_total > 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
731 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
732 # setting the default heap size limit to 3/8 of the available
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
733 # amount of memory:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
734 $gf_heap_default = ( int ($sys_mem_total / (8 / 3 * 1024) ) );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
735
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
736 print "\nSetting the heap limit for Glassfish to " . $gf_heap_default . "MB. \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
737 print "You may need to adjust this setting to better suit \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
738 print "your system.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
739
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
740 $gf_heap_default .= "m";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
741
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
742 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
743 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
744 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
745 print "\nCould not determine the amount of memory on your system.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
746 print "Setting the heap limit for Glassfish to 2GB. You may need \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
747 print "to adjust the value to better suit your system.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
748 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
749
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
750 push @CONFIG_VARIABLES, "DEF_MEM_SIZE";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
751 $CONFIG_DEFAULTS{"DEF_MEM_SIZE"} = $gf_heap_default;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
752
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
753 print "\nPress any key to continue...\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
754
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
755 system "stty cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
756 my $key = getc(STDIN);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
757 system "stty -cbreak </dev/tty >/dev/tty 2>&1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
758 print "\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
759
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
760 # 5c. GENERATE GLASSFISH CONFIGURATION FILE:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
761
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
762 print "\nWriting glassfish configuration file (domain.xml)... ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
763
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
764 # 5cc. FIND THE "special-admin-indicator" IN THE ORIGINAL GLASSFISH CONFIG:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
765
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
766 open ( GFCNFG, $glassfish_dir."/glassfish/domains/domain1/config/domain.xml") || die $@;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
767
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
768 while ( <GFCNFG> )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
769 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
770 if (/<secure-admin special-admin-indicator=\"([^\"]*)\"/)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
771 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
772 $CONFIG_DEFAULTS{'GF_SPEC_INDICATOR'} = $1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
773 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
774 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
775
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
776 # (is it really a problem if we haven't found it?)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
777
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
778 close GFCNFG;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
779
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
780 open TEMPLATEIN, 'domain.xml.TEMPLATE';
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
781 open CONFIGOUT, '>domain.xml';
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
782
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
783 while( <TEMPLATEIN> )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
784 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
785 for $ENTRY (@CONFIG_VARIABLES)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
786 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
787 $patin = '%' . $ENTRY . '%';
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
788 $patout = $CONFIG_DEFAULTS{$ENTRY};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
789
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
790 s/$patin/$patout/g;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
791 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
792
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
793 print CONFIGOUT $_;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
794
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
795 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
796
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
797 close TEMPLATEIN;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
798 close CONFIGOUT;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
799
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
800 print "done.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
801
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
802 system ("/bin/cp -f domain.xml ".$glassfish_dir."/glassfish/domains/domain1/config");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
803 #diagnostics needed!
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
804
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
805 # check if the supllied config files are in the right place:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
806
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
807 unless ( -f "config/logging.properties" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
808 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
809 print "\nERROR! Configuration files not found in config dir!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
810 print "(are you running the installer in the right directory?\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
811 print "Aborting...\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
812 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
813 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
814
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
815 print "\nCopying additional configuration files... ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
816
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
817 system ( "/bin/cp -Rf config/* ".$glassfish_dir."/glassfish/domains/domain1/config");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
818 #diagnostics needed!
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
819
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
820 # install pre-configured robots.txt blocking bot crawlers:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
821 system ( "/bin/cp -f robots.txt ".$glassfish_dir."/glassfish/domains/domain1/docroot");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
822
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
823 # install the DVN guides (HTML) into the application docroot:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
824 system ( "/bin/cp -Rf doc/guides/* ".$glassfish_dir."/glassfish/domains/domain1/docroot/guides");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
825
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
826
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
827 print "done!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
828
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
829 print "\nInstalling the Glassfish PostgresQL driver... ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
830
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
831 my $install_driver_jar = "";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
832
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
833 if ( $pg_major_version == 8 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
834 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
835 if ( $pg_minor_version == 3 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
836 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
837 $install_driver_jar = $POSTGRES_DRIVER_8_3;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
838 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
839 elsif ( $pg_minor_version == 4 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
840 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
841 $install_driver_jar = $POSTGRES_DRIVER_8_4;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
842 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
843 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
844 elsif ( $pg_major_version == 9 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
845 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
846 if ( $pg_minor_version == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
847 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
848 $install_driver_jar = $POSTGRES_DRIVER_9_0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
849 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
850 elsif ( $pg_minor_version == 1 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
851 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
852 $install_driver_jar = $POSTGRES_DRIVER_9_1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
853 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
854 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
855
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
856 =poc
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
857 unless ( $install_driver_jar )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
858 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
859 die "Installer could not find POSTGRES JDBC driver for your version of PostgresQL!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
860
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
861 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
862 =cut
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
863
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
864 system ( "/bin/cp", "pgdriver/" . $install_driver_jar, $glassfish_dir."/glassfish/lib");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
865 #diagnostics needed!
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
866
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
867 print "done!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
868
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
869 # 5d. STOP GLASSFISH (OK IF NOT RUNNING):
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
870 print "\nStopping glassfish...\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
871
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
872 unless ( ($exit_code=system ($glassfish_dir."/bin/asadmin stop-domain domain1")) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
873 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
874 print STDERR "(that's OK!)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
875 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
876
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
877 # 5dd. INSTALL PATCHED WEBCORE GLASSFISH MODULE:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
878
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
879 $gf_webcore_jar = $glassfish_dir."/glassfish/modules/web-core.jar";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
880
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
881 system ("/bin/mv -f ".$gf_webcore_jar . " " . $gf_webcore_jar.".PRESERVED");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
882 system ("/bin/cp web-core.jar ".$gf_webcore_jar);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
883
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
884 # 5ddd. DELETE EJB TIMER APP LOCK FILE, if exists (just in case!):
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
885
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
886 system ( "/bin/rm -f ".$glassfish_dir."/glassfish/domains/domain1/generated/ejb-timer-service-app" );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
887
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
888 # 5e. START GLASSFISH:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
889 print "\nStarting glassfish.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
890
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
891 unless ( ($exit_code=system ($glassfish_dir."/bin/asadmin start-domain domain1")) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
892 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
893 print STDERR "Could not start glassfish!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
894 print STDERR "(exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
895 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
896 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
897
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
898
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
899 # check if glassfish is running:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
900 # TODO.
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
901
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
902 # 6. DEPLOY APPLICATION:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
903 # 6a. DO WE HAVE ANT?
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
904 # (we are no longer using ant to deply -- L.A.)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
905 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
906 #$sys_path = $ENV{'PATH'};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
907 #@sys_path_dirs = split ( ":", $sys_path );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
908
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
909 #$ant_exec = "";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
910 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
911 #for $sys_path_dir ( @sys_path_dirs )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
912 #{
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
913 # if ( -x $sys_path_dir . "/ant" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
914 # {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
915 # $ant_exec = $sys_path_dir . "/ant";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
916 # last;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
917 # }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
918 #}
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
919 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
920 #if ( $ant_exec eq "" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
921 #{
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
922 # print STDERR "\nERROR: I haven't been able to find ant command in your PATH!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
923 # print STDERR "Please make sure and is installed and in your PATH; then try again.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
924 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
925 # exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
926 #}
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
927 # 6b. TRY TO DEPLOY:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
928
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
929 print "\nAttempting to deploy the application:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
930
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
931 $CONFIG_DEFAULTS{'GLASSFISH_ADMIN_PASSWORD'} = 'adminadmin';
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
932 # TODO: ask for password! -- in case they have already changed it
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
933 # (update: chances are we don't even need the password anymore, as
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
934 # long as we are deploying locally (?))
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
935
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
936 my $glassfish_password = $CONFIG_DEFAULTS{'GLASSFISH_ADMIN_PASSWORD'};
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
937
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
938 # create deployment properties files:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
939 # (these properties files are no longer used, because we are no longer
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
940 # using ant to deploy the app. -- L.A.)
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
941
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
942 #for $prop_file ('AS', 'glassfish')
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
943 #{
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
944 # open ( TEMPLIN, "appdeploy/" . $prop_file . ".properties.TEMPLATE" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
945 # || die "failed to open appdeploy/" . $prop_file . ".properties.TEMPLATE";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
946 # open ( PROPOUT, ">appdeploy/" . $prop_file . ".properties" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
947 # || die "failed to open appdeploy/" . $prop_file . ".properties for writing";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
948 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
949 # while( <TEMPLIN> )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
950 # {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
951 # s/%GF_ADMIN_PASSWORD%/$glassfish_password/g;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
952 # s/%GF_ROOT_DIR%/$glassfish_dir/g;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
953 # print PROPOUT $_;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
954 # }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
955 #
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
956 # close TEMPLIN;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
957 # close PROPOUT;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
958 #}
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
959
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
960 # Create the .asadminpass file, or replace it, if exists:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
961
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
962 $asadminpass_file = $ENV{'HOME'} . "/.asadminpass";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
963
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
964 if ( -e $asadminpass_file )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
965 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
966 system ("/bin/mv -f " . $asadminpass_file . " " . $asadminpass_file . ".PRESERVED");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
967 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
968
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
969 system ("echo 'asadmin://admin@localhost:4848 ' > " . $asadminpass_file);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
970
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
971 $deploy_command = $glassfish_dir."/bin/asadmin deploy --force=true --name=DVN-web dist/DVN-web.war";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
972
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
973 unless ( ($exit_code = system ("cd appdeploy; " . $deploy_command)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
974 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
975 print STDERR "Could not deploy DVN application!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
976 print STDERR "(exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
977 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
978 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
979
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
980 if ( $pg_local_connection )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
981 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
982 print "\nOK; now we are going to stop glassfish and populate the database with\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
983 print "some initial content, then start glassfish again.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
984 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
985 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
986 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
987 print "\nOK; stopping glasfish.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
988 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
989
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
990
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
991 # 6c. SHUT DOWN:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
992
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
993 $gf_stop_command = $glassfish_dir."/bin/asadmin stop-domain domain1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
994
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
995 unless ( ($exit_code = system ($gf_stop_command)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
996 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
997 print STDERR "Could not stop glassfish!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
998 print STDERR "(command line: " . $gf_stop_command . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
999 print STDERR "(exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1000 print STDERR "\nPlease finish the installation process manually: \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1001 print STDERR "stop/kill glassfish; then populate the database with \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1002 print STDERR "the supplied initial content, by executing the following \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1003 print STDERR "command, *as Unix user postgres*: \n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1004
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1005 $psql_command = $psql_exec . "/psql -d $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} -f " . $SQL_REFERENCE_DATA;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1006
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1007 print STDERR $psql_command . "\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1008 print STDERR "Then start glassfish again... Voila, you should then have \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1009 print STDERR "a running DVN instance at the following URL:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1010 print STDERR " http://" . $CONFIG_DEFAULTS{'HOST_DNS_ADDRESS'} . "/dvn\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1011
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1012 print STDERR "\naborting the installer... (sorry!)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1013
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1014 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1015 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1016
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1017 # 7. POPULATE DATABASE:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1018
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1019 if ( $pg_local_connection )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1020 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1021 # 7a. POPULATE LOCALLY:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1022 print "\nPopulating the database (local PostgresQL instance):\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1023
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1024 # Copy the SQL file to /tmp, where user postgres will definitely
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1025 # have read access to it:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1026
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1027 copy("referenceData.sql","/tmp") or die "Could not copy referenceData.sql to /tmp: $!";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1028
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1029 $< = $POSTGRES_SYS_UID;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1030 $> = $POSTGRES_SYS_UID;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1031 chdir ("/tmp");
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1032 $psql_command = $psql_exec . "/psql -d $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} -f referenceData.sql";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1033
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1034 unless ( ($exitcode = system("$psql_command")) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1035 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1036 print STDERR "Could not populate Postgres database for the DVN app!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1037 print STDERR "(command: " . $psql_command . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1038 print STDERR "(psql exit code: " . $exitcode . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1039 print STDERR "\nYou must populate the database before you can use your new\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1040 print STDERR "DVN instance. Please consult the installation manual and/or\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1041 print STDERR "seek support from the DVN team.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1042 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1043
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1044 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1045
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1046 chdir ($cwd);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1047 print "\nOK, done!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1048
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1049 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1050 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1051 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1052 # 7b. INSTRUCT THE USER TO POPULATE THE DB ON THE REMOTE SERVER:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1053 # NOT SUPPORTED YET -- TODO
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1054 print "The database needs to be populated with some intial content \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1055 print "before we restart the DVN one last time. \n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1056 print "However, populating a database on a remote PostgresQL server ";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1057 print "is not supported yet!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1058 print "Please copy the file referenceData.sql (found in this directory)\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1059 print "onto the remote server and populate the database manually,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1060 print "as user postgres, with the following command:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1061 print " psql -d $CONFIG_DEFAULTS{'POSTGRES_DATABASE'} -f referenceData.sql\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1062 print "then start glassfish again on this server with \n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1063 print " " . $glassfish_dir."/bin/asadmin start-domain domain1\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1064
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1065 $> = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1066 $< = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1067
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1068 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1069
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1070 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1071
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1072 # back to root:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1073
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1074 $> = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1075 $< = 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1076
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1077 # 8. START GLASSFISH AGAIN:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1078 print "\nStarting glassfish, again:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1079
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1080 $gf_start_command = $glassfish_dir."/bin/asadmin start-domain domain1";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1081
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1082 # delete the EJB TIMER app lock file, if exists (just in case!):
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1083 system ( "/bin/rm -f ".$glassfish_dir."/glassfish/domains/domain1/generated/ejb-timer-service-app" );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1084
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1085 unless ( ($exit_code = system ($gf_start_command)) == 0 )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1086 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1087 print STDERR "Could not start glassfish!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1088 print STDERR "(command line: " . $gf_start_command . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1089 print STDERR "(exit code: " . $exit_code . ")\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1090 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1091 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1092
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1093
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1094 print "\nYou should now have a running DVN instance;\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1095 print "Please go to the application at the following URL:\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1096 print " http://" . $CONFIG_DEFAULTS{'HOST_DNS_ADDRESS'} . "/dvn\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1097 print "\nand log in by using \"networkAdmin\" as both the user name\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1098 print "and password. Click the \"networkAdmin\" link on the right side\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1099 print "Of the main screen, then click \"Update Account\". Change this\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1100 print "default password and default e-mail address.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1101
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1102 # 9. FINALLY, CHECK IF RSERVE IS RUNNING:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1103 print "\n\nFinally, checking if Rserve is running and accessible...\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1104
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1105 unless ( $CONFIG_DEFAULTS{'RSERVE_PORT'}=~/^[0-9][0-9]*$/ )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1106 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1107 print $CONFIG_DEFAULTS{'RSERVE_HOST'} . " does not look like a valid port number,\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1108 print "defaulting to 6311.\n\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1109
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1110 $CONFIG_DEFAULTS{'RSERVE_PORT'} = 6311;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1111 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1112
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1113 my ( $rserve_iaddr, $rserve_paddr, $rserve_proto );
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1114
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1115 unless ( $rserve_iaddr = inet_aton($CONFIG_DEFAULTS{'RSERVE_HOST'}) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1116 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1117 print STDERR "Could not look up $CONFIG_DEFAULTS{'RSERVE_HOST'},\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1118 print STDERR "the host you specified as your R server.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1119 print STDERR "\nDVN can function without a working R server, but\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1120 print STDERR "much of the functionality concerning running statistics\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1121 print STDERR "and analysis on quantitative data will not be available.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1122 print STDERR "Please consult the Installers guide for more info.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1123
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1124 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1125 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1126
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1127 $rserve_paddr = sockaddr_in($CONFIG_DEFAULTS{'RSERVE_PORT'}, $rserve_iaddr);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1128 $rserve_proto = getprotobyname('tcp');
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1129
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1130 unless ( socket(SOCK, PF_INET, SOCK_STREAM, $rserve_proto) &&
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1131 connect(SOCK, $rserve_paddr) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1132 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1133 print STDERR "Could not establish connection to $CONFIG_DEFAULTS{'RSERVE_HOST'}\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1134 print STDERR "on port $CONFIG_DEFAULTS{'RSERVE_PORT'}, the address you provided\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1135 print STDERR "for your R server.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1136 print STDERR "DVN can function without a working R server, but\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1137 print STDERR "much of the functionality concerning running statistics\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1138 print STDERR "and analysis on quantitative data will not be available.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1139 print STDERR "Please consult the \"Installing R\" section in the Installers guide\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1140 print STDERR "for more info.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1141
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1142 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1143
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1144 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1145
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1146 close (SOCK);
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1147 print "\nOK!\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1148
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1149 exit 0;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1150
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1151
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1152 sub create_pg_hash {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1153 local $pg_username = shift @_;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1154 local $pg_password = shift @_;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1155
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1156 $encode_line = $pg_password . $pg_username;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1157
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1158 # for Redhat:
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1159
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1160 ##print STDERR "executing /bin/echo -n $encode_line | md5sum\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1161
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1162 if ( $WORKING_OS eq "MacOSX" )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1163 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1164 $hash = `/bin/echo -n $encode_line | md5`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1165 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1166 else
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1167 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1168 $hash = `/bin/echo -n $encode_line | md5sum`;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1169 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1170
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1171 chop $hash;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1172
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1173 $hash =~s/ \-$//;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1174
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1175 if ( (length($hash) != 32) || ($hash !~ /^[0-9a-f]*$/) )
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1176 {
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1177 print STDERR "Failed to generate a MD5-encrypted password hash for the Postgres database.\n";
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1178 exit 1;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1179 }
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1180
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1181
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1182 return $hash;
1b2188262ae9 adding the installer.
"jurzua <jurzua@mpiwg-berlin.mpg.de>"
parents:
diff changeset
1183 }