source: locker/deploy/bin/onserver.pm @ 240

Last change on this file since 240 was 240, checked in by jbarnold, 18 years ago
Another attempt to fix the automatic installer bug
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1package onserver;
2use strict;
3use Exporter;
4our @ISA = qw(Exporter);
5our @EXPORT = qw(setup totmp print_login_info press_enter $server $tmp $USER $HOME $sname $deploy $addrend $admin_username $requires_sql $addrlast $sqlhost $sqluser $sqlpass $sqldb $sqldbcurl $admin_password $scriptsdev $human);
6
7our $server = "scripts.mit.edu";
8
9our ($tmp, $USER, $HOME, $sname, $deploy, $addrend, $admin_username, $requires_sql, $addrlast, $sqlhost, $sqluser, $sqlpass, $sqldb, $sqldbcurl, $admin_password, $scriptsdev, $human);
10
11$tmp = ".scripts-tmp";
12sub totmp {
13  open(FILE, ">$tmp");
14  print FILE $_[0];
15  close(FILE);
16}
17
18sub print_login_info {
19  print "\nYou will be able to log in to $sname using the following:\n";
20  print "  username: $admin_username\n";
21  print "  password: $admin_password\n";
22}
23
24sub press_enter {
25  local $/ = "\n";
26  print "Press [enter] to continue with the install.";
27  my $enter = <STDIN>; 
28}
29
30sub setup {
31  $ENV{PATH} = '/bin:/usr/bin';
32  $USER = $ENV{USER};
33  $HOME = $ENV{HOME};
34 
35  ($sname, $deploy, $addrend, $admin_username, $requires_sql, $scriptsdev, $human) = @ARGV;
36  chdir "$HOME/web_scripts/$addrend";
37 
38  if($addrend =~ /^(.*)\/$/) {
39    $addrend = $1;
40  }
41  ($addrlast) = ($addrend =~ /([^\/]*)$/);
42 
43  if($requires_sql) {
44    print "\nCreating SQL database for $sname...\n";
45   
46    my $getpwd=`/mit/scripts/sql/bin$scriptsdev/get-password`;
47    ($sqlhost, $sqluser, $sqlpass) = split(/\s/, $getpwd);
48   
49    $sqldb=`/mit/scripts/sql/bin$scriptsdev/get-next-database "$addrlast"`;
50    $sqldb=`/mit/scripts/sql/bin$scriptsdev/create-database "$sqldb"`;
51    if($sqldb eq "") {
52      print "\nERROR:\n";
53      print "Your SQL account failed to create a SQL database.\n";
54      print "You should log in at http://sql.mit.edu to check whether\n";
55      print "your SQL account is at its database limit or its storage limit.\n";
56      print "If you cannot determine the cause of the problem, please\n";
57      print "feel free to contact sql\@mit.edu for assistance.\n";
58      `touch .failed`;
59      exit 1;
60    }
61    $sqldbcurl = $sqldb;
62    $sqldbcurl =~ s/\+/\%2B/;
63  }
64 
65  if(-e "$HOME/web_scripts/$addrend/.admin") { 
66    $admin_password=`cat $HOME/web_scripts/$addrend/.admin`;
67    chomp($admin_password);
68    unlink "$HOME/web_scripts/$addrend/.admin";
69  } 
70
71  print "\nConfiguring $sname...\n";
72 
73  `date > .scripts-version`;
74  `stat /mit/scripts/deploy$scriptsdev/$deploy.tar.gz >> .scripts-version`;
75
76  select STDOUT;
77  $| = 1; # STDOUT is *hot*!
78}
Note: See TracBrowser for help on using the repository browser.