Changes between Version 42 and Version 43 of InstallationGuidelines/Linux/Server/CherokeePostgreSQL


Ignore:
Timestamp:
03/20/12 17:10:51 (10 years ago)
Author:
Pat Tressel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InstallationGuidelines/Linux/Server/CherokeePostgreSQL

    v42 v43  
    1414== Before Imaging ==
    1515[http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/install-eden-cherokee-postgis.sh install-eden-cherokee-postgis.sh]
    16 {{{
    17 #!/bin/sh
    18 
    19 # Script to turn a generic Debian Squeeze box into an Eden server
    20 # with Cherokee & PostgreSQL
    21 # - tunes PostgreSQL for 1Gb RAM
    22 
    23 # Update system
    24 apt-get update
    25 apt-get upgrade -y
    26 apt-get clean
    27 
    28 # Install Admin Tools
    29 apt-get install -y unzip psmisc mlocate telnet lrzsz vim elinks-lite rcconf htop sudo
    30 apt-get clean
    31 # Git
    32 apt-get -y install git-core
    33 apt-get clean
    34 # Email
    35 apt-get -y install exim4-config exim4-daemon-light
    36 apt-get clean
    37 
    38 #########
    39 # Python
    40 #########
    41 # Install Libraries
    42 apt-get -y install libgeos-c1
    43 
    44 # Install Python 2.6
    45 apt-get -y install python2.6 python-dev
    46 # 100 Mb of diskspace due to deps, so only if you want an advanced shell
    47 #apt-get -y install ipython
    48 apt-get clean
    49 apt-get -y install python-lxml python-setuptools python-shapely python-dateutil
    50 apt-get clean
    51 apt-get -y install python-serial
    52 apt-get -y install python-imaging python-reportlab
    53 apt-get -y install python-matplotlib
    54 apt-get -y install python-xlwt python-xlrd
    55 apt-get -y install build-essential
    56 apt-get clean
    57 
    58 #########
    59 # Web2Py
    60 #########
    61 # Install Web2Py
    62 adduser --system --disabled-password web2py
    63 addgroup web2py
    64 cd /home
    65 git clone git://github.com/mdipierro/web2py.git
    66 ln -s /home/web2py ~
    67 cat << EOF > "/home/web2py/routes.py"
    68 #!/usr/bin/python
    69 default_application = 'eden'
    70 default_controller = 'default'
    71 default_function = 'index'
    72 routes_onerror = [
    73         ('eden/400', '!'),
    74         ('eden/401', '!'),
    75         ('eden/*', '/eden/errors/index'),
    76         ('*/*', '/eden/errors/index'),
    77     ]
    78 EOF
    79 
    80 
    81 ##############
    82 # Sahana Eden
    83 ##############
    84 # Install Sahana Eden
    85 cd web2py
    86 cd applications
    87 git clone git://github.com/flavour/eden.git
    88 # Fix permissions
    89 chown web2py ~web2py
    90 chown web2py ~web2py/applications/admin/cache
    91 chown web2py ~web2py/applications/admin/cron
    92 chown web2py ~web2py/applications/admin/databases
    93 chown web2py ~web2py/applications/admin/errors
    94 chown web2py ~web2py/applications/admin/sessions
    95 chown web2py ~web2py/applications/eden
    96 chown web2py ~web2py/applications/eden/cache
    97 chown web2py ~web2py/applications/eden/cron
    98 mkdir -p ~web2py/applications/eden/databases
    99 chown web2py ~web2py/applications/eden/databases
    100 chown web2py ~web2py/applications/eden/errors
    101 chown web2py ~web2py/applications/eden/models
    102 chown web2py ~web2py/applications/eden/sessions
    103 chown web2py ~web2py/applications/eden/static/img/markers
    104 mkdir -p ~web2py/applications/eden/static/cache/chart
    105 chown web2py -R ~web2py/applications/eden/static/cache
    106 chown web2py ~web2py/applications/eden/uploads
    107 mkdir -p ~web2py/applications/eden/uploads/gis_cache
    108 mkdir -p ~web2py/applications/eden/uploads/images
    109 mkdir -p ~web2py/applications/eden/uploads/tracks
    110 chown web2py ~web2py/applications/eden/uploads/gis_cache
    111 chown web2py ~web2py/applications/eden/uploads/images
    112 chown web2py ~web2py/applications/eden/uploads/tracks
    113 ln -s /home/web2py/applications/eden ~
    114 
    115 ##########
    116 # Cherokee
    117 ##########
    118 # Debian current version
    119 echo "deb http://apt.balocco.name squeeze main" >> /etc/apt/sources.list
    120 curl http://apt.balocco.name/key.asc | apt-key add -
    121 apt-get update
    122 apt-get -y install cherokee libcherokee-mod-rrd
    123 apt-get clean
    124 
    125 CHEROKEE_CONF="/etc/cherokee/cherokee.conf"
    126 
    127 # Install uWSGI
    128 apt-get install -y libxml2-dev
    129 cd /tmp
    130 wget http://projects.unbit.it/downloads/uwsgi-1.0.2.1.tar.gz
    131 tar zxvf uwsgi-1.0.2.1.tar.gz
    132 cd uwsgi-1.0.2.1
    133 make
    134 cp uwsgi /usr/local/bin
    135 cd ..
    136 
    137 # Configure uwsgi
    138 
    139 ## Add scheduler config
    140 
    141 cat << EOF > "/home/web2py/run_scheduler.py"
    142 #!/usr/bin/env python
    143 # -*- coding: utf-8 -*-
    144 
    145 import os
    146 import sys
    147 
    148 if '__file__' in globals():
    149     path = os.path.dirname(os.path.abspath(__file__))
    150     os.chdir(path)
    151 else:
    152     path = os.getcwd() # Seems necessary for py2exe
    153 
    154 sys.path = [path]+[p for p in sys.path if not p==path]
    155 
    156 # import gluon.import_all ##### This should be uncommented for py2exe.py
    157 import gluon.widget
    158 from gluon.shell import run
    159 
    160 # Start Web2py Scheduler -- Note the app name is hardcoded!
    161 if __name__ == '__main__':
    162     run('eden',True,True,None,False,"from gluon import current; current._scheduler.loop()")
    163 EOF
    164 
    165 
    166 cat << EOF > "/home/web2py/uwsgi.xml"
    167 <uwsgi>
    168     <uid>web2py</uid>
    169     <gid>web2py</gid>
    170     <pythonpath>/home/web2py/</pythonpath>
    171     <app mountpoint="/">
    172         <script>wsgihandler</script>
    173     </app>
    174     <mule>run_scheduler.py</mule>
    175     <workers>4</workers>
    176     <pidfile>/tmp/uwsgi-prod.pid</pidfile>
    177     <daemonize>/var/log/uwsgi/prod.log</daemonize>
    178     <socket>127.0.0.1:59025</socket>
    179     <master/>
    180 </uwsgi>
    181 EOF
    182 
    183 touch /tmp/uwsgi-prod.pid
    184 chown web2py: /tmp/uwsgi-prod.pid
    185 
    186 mkdir -p /var/log/uwsgi
    187 chown web2py: /var/log/uwsgi
    188 
    189 # Init script for uwsgi
    190 
    191 cat << EOF > "/etc/init.d/uwsgi"
    192 #! /bin/bash
    193 # /etc/init.d/uwsgi
    194 #
    195 
    196 daemon=/usr/local/bin/uwsgi
    197 pid=/tmp/uwsgi-prod.pid
    198 args="-x /home/web2py/uwsgi.xml"
    199 
    200 # Carry out specific functions when asked to by the system
    201 case "\$1" in
    202     start)
    203         echo "Starting uwsgi"
    204         start-stop-daemon -p \$pid --start --exec \$daemon -- \$args
    205         ;;
    206     stop)
    207         echo "Stopping script uwsgi"
    208         start-stop-daemon --signal INT -p \$pid --stop \$daemon -- \$args
    209         ;;
    210     reload)
    211         echo "Reloading conf"
    212         kill -HUP \$(cat \$pid)
    213         ;;
    214     *)
    215         echo "Usage: /etc/init.d/uwsgi {start|stop|reload}"
    216         exit 1
    217     ;;
    218 esac
    219 exit 0
    220 EOF
    221 
    222 chmod a+x /etc/init.d/uwsgi
    223 update-rc.d uwsgi defaults
    224 
    225 
    226 # Configure Cherokee
    227 
    228 mv "$CHEROKEE_CONF" /tmp
    229 cat << EOF > "$CHEROKEE_CONF"
    230 config!version = 001002002
    231 server!bind!1!port = 80
    232 server!collector = rrd
    233 server!fdlimit = 10240
    234 server!group = www-data
    235 server!ipv6 = 0
    236 server!keepalive = 1
    237 server!keepalive_max_requests = 500
    238 server!panic_action = /usr/share/cherokee/cherokee-panic
    239 server!pid_file = /var/run/cherokee.pid
    240 server!server_tokens = product
    241 server!timeout = 300
    242 server!user = www-data
    243 vserver!10!collector!enabled = 1
    244 vserver!10!directory_index = index.html
    245 vserver!10!document_root = /var/www
    246 vserver!10!error_writer!filename = /var/log/cherokee/cherokee.error
    247 vserver!10!error_writer!type = file
    248 vserver!10!logger = combined
    249 vserver!10!logger!access!buffsize = 16384
    250 vserver!10!logger!access!filename = /var/log/cherokee/cherokee.access
    251 vserver!10!logger!access!type = file
    252 vserver!10!nick = default
    253 vserver!10!rule!10!handler = common
    254 vserver!10!rule!10!handler!iocache = 1
    255 vserver!10!rule!10!match = default
    256 vserver!20!collector!enabled = 1
    257 vserver!20!directory_index = index.html
    258 vserver!20!document_root = /var/www
    259 vserver!20!error_writer!filename = /var/log/cherokee/cherokee.error
    260 vserver!20!error_writer!type = file
    261 vserver!20!logger = combined
    262 vserver!20!logger!access!buffsize = 16384
    263 vserver!20!logger!access!filename = /var/log/cherokee/cherokee.access
    264 vserver!20!logger!access!type = file
    265 vserver!20!match = wildcard
    266 vserver!20!match!domain!1 = *
    267 vserver!20!match!nick = 0
    268 vserver!20!nick = maintenance
    269 vserver!20!rule!210!handler = file
    270 vserver!20!rule!210!match = fullpath
    271 vserver!20!rule!210!match!fullpath!1 = /maintenance.html
    272 vserver!20!rule!110!handler = redir
    273 vserver!20!rule!110!handler!rewrite!10!regex = ^/*
    274 vserver!20!rule!110!handler!rewrite!10!show = 1
    275 vserver!20!rule!110!handler!rewrite!10!substring = /maintenance.html
    276 vserver!20!rule!110!match = directory
    277 vserver!20!rule!110!match!directory = /
    278 vserver!20!rule!10!handler = common
    279 vserver!20!rule!10!handler!iocache = 1
    280 vserver!20!rule!10!match = default
    281 vserver!30!collector!enabled = 1
    282 vserver!30!directory_index = index.html
    283 vserver!30!document_root = /var/www
    284 vserver!30!error_handler = error_redir
    285 vserver!30!error_handler!503!show = 0
    286 vserver!30!error_handler!503!url = /maintenance.html
    287 vserver!30!error_writer!filename = /var/log/cherokee/cherokee.error
    288 vserver!30!error_writer!type = file
    289 vserver!30!logger = combined
    290 vserver!30!logger!access!buffsize = 16384
    291 vserver!30!logger!access!filename = /var/log/cherokee/cherokee.access
    292 vserver!30!logger!access!type = file
    293 vserver!30!match = wildcard
    294 vserver!30!match!domain!1 = *
    295 vserver!30!match!nick = 0
    296 vserver!30!nick = Production
    297 vserver!30!rule!700!expiration = epoch
    298 vserver!30!rule!700!expiration!caching = no-cache
    299 vserver!30!rule!700!expiration!caching!must-revalidate = 1
    300 vserver!30!rule!700!expiration!caching!no-store = 1
    301 vserver!30!rule!700!expiration!caching!no-transform = 1
    302 vserver!30!rule!700!expiration!caching!proxy-revalidate = 1
    303 vserver!30!rule!700!flcache = forbid
    304 vserver!30!rule!700!handler = common
    305 vserver!30!rule!700!handler!allow_dirlist = 0
    306 vserver!30!rule!700!handler!allow_pathinfo = 0
    307 vserver!30!rule!700!match = fullpath
    308 vserver!30!rule!700!match!fullpath!1 = /maintenance.html
    309 vserver!30!rule!400!document_root = /home/web2py/applications/eden/static
    310 vserver!30!rule!400!encoder!deflate = allow
    311 vserver!30!rule!400!encoder!gzip = allow
    312 vserver!30!rule!400!expiration = time
    313 vserver!30!rule!400!expiration!time = 7d
    314 vserver!30!rule!400!handler = file
    315 vserver!30!rule!400!match = fullpath
    316 vserver!30!rule!400!match!fullpath!1 = /favicon.ico
    317 vserver!30!rule!400!match!fullpath!2 = /robots.txt
    318 vserver!30!rule!400!match!fullpath!3 = /crossdomain.xml
    319 vserver!30!rule!300!document_root = /home/web2py/applications/eden/static
    320 vserver!30!rule!300!encoder!deflate = allow
    321 vserver!30!rule!300!encoder!gzip = allow
    322 vserver!30!rule!300!expiration = time
    323 vserver!30!rule!300!expiration!time = 7d
    324 vserver!30!rule!300!handler = file
    325 vserver!30!rule!300!match = directory
    326 vserver!30!rule!300!match!directory = /eden/static/
    327 vserver!30!rule!300!match!final = 1
    328 vserver!30!rule!200!encoder!deflate = allow
    329 vserver!30!rule!200!encoder!gzip = allow
    330 vserver!30!rule!200!handler = uwsgi
    331 vserver!30!rule!200!handler!balancer = round_robin
    332 vserver!30!rule!200!handler!balancer!source!10 = 1
    333 vserver!30!rule!200!handler!check_file = 0
    334 vserver!30!rule!200!handler!error_handler = 1
    335 vserver!30!rule!200!handler!modifier1 = 0
    336 vserver!30!rule!200!handler!modifier2 = 0
    337 vserver!30!rule!200!handler!pass_req_headers = 1
    338 vserver!30!rule!200!match = directory
    339 vserver!30!rule!200!match!directory = /
    340 vserver!30!rule!100!handler = common
    341 vserver!30!rule!100!handler!iocache = 1
    342 vserver!30!rule!100!match = default
    343 source!1!env_inherited = 1
    344 source!1!group = web2py
    345 source!1!host = 127.0.0.1:59025
    346 source!1!interpreter = /usr/local/bin/uwsgi -s 127.0.0.1:59025 -x /home/web2py/uwsgi.xml
    347 source!1!nick = uWSGI 1
    348 source!1!timeout = 300
    349 source!1!type = host
    350 source!1!user = web2py
    351 EOF
    352 
    353 grep 'icons!' /tmp/cherokee.conf >> "$CHEROKEE_CONF"
    354 grep 'mime!' /tmp/cherokee.conf >> "$CHEROKEE_CONF"
    355 
    356 cat << EOF >> "$CHEROKEE_CONF"
    357 admin!ows!enabled = 0
    358 EOF
    359 
    360 # For a static home page, push 400->500 & 300->400 & insert this
    361 #vserver!30!rule!300!document_root = /home/web2py/applications/eden/static
    362 #vserver!30!rule!300!handler = redir
    363 #vserver!30!rule!300!handler!rewrite!10!regex = ^.*$
    364 #vserver!30!rule!300!handler!rewrite!10!show = 1
    365 #vserver!30!rule!300!handler!rewrite!10!substring = /eden/static/index.html
    366 #vserver!30!rule!300!match = and
    367 #vserver!30!rule!300!match!final = 1
    368 #vserver!30!rule!300!match!left = fullpath
    369 #vserver!30!rule!300!match!left!fullpath!1 = /
    370 #vserver!30!rule!300!match!right = not
    371 #vserver!30!rule!300!match!right!right = header
    372 #vserver!30!rule!300!match!right!right!complete = 0
    373 #vserver!30!rule!300!match!right!right!header = Cookie
    374 #vserver!30!rule!300!match!right!right!match = re
    375 #vserver!30!rule!300!match!right!right!type = regex
    376 
    377 
    378 cat << EOF > "/var/www/maintenance.html"
    379 <html><body><h1>Site Maintenance</h1>Please try again later...</body></html>
    380 EOF
    381 
    382 
    383 /etc/init.d/cherokee restart
    384 
    385 
    386 ############
    387 # PostgreSQL
    388 ############
    389 apt-get -y install postgresql-8.4 python-psycopg2 postgresql-8.4-postgis ptop
    390 
    391 # Tune PostgreSQL
    392 cat << EOF >> "/etc/sysctl.conf"
    393 ## Increase Shared Memory available for PostgreSQL
    394 # 512Mb
    395 kernel.shmmax = 279134208
    396 # 1024Mb (may need more)
    397 #kernel.shmmax = 552992768
    398 kernel.shmall = 2097152
    399 EOF
    400 sysctl -w kernel.shmmax=279134208 # For 512 MB RAM
    401 #sysctl -w kernel.shmmax=552992768 # For 1024 MB RAM
    402 sysctl -w kernel.shmall=2097152
    403 
    404 sed -i 's|#track_counts = on|track_counts = on|' /etc/postgresql/8.4/main/postgresql.conf
    405 sed -i 's|#autovacuum = on|autovacuum = on|' /etc/postgresql/8.4/main/postgresql.conf
    406 sed -i 's|shared_buffers = 28MB|shared_buffers = 160MB|' /etc/postgresql/8.4/main/postgresql.conf
    407 sed -i 's|#effective_cache_size = 128MB|effective_cache_size = 512MB|' /etc/postgresql/8.4/main/postgresql.conf
    408 sed -i 's|#work_mem = 1MB|work_mem = 4MB|' /etc/postgresql/8.4/main/postgresql.conf
    409 
    410 #####################
    411 # Management scripts
    412 #####################
    413 cat << EOF > "/usr/local/bin/backup"
    414 #!/bin/sh
    415 mkdir /var/backups/eden
    416 chown postgres /var/backups/eden
    417 NOW=\$(date +"%Y-%m-%d")
    418 su -c - postgres "pg_dump -c sahana > /var/backups/eden/sahana-\$NOW.sql"
    419 su -c - postgres "pg_dump -Fc gis > /var/backups/eden/gis.dmp"
    420 OLD=\$(date --date='7 day ago' +"%Y-%m-%d")
    421 rm -f /var/backups/eden/sahana-\$OLD.sql
    422 mkdir /var/backups/eden/uploads
    423 tar -cf /var/backups/eden/uploads/uploadsprod-$NOW.tar -C /home/web2py/applications/eden  ./uploads
    424 bzip2 /var/backups/eden/uploads/uploadsprod-$NOW.tar
    425 rm -f /var/backups/eden/uploads/uploadsprod-$OLD.tar.bz2
    426 EOF
    427 chmod +x /usr/local/bin/backup
    428 
    429 cat << EOF > "/usr/local/bin/compile"
    430 #!/bin/bash
    431 /etc/init.d/uwsgi stop
    432 cd ~web2py
    433 python web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
    434 /etc/init.d/uwsgi start
    435 EOF
    436 chmod +x /usr/local/bin/compile
    437 
    438 cat << EOF > "/usr/local/bin/pull"
    439 #!/bin/sh
    440 
    441 /etc/init.d/uwsgi stop
    442 cd ~web2py/applications/eden
    443 sed -i 's/deployment_settings.base.migrate = False/deployment_settings.base.migrate = True/g' models/000_config.py
    444 git pull
    445 rm -rf compiled
    446 cd ~web2py
    447 sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    448 cd ~web2py/applications/eden
    449 sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
    450 cd ~web2py
    451 python web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
    452 /etc/init.d/uwsgi start
    453 EOF
    454 chmod +x /usr/local/bin/pull
    455 
    456 # Change the value of prepopulate, if-necessary
    457 cat << EOF2 > "/usr/local/bin/clean"
    458 #!/bin/sh
    459 /etc/init.d/uwsgi stop
    460 cd ~web2py/applications/eden
    461 rm -f databases/*
    462 rm -f errors/*
    463 rm -f sessions/*
    464 rm -rf uploads/*
    465 pkill -f 'postgres: sahana sahana'
    466 sudo -H -u postgres dropdb sahana
    467 sed -i 's/deployment_settings.base.migrate = False/deployment_settings.base.migrate = True/g' models/000_config.py
    468 sed -i 's/deployment_settings.base.prepopulate = 0/deployment_settings.base.prepopulate = 1/g' models/000_config.py
    469 rm -rf compiled
    470 su -c - postgres "createdb -O sahana -E UTF8 sahana -T template0"
    471 su -c - postgres "createlang plpgsql -d sahana"
    472 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
    473 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
    474 su -c - postgres "psql -q -d sahana -c 'grant all on geometry_columns to sahana;'"
    475 su -c - postgres "psql -q -d sahana -c 'grant all on spatial_ref_sys to sahana;'"
    476 cd ~web2py
    477 sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    478 cd ~web2py/applications/eden
    479 sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
    480 sed -i 's/deployment_settings.base.prepopulate = 1/deployment_settings.base.prepopulate = 0/g' models/000_config.py
    481 cd ~web2py
    482 python web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
    483 /etc/init.d/uwsgi start
    484 EOF2
    485 chmod +x /usr/local/bin/clean
    486 
    487 cat << EOF > "/usr/local/bin/w2p"
    488 #!/bin/sh
    489 cd ~web2py
    490 python web2py.py -S eden -M
    491 EOF
    492 chmod +x /usr/local/bin/w2p
    493 
    494 cat << EOF > "/usr/local/bin/reload-uwsgi"
    495 #!/bin/bash
    496 set -e
    497 
    498 if [[ -z "$1" ]]; then
    499     echo >&2 "Instance needs to be specified: prod, dev, test or train"
    500     exit 1
    501 elif [[ ! -d "/home/rms/$1" ]]; then
    502     echo >&2 "$1 is not a valid instance!"
    503     exit 1
    504 fi
    505 
    506 INSTANCE=$1
    507 
    508 /etc/init.d/uwsgi-$INSTANCE reload
    509 EOF
    510 chmod +x /usr/local/bin/reload-uwsgi
    511 
    512 cat << EOF > "/usr/local/bin/start-uwsgi"
    513 #!/bin/bash
    514 set -e
    515 
    516 if [[ -z "$1" ]]; then
    517     echo >&2 "Instance needs to be specified: prod, dev, test or train"
    518     exit 1
    519 elif [[ ! -d "/home/rms/$1" ]]; then
    520     echo >&2 "$1 is not a valid instance!"
    521     exit 1
    522 fi
    523 
    524 INSTANCE=$1
    525 
    526 /etc/init.d/uwsgi-$INSTANCE start
    527 EOF
    528 chmod +x /usr/local/bin/start-uwsgi
    529 
    530 
    531 cat << EOF > "/usr/local/bin/stop-uwsgi"
    532 #!/bin/bash
    533 set -e
    534 
    535 if [[ -z "$1" ]]; then
    536     echo >&2 "Instance needs to be specified: prod, dev, test or train"
    537     exit 1
    538 elif [[ ! -d "/home/rms/$1" ]]; then
    539     echo >&2 "$1 is not a valid instance!"
    540     exit 1
    541 fi
    542 
    543 INSTANCE=$1
    544 
    545 /etc/init.d/uwsgi-$INSTANCE stop
    546 EOF
    547 chmod +x /usr/local/bin/stop-uwsgi
    548 
    549 apt-get clean
    550 
    551 # END
    552 
    553 }}}
     16[[Include(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/install-eden-cherokee-postgis.sh, text/plain)]]
    55417
    55518== After Imaging ==
    55619[http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh configure-eden-cherokee-postgis.sh]
    557 {{{
    558 #!/bin/sh
    559 
    560 # Script to configure an Eden server
    561 # - assumes that install-eden-cherokee-postgis.sh has been run
    562 
    563 
    564 #RAM=1
    565 #if [ $RAM != 1 ]; then
    566     # @ToDo: Option to tune PostgreSQL from the default 1Gb RAM
    567     # 512
    568     #/etc/sysctl.conf
    569     #552992768->279134208
    570     #/etc/postgresql/8.4/main/postgresql.conf
    571 #fi
    572 
    573 echo -e "What domain name should we use? : \c "
    574 read DOMAIN
    575 
    576 echo -e "What host name should we use? : \c "
    577 read hostname
    578 sitename=$hostname".$DOMAIN"
    579 
    580 echo -e "What is the new PostgreSQL password: \c "
    581 read password
    582 
    583 echo "Now reconfiguring system to use the hostname: $hostname"
    584 
    585 cd /etc
    586 filename="hosts"
    587 sed -i "s|localdomain localhost|localdomain localhost $hostname|" $filename
    588 
    589 cd /etc
    590 filename="hostname"
    591 echo $hostname > $filename
    592 
    593 cd /etc
    594 filename="mailname"
    595 echo $sitename >  $filename
    596 
    597 # Update system (in case run at a much later time than the install script)
    598 apt-get update
    599 apt-get upgrade -y
    600 cd ~web2py
    601 git pull
    602 cd ~web2py/applications/eden
    603 git pull
    604 # -----------------------------------------------------------------------------
    605 # Email
    606 # -----------------------------------------------------------------------------
    607 echo configure for Internet mail delivery
    608 dpkg-reconfigure exim4-config
    609 
    610 # -----------------------------------------------------------------------------
    611 # Sahana Eden
    612 # -----------------------------------------------------------------------------
    613 echo "Setting up Sahana"
    614 
    615 # Copy Templates
    616 cp ~web2py/applications/eden/deployment-templates/cron/crontab ~web2py/applications/eden/cron
    617 cp ~web2py/applications/eden/deployment-templates/models/000_config.py ~web2py/applications/eden/models
    618 
    619 sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' ~web2py/applications/eden/models/000_config.py
    620 sed -i "s|akeytochange|$sitename$password|" ~web2py/applications/eden/models/000_config.py
    621 sed -i "s|127.0.0.1:8000|$sitename|" ~web2py/applications/eden/models/000_config.py
    622 sed -i 's|base.cdn = False|base.cdn = True|' ~web2py/applications/eden/models/000_config.py
    623 
    624 # PostgreSQL
    625 echo "CREATE USER sahana WITH PASSWORD '$password';" > /tmp/pgpass.sql
    626 su -c - postgres "psql -q -d template1 -f /tmp/pgpass.sql"
    627 rm -f /tmp/pgpass.sql
    628 su -c - postgres "createdb -O sahana -E UTF8 sahana -T template0"
    629 su -c - postgres "createlang plpgsql -d sahana"
    630 
    631 # PostGIS
    632 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
    633 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
    634 su -c - postgres "psql -q -d sahana -c 'grant all on geometry_columns to sahana;'"
    635 su -c - postgres "psql -q -d sahana -c 'grant all on spatial_ref_sys to sahana;'"
    636 
    637 # Configure Database
    638 sed -i 's|deployment_settings.database.db_type = "sqlite"|deployment_settings.database.db_type = "postgres"|' ~web2py/applications/eden/models/000_config.py
    639 sed -i "s|deployment_settings.database.password = \"password\"|deployment_settings.database.password = \"$password\"|" ~web2py/applications/eden/models/000_config.py
    640 # Spatial DAL not yet in Trunk Web2Py
    641 #sed -i 's|deployment_settings.gis.spatialdb = False|deployment_settings.gis.spatialdb = True|' ~web2py/applications/eden/models/000_config.py
    642 
    643 # Create the Tables & Populate with base data
    644 sed -i 's|deployment_settings.base.prepopulate = 0|deployment_settings.base.prepopulate = 1|' ~web2py/applications/eden/models/000_config.py
    645 sed -i 's|deployment_settings.base.migrate = False|deployment_settings.base.migrate = True|' ~web2py/applications/eden/models/000_config.py
    646 cd ~web2py
    647 sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    648 
    649 # Configure for Production
    650 sed -i 's|deployment_settings.base.prepopulate = 1|deployment_settings.base.prepopulate = 0|' ~web2py/applications/eden/models/000_config.py
    651 sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' ~web2py/applications/eden/models/000_config.py
    652 cd ~web2py
    653 sudo -H -u web2py python web2py.py -S eden -R applications/eden/static/scripts/tools/compile.py
    654 
    655 # Schedule backups for 02:01 daily
    656 echo "1 2   * * * * root    /usr/local/bin/backup" >> "/etc/crontab"
    657 
    658 
    659 #read -p "Press any key to Reboot..."
    660 echo "Now rebooting.."
    661 reboot
    662 
    663 # END
    664 }}}
     20[[Include(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh, text/plain)]]