Changes between Version 3 and Version 4 of SimpleBashScriptToSetupDevelopmentEnvironment
- Timestamp:
- Dec 14, 2005, 9:29:58 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SimpleBashScriptToSetupDevelopmentEnvironment
v3 v4 1 Don't know why the '''sh''' wiki processor ain't workin , so to view the script, edit this page.1 Don't know why the '''sh''' wiki processor ain't workin', maybe the server doesn't have `enscript` installed, so here's a plain and not that neat view of the script: 2 2 {{{ 3 3 #!sh 4 4 #!/bin/bash 5 5 6 DJANGO_PROJECT="$(basename `pwd`)" 6 # Project Name, for example: 7 # DJANGO_PROJECT="$(basename `pwd`)" 8 DJANGO_PROJECT='' 9 10 # Django's HTTP server settings 7 11 #SERVER_ADDR="10.1.0.1" 8 #SERVER_PORT="80 00"12 #SERVER_PORT="8080" 9 13 14 # Database Settings 10 15 DJANGO_DB_NAME="${DJANGO_PROJECT}" 11 16 DJANGO_DB_USER='' 12 17 DJANGO_DB_PASS='' 13 18 14 DJANGO_SECRET_UNIQUE_ID='YOUR_SECRET_UNIQUE_ID_HERE' 19 # Project's unique ID setting 20 DJANGO_SECRET_KEY='YOUR_SECRET_UNIQUE_ID_HERE' 15 21 16 17 22 # Update our Python path 18 23 PYTHONPATH="$(echo $PYTHONPATH):$(dirname `pwd`)" 19 24 25 # Setup DJANGO_SETTINGS_MODULE 20 26 DJANGO_SETTINGS_MODULE="${DJANGO_PROJECT}.settings" 21 27 28 # Check argument passed to script, if '-S', it starts Django's HTTP server 22 29 if [ "$1" == "-S" ]; then 30 # If SERVER_ADDR is not setup, use the default 23 31 if [ -z "${SERVER_ADDR}" ]; then 24 32 SERVER_ADDR="localhost" 25 33 fi 34 # If SERVER_PORT is not setup, use the default 26 35 if [ -z "${SERVER_PORT}" ]; then 27 36 SERVER_PORT="8000" 28 37 fi 38 # Start the Django's HTTP Server 29 39 django-admin.py runserver ${SERVER_ADDR}:${SERVER_PORT} \ 30 40 --settings="${DJANGO_PROJECT}.settings" … … 34 44 #!/bin/bash 35 45 36 DJANGO_PROJECT="$(basename `pwd`)" 46 # Project Name, for example: 47 # DJANGO_PROJECT="$(basename `pwd`)" 48 DJANGO_PROJECT='' 49 50 # Django's HTTP server settings 37 51 #SERVER_ADDR="10.1.0.1" 38 #SERVER_PORT="80 00"52 #SERVER_PORT="8080" 39 53 54 # Database Settings 40 55 DJANGO_DB_NAME="${DJANGO_PROJECT}" 41 56 DJANGO_DB_USER='' 42 57 DJANGO_DB_PASS='' 43 58 44 DJANGO_SECRET_UNIQUE_ID='YOUR_SECRET_UNIQUE_ID_HERE' 59 # Project's unique ID setting 60 DJANGO_SECRET_KEY='YOUR_SECRET_UNIQUE_ID_HERE' 45 61 46 47 62 # Update our Python path 48 63 PYTHONPATH="$(echo $PYTHONPATH):$(dirname `pwd`)" 49 64 65 # Setup DJANGO_SETTINGS_MODULE 50 66 DJANGO_SETTINGS_MODULE="${DJANGO_PROJECT}.settings" 51 67 68 # Check argument passed to script, if '-S', it starts Django's HTTP server 52 69 if [ "$1" == "-S" ]; then 70 # If SERVER_ADDR is not setup, use the default 53 71 if [ -z "${SERVER_ADDR}" ]; then 54 72 SERVER_ADDR="localhost" 55 73 fi 74 # If SERVER_PORT is not setup, use the default 56 75 if [ -z "${SERVER_PORT}" ]; then 57 76 SERVER_PORT="8000" 58 77 fi 78 # Start the Django's HTTP Server 59 79 django-admin.py runserver ${SERVER_ADDR}:${SERVER_PORT} \ 60 80 --settings="${DJANGO_PROJECT}.settings" 61 81 fi 62 82 }}} 83 84 To use it, just source it to update environment variables: 85 {{{ 86 source env.sh 87 }}} 88 89 To run the server: 90 {{{ 91 ./env -S 92 }}} 93 94 This is of course, a file that you won't get into your revision control system, it has private data. 95 96 Now, on your project's '''`settings.py`''', you can use(these are just parts of '''`settings.py`''' of couse): 97 {{{ 98 #!python 99 DATABASE_NAME = os.environ['DJANGO_DB_NAME'] 100 DATABASE_USER = os.environ['DJANGO_DB_USER'] 101 DATABASE_PASSWORD = os.environ['DJANGO_DB_PASS'] 102 103 SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] 104 }}} 105 106 And now, you can safely commit '''`settings.py`''' to your revision control system without double checking to see if you forgot to delete the private parts.