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 | | |
| 429 | cd ~web2py/applications/eden |
| 430 | sed -i 's/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g' models/000_config.py |
| 431 | sed -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 |
| 434 | EOF2 |
| 435 | chmod +x /usr/local/bin/clean |
| 436 | |
| 437 | cat << EOF > "/usr/local/bin/w2p" |
| 438 | #!/bin/sh |
| 439 | cd ~web2py |
| 440 | python web2py.py -S eden -M |
| 441 | EOF |
| 442 | chmod +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 | |
| 455 | BRANCH="~flavour/sahana-eden/trunk" |
| 456 | |
| 457 | if [ "$BRANCH" != "~flavour/sahana-eden/trunk" ]; then |
| 458 | echo "parent_location = http://bazaar.launchpad.net/$BRANCH" > /home/web2py/applications/eden/.bzr/branch/branch.conf |
| 459 | fi |
| 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 | |
| 470 | echo -e "What domain name should we use? : \c " |
| 471 | read DOMAIN |
| 472 | |
| 473 | echo -e "What host name should we use? : \c " |
| 474 | read hostname |
| 475 | sitename=$hostname".$DOMAIN" |
| 476 | |
| 477 | echo -e "What is the new PostgreSQL password: \c " |
| 478 | read password |
| 479 | |
| 480 | echo "Now reconfiguring system to use the hostname: $hostname" |
| 481 | |
| 482 | cd /etc |
| 483 | filename="hosts" |
| 484 | sed -i "s|localdomain localhost|localdomain localhost $hostname|" $filename |
| 485 | |
| 486 | cd /etc |
| 487 | filename="hostname" |
| 488 | echo $hostname > $filename |
| 489 | |
| 490 | cd /etc |
| 491 | filename="mailname" |
| 492 | echo $sitename > $filename |
| 493 | |
| 494 | # Update system (in case run at a much later time than the install script) |
| 495 | apt-get update |
| 496 | apt-get upgrade -y |
| 497 | cd ~web2py |
| 498 | bzr pull |
| 499 | cd ~web2py/applications/eden |
| 500 | bzr pull |
| 501 | # ----------------------------------------------------------------------------- |
| 502 | # Email |
| 503 | # ----------------------------------------------------------------------------- |
| 504 | echo configure for Internet mail delivery |
| 505 | dpkg-reconfigure exim4-config |
| 506 | |
| 507 | # ----------------------------------------------------------------------------- |
| 508 | # Sahana Eden |
| 509 | # ----------------------------------------------------------------------------- |
| 510 | echo "Setting up Sahana" |
| 511 | |
| 512 | # Copy Templates |
| 513 | cp ~web2py/applications/eden/deployment-templates/cron/crontab ~web2py/applications/eden/cron |
| 514 | cp ~web2py/applications/eden/deployment-templates/models/000_config.py ~web2py/applications/eden/models |
| 515 | |
| 516 | sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' ~web2py/applications/eden/models/000_config.py |
| 517 | sed -i "s|akeytochange|$sitename$password|" ~web2py/applications/eden/models/000_config.py |
| 518 | sed -i "s|127.0.0.1:8000|$sitename|" ~web2py/applications/eden/models/000_config.py |
| 519 | sed -i 's|base.cdn = False|base.cdn = True|' ~web2py/applications/eden/models/000_config.py |
| 520 | |
| 521 | # PostgreSQL |
| 522 | echo "CREATE USER sahana WITH PASSWORD '$password';" > /tmp/pgpass.sql |
| 523 | su -c - postgres "psql -q -d template1 -f /tmp/pgpass.sql" |
| 524 | rm -f /tmp/pgpass.sql |
| 525 | su -c - postgres "createdb -O sahana -E UTF8 sahana -T template0" |
| 526 | su -c - postgres "createlang plpgsql -d sahana" |
| 527 | |
| 528 | # PostGIS |
| 529 | su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql" |
| 530 | su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql" |
| 531 | |
| 532 | # Configure Database |
| 533 | sed -i 's|deployment_settings.database.db_type = "sqlite"|deployment_settings.database.db_type = "postgres"|' ~web2py/applications/eden/models/000_config.py |
| 534 | sed -i "s|deployment_settings.database.password = \"password\"|deployment_settings.database.password = \"$password\"|" ~web2py/applications/eden/models/000_config.py |
| 535 | sed -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 |
| 538 | sed -i 's|deployment_settings.base.prepopulate = 0|deployment_settings.base.prepopulate = 1|' ~web2py/applications/eden/models/000_config.py |
| 539 | sed -i 's|deployment_settings.base.migrate = False|deployment_settings.base.migrate = True|' ~web2py/applications/eden/models/000_config.py |
| 540 | cd ~web2py |
| 541 | sudo -H -u web2py python web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py |
| 542 | |
| 543 | # PostGIS the Sahana DB |
| 544 | cat << EOF > "/tmp/geometry.sql" |
| 545 | UPDATE public.gis_location SET wkt = 'POINT (' || lon || ' ' || lat || ')' WHERE gis_feature_type = 1; |
| 546 | SELECT AddGeometryColumn( 'public', 'gis_location', 'the_geom', 4326, 'GEOMETRY', 2 ); |
| 547 | UPDATE public.gis_location SET the_geom = ST_SetSRID(ST_GeomFromText(wkt), 4326); |
| 548 | EOF |
| 549 | su -c - postgres "psql -q -d sahana -f /tmp/geometry.sql" |
| 550 | cat << EOF > "/tmp/autopopulate.sql" |
| 551 | CREATE 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; |
| 562 | ALTER FUNCTION s3_update_geometry() OWNER TO sahana; |
| 563 | CREATE TRIGGER s3_locations_update |
| 564 | BEFORE INSERT |
| 565 | ON gis_location |
| 566 | FOR EACH ROW |
| 567 | EXECUTE PROCEDURE s3_update_geometry(); |
| 568 | |
| 569 | EOF |
| 570 | su -c - postgres "psql -q -d sahana -f /tmp/autopopulate.sql" |