source: locker/deploy/bin/django @ 1037

Last change on this file since 1037 was 1036, checked in by mitchb, 15 years ago
Fix django autoinstaller. Pass the URL components to the fcgi.
  • Property svn:executable set to *
File size: 2.1 KB
RevLine 
[995]1#!/usr/bin/perl
2use strict;
3use lib '/mit/scripts/deploy/bin';
4use onserver;
5
6setup();
7
8print "\nEnter the code name for your project (a valid Python package name).\n";
9print "Do not use 'django' or the name of any other Python library.\n";
10print "Project name: ";
11my $name = <STDIN>;
12chomp $name;
13
14open FASTCGI, ">index.fcgi";
15print FASTCGI <<EOF;
16#!/usr/bin/env python
17import sys, os
18sys.path.insert(0, "/mit/$USER/Scripts/django")
19os.chdir("/mit/$USER/Scripts/django/$name")
20os.environ['DJANGO_SETTINGS_MODULE'] = "$name.settings"
21
22from django.core.servers.fastcgi import runfastcgi
23runfastcgi(method="threaded", daemonize="false")
24EOF
25close FASTCGI;
26chmod 0755, "index.fcgi";
27
28open HTACCESS, ">.htaccess";
29print HTACCESS <<EOF;
30RewriteEngine On
31RewriteCond %{REQUEST_FILENAME} !-f
32RewriteCond %{REQUEST_FILENAME} !-d
[1036]33RewriteRule ^(.*)\$ index.fcgi/\$1 [QSA,L]
[995]34EOF
35close HTACCESS;
36chmod 0777, ".htaccess";
37
38chdir "/mit/$USER/Scripts/django/";
39system qw{django-admin.py startproject}, $name;
40chdir "$name";
41
42open SETTINGS, "settings.py";
43open NEWSETTINGS, "settings.py.new";
44while (<SETTINGS>) {
45  chomp;
46  if (/Your Name/) {
47    $_ = "    ('$USER', '$email'),\n";
48  } elsif (/^DATABASE_ENGINE/) {
49    $_ = "DATABASE_ENGINE = 'mysql'\n";
50  } elsif  (/^DATABASE_NAME/) {
51    $_ = "DATABASE_NAME = '$sqldb'\n";
52  } elsif (/^DATABASE_USER/) {
53    $_ = "DATABASE_USER = '$sqluser'\n";
54  } elsif (/^DATABASE_PASSWORD/) {
55    $_ = "DATABASE_PASSWORD = '$sqlpass'\n";
56  } elsif (/^DATABASE_HOST/) {
57    $_ = "DATABASE_HOST = '$sqlhost'\n";
58  } elsif (/Chicago/) {
59    $_ =~ s/Chicago/New_York/;
60  }
61  print NEWSETTINGS $_;
62}
63close NEWSETTINGS;
64close SETTNGS;
65rename "settings.py.new", "settings.py";
66
67print "\nDjango has been installed.\n\nYour project is located in:\n";
68print "  /mit/$USER/Scripts/django/$name/\n";
69print "To access manage.py, run 'ssh -k $USER\@scripts' and cd to the above directory.\n\n";
70print "When you edit your code, run the command\n";
71print "  touch /mit/$USER/web_scripts/$addrend/index.fcgi\n";
72print "before testing, to cause your site to reload the new code.\n";
73press_enter;
74
75exit 0;
Note: See TracBrowser for help on using the repository browser.