Changes between Version 7 and Version 8 of InstallationGuidelines/Linux/Server/CherokeePostgreSQL


Ignore:
Timestamp:
11/17/11 17:19:43 (13 years ago)
Author:
Fran Boon
Comment:

Ensure that a clean restores the spatial indexing

Legend:

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

    v7 v8  
    381381
    382382# Change the value of prepopulate, if-necessary
    383 cat << EOF > "/usr/local/bin/clean"
     383cat << EOF2 > "/usr/local/bin/clean"
    384384#!/bin/sh
    385385cd ~web2py/applications/eden
     
    399399cd ~web2py
    400400sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    401 cd ~web2py/applications/eden
    402 sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
    403 sed -i 's/deployment_settings.base.prepopulate = 1/deployment_settings.base.prepopulate = 0/g' models/000_config.py
    404 /usr/local/bin/maintenance off
    405 /usr/local/bin/compile
    406 EOF
    407 chmod +x /usr/local/bin/clean
    408 
    409 cat << EOF > "/usr/local/bin/w2p"
    410 #!/bin/sh
    411 cd ~web2py
    412 python web2py.py -S eden -M
    413 EOF
    414 chmod +x /usr/local/bin/w2p
    415 
    416 # END
    417 }}}
    418 
    419 == After Imaging ==
    420 [http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh configure-eden-cherokee-postgis.sh]
    421 {{{
    422 #!/bin/sh
    423 
    424 # Script to configure an Eden server
    425 # - assumes that install-eden-cherokee-postgis.sh has been run
    426 
    427 BRANCH="~flavour/sahana-eden/trunk"
    428 
    429 if [ "$BRANCH" != "~flavour/sahana-eden/trunk" ]; then
    430     echo "parent_location = http://bazaar.launchpad.net/$BRANCH" > /home/web2py/applications/eden/.bzr/branch/branch.conf
    431 fi
    432 
    433 #RAM=1
    434 #if [ $RAM != 1 ]; then
    435     # @ToDo: Option to tune PostgreSQL from the default 1Gb RAM
    436     # 512
    437     #/etc/sysctl.conf
    438     #552992768->279134208
    439     #/etc/postgresql/8.4/main/postgresql.conf
    440 #fi
    441 
    442 echo -e "What domain name should we use? : \c "
    443 read DOMAIN
    444 
    445 echo -e "What host name should we use? : \c "
    446 read hostname
    447 sitename=$hostname".$DOMAIN"
    448 
    449 echo -e "What is the new PostgreSQL password: \c "
    450 read password
    451 
    452 echo "Now reconfiguring system to use the hostname: $hostname"
    453 
    454 cd /etc
    455 filename="hosts"
    456 sed -i "s|localdomain localhost|localdomain localhost $hostname|" $filename
    457 
    458 cd /etc
    459 filename="hostname"
    460 echo $hostname > $filename
    461 
    462 cd /etc
    463 filename="mailname"
    464 echo $sitename >  $filename
    465 
    466 # Update system (in case run at a much later time than the install script)
    467 apt-get update
    468 apt-get upgrade -y
    469 cd ~web2py
    470 bzr pull
    471 cd ~web2py/applications/eden
    472 bzr pull
    473 # -----------------------------------------------------------------------------
    474 # Email
    475 # -----------------------------------------------------------------------------
    476 echo configure for Internet mail delivery
    477 dpkg-reconfigure exim4-config
    478 
    479 # -----------------------------------------------------------------------------
    480 # Sahana Eden
    481 # -----------------------------------------------------------------------------
    482 echo "Setting up Sahana"
    483 
    484 # Copy Templates
    485 cp ~web2py/applications/eden/deployment-templates/cron/crontab ~web2py/applications/eden/cron
    486 cp ~web2py/applications/eden/deployment-templates/models/000_config.py ~web2py/applications/eden/models
    487 
    488 sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' ~web2py/applications/eden/models/000_config.py
    489 sed -i "s|akeytochange|$sitename$password|" ~web2py/applications/eden/models/000_config.py
    490 sed -i "s|127.0.0.1:8000|$sitename|" ~web2py/applications/eden/models/000_config.py
    491 sed -i 's|base.cdn = False|base.cdn = True|' ~web2py/applications/eden/models/000_config.py
    492 
    493 # PostgreSQL
    494 echo "CREATE USER sahana WITH PASSWORD '$password';" > /tmp/pgpass.sql
    495 su -c - postgres "psql -q -d template1 -f /tmp/pgpass.sql"
    496 rm -f /tmp/pgpass.sql
    497 su -c - postgres "createdb -O sahana -E UTF8 sahana -T template0"
    498 su -c - postgres "createlang plpgsql -d sahana"
    499 
    500 # PostGIS
    501 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
    502 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
    503 
    504 # Configure Database
    505 sed -i 's|deployment_settings.database.db_type = "sqlite"|deployment_settings.database.db_type = "postgres"|' ~web2py/applications/eden/models/000_config.py
    506 sed -i "s|deployment_settings.database.password = \"password\"|deployment_settings.database.password = \"$password\"|" ~web2py/applications/eden/models/000_config.py
    507 sed -i 's|deployment_settings.gis.spatialdb = False|deployment_settings.gis.spatialdb = True|' ~web2py/applications/eden/models/000_config.py
    508 
    509 # Create the Tables & Populate with base data
    510 sed -i 's|deployment_settings.base.prepopulate = 0|deployment_settings.base.prepopulate = 1|' ~web2py/applications/eden/models/000_config.py
    511 sed -i 's|deployment_settings.base.migrate = False|deployment_settings.base.migrate = True|' ~web2py/applications/eden/models/000_config.py
    512 cd ~web2py
    513 sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
    514 
    515401# PostGIS the Sahana DB
    516402cat << EOF > "/tmp/geometry.sql"
     
    541427EOF
    542428su -c - postgres "psql -q -d sahana -f /tmp/autopopulate.sql"
     429cd ~web2py/applications/eden
     430sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py
     431sed -i 's/deployment_settings.base.prepopulate = 1/deployment_settings.base.prepopulate = 0/g' models/000_config.py
     432/usr/local/bin/maintenance off
     433/usr/local/bin/compile
     434EOF2
     435chmod +x /usr/local/bin/clean
     436
     437cat << EOF > "/usr/local/bin/w2p"
     438#!/bin/sh
     439cd ~web2py
     440python web2py.py -S eden -M
     441EOF
     442chmod +x /usr/local/bin/w2p
     443
     444# END
     445}}}
     446
     447== After Imaging ==
     448[http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh configure-eden-cherokee-postgis.sh]
     449{{{
     450#!/bin/sh
     451
     452# Script to configure an Eden server
     453# - assumes that install-eden-cherokee-postgis.sh has been run
     454
     455BRANCH="~flavour/sahana-eden/trunk"
     456
     457if [ "$BRANCH" != "~flavour/sahana-eden/trunk" ]; then
     458    echo "parent_location = http://bazaar.launchpad.net/$BRANCH" > /home/web2py/applications/eden/.bzr/branch/branch.conf
     459fi
     460
     461#RAM=1
     462#if [ $RAM != 1 ]; then
     463    # @ToDo: Option to tune PostgreSQL from the default 1Gb RAM
     464    # 512
     465    #/etc/sysctl.conf
     466    #552992768->279134208
     467    #/etc/postgresql/8.4/main/postgresql.conf
     468#fi
     469
     470echo -e "What domain name should we use? : \c "
     471read DOMAIN
     472
     473echo -e "What host name should we use? : \c "
     474read hostname
     475sitename=$hostname".$DOMAIN"
     476
     477echo -e "What is the new PostgreSQL password: \c "
     478read password
     479
     480echo "Now reconfiguring system to use the hostname: $hostname"
     481
     482cd /etc
     483filename="hosts"
     484sed -i "s|localdomain localhost|localdomain localhost $hostname|" $filename
     485
     486cd /etc
     487filename="hostname"
     488echo $hostname > $filename
     489
     490cd /etc
     491filename="mailname"
     492echo $sitename >  $filename
     493
     494# Update system (in case run at a much later time than the install script)
     495apt-get update
     496apt-get upgrade -y
     497cd ~web2py
     498bzr pull
     499cd ~web2py/applications/eden
     500bzr pull
     501# -----------------------------------------------------------------------------
     502# Email
     503# -----------------------------------------------------------------------------
     504echo configure for Internet mail delivery
     505dpkg-reconfigure exim4-config
     506
     507# -----------------------------------------------------------------------------
     508# Sahana Eden
     509# -----------------------------------------------------------------------------
     510echo "Setting up Sahana"
     511
     512# Copy Templates
     513cp ~web2py/applications/eden/deployment-templates/cron/crontab ~web2py/applications/eden/cron
     514cp ~web2py/applications/eden/deployment-templates/models/000_config.py ~web2py/applications/eden/models
     515
     516sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' ~web2py/applications/eden/models/000_config.py
     517sed -i "s|akeytochange|$sitename$password|" ~web2py/applications/eden/models/000_config.py
     518sed -i "s|127.0.0.1:8000|$sitename|" ~web2py/applications/eden/models/000_config.py
     519sed -i 's|base.cdn = False|base.cdn = True|' ~web2py/applications/eden/models/000_config.py
     520
     521# PostgreSQL
     522echo "CREATE USER sahana WITH PASSWORD '$password';" > /tmp/pgpass.sql
     523su -c - postgres "psql -q -d template1 -f /tmp/pgpass.sql"
     524rm -f /tmp/pgpass.sql
     525su -c - postgres "createdb -O sahana -E UTF8 sahana -T template0"
     526su -c - postgres "createlang plpgsql -d sahana"
     527
     528# PostGIS
     529su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
     530su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
     531
     532# Configure Database
     533sed -i 's|deployment_settings.database.db_type = "sqlite"|deployment_settings.database.db_type = "postgres"|' ~web2py/applications/eden/models/000_config.py
     534sed -i "s|deployment_settings.database.password = \"password\"|deployment_settings.database.password = \"$password\"|" ~web2py/applications/eden/models/000_config.py
     535sed -i 's|deployment_settings.gis.spatialdb = False|deployment_settings.gis.spatialdb = True|' ~web2py/applications/eden/models/000_config.py
     536
     537# Create the Tables & Populate with base data
     538sed -i 's|deployment_settings.base.prepopulate = 0|deployment_settings.base.prepopulate = 1|' ~web2py/applications/eden/models/000_config.py
     539sed -i 's|deployment_settings.base.migrate = False|deployment_settings.base.migrate = True|' ~web2py/applications/eden/models/000_config.py
     540cd ~web2py
     541sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
     542
     543# PostGIS the Sahana DB
     544cat << EOF > "/tmp/geometry.sql"
     545UPDATE public.gis_location SET wkt = 'POINT (' || lon || ' ' || lat || ')' WHERE gis_feature_type = 1;
     546SELECT AddGeometryColumn( 'public', 'gis_location', 'the_geom', 4326, 'GEOMETRY', 2 );
     547UPDATE public.gis_location SET the_geom = ST_SetSRID(ST_GeomFromText(wkt), 4326);
     548EOF
     549su -c - postgres "psql -q -d sahana -f /tmp/geometry.sql"
     550cat << EOF > "/tmp/autopopulate.sql"
     551CREATE OR REPLACE FUNCTION s3_update_geometry()
     552  RETURNS "trigger" AS \$$
     553  DECLARE
     554  BEGIN
     555    if (NEW.wkt != '') then
     556        NEW.the_geom = SetSRID(GeomFromText(NEW.wkt), 4326);
     557        end if;
     558
     559    RETURN NEW;
     560  END;
     561\$$  LANGUAGE 'plpgsql' VOLATILE;
     562ALTER FUNCTION s3_update_geometry() OWNER TO sahana;
     563CREATE TRIGGER s3_locations_update
     564  BEFORE INSERT
     565  ON gis_location
     566  FOR EACH ROW
     567  EXECUTE PROCEDURE s3_update_geometry();
     568
     569EOF
     570su -c - postgres "psql -q -d sahana -f /tmp/autopopulate.sql"
    543571
    544572# Configure for Production