1 | #!/usr/bin/perl |
---|
2 | use strict; |
---|
3 | use lib '/mit/scripts/deploy/bin'; |
---|
4 | use onserver; |
---|
5 | |
---|
6 | setup(); |
---|
7 | |
---|
8 | print "\nEnter the code name for your project (a valid Python package name).\n"; |
---|
9 | print "Do not use 'django' or the name of any other Python library.\n"; |
---|
10 | print "Project name: "; |
---|
11 | my $name = <STDIN>; |
---|
12 | chomp $name; |
---|
13 | |
---|
14 | open FASTCGI, ">index.fcgi"; |
---|
15 | print FASTCGI <<EOF; |
---|
16 | #!/usr/bin/env python |
---|
17 | import sys, os |
---|
18 | sys.path.insert(0, "/mit/$USER/Scripts/django") |
---|
19 | os.chdir("/mit/$USER/Scripts/django/$name") |
---|
20 | os.environ['DJANGO_SETTINGS_MODULE'] = "$name.settings" |
---|
21 | |
---|
22 | from django.core.servers.fastcgi import runfastcgi |
---|
23 | runfastcgi(method="threaded", daemonize="false") |
---|
24 | EOF |
---|
25 | close FASTCGI; |
---|
26 | chmod 0755, "index.fcgi"; |
---|
27 | |
---|
28 | open HTACCESS, ">.htaccess"; |
---|
29 | print HTACCESS <<EOF; |
---|
30 | RewriteEngine On |
---|
31 | RewriteCond %{REQUEST_FILENAME} !-f |
---|
32 | RewriteCond %{REQUEST_FILENAME} !-d |
---|
33 | RewriteRule ^(.*)\$ index.fcgi/$1 [QSA,L] |
---|
34 | EOF |
---|
35 | close HTACCESS; |
---|
36 | chmod 0777, ".htaccess"; |
---|
37 | |
---|
38 | chdir "/mit/$USER/Scripts/django/"; |
---|
39 | system qw{django-admin.py startproject}, $name; |
---|
40 | chdir "$name"; |
---|
41 | |
---|
42 | open SETTINGS, "settings.py"; |
---|
43 | open NEWSETTINGS, "settings.py.new"; |
---|
44 | while (<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 | } |
---|
63 | close NEWSETTINGS; |
---|
64 | close SETTNGS; |
---|
65 | rename "settings.py.new", "settings.py"; |
---|
66 | |
---|
67 | print "\nDjango has been installed.\n\nYour project is located in:\n"; |
---|
68 | print " /mit/$USER/Scripts/django/$name/\n"; |
---|
69 | print "To access manage.py, run 'ssh -k $USER\@scripts' and cd to the above directory.\n\n"; |
---|
70 | print "When you edit your code, run the command\n"; |
---|
71 | print " touch /mit/$USER/web_scripts/$addrend/index.fcgi\n"; |
---|
72 | print "before testing, to cause your site to reload the new code.\n"; |
---|
73 | press_enter; |
---|
74 | |
---|
75 | exit 0; |
---|