Changes between Version 2 and Version 3 of SysAdmin/Jenkins


Ignore:
Timestamp:
02/08/11 22:18:40 (14 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SysAdmin/Jenkins

    v2 v3  
    1111
    1212Update scripts:
     13
     14sudo -H -u jenkins /home/update_sqlite.sh
    1315{{{
    1416cd /home/web2py/applications/sqlite
    1517bzr pull
    16 rm -rf "/home/web2py/applications/sqlite/databases/*"
    17 rm -rf "/home/web2py/applications/sqlite/errors/*"
    18 rm -rf "/home/web2py/applications/sqlite/sessions/*"
    19 cp -f "/home/web2py/applications/sqlite/deployment-templates/models/000_config.py" "/home/web2py/applications/sqlite/models"
    20 sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/sqlite/models/000_config.py"
    21 sed -i 's|127.0.0.1:8000|sqlite.eden.sahanafoundation.org|' "/home/web2py/applications/sqlite/models/000_config.py"
    22 sed -i 's|#deployment_settings.ui.navigate_away_confirm = False|deployment_settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/sqlite/models/000_config.py"
     18rm -rf /home/web2py/applications/sqlite/databases/*
     19rm -rf /home/web2py/applications/sqlite/errors/*
     20rm -rf /home/web2py/applications/sqlite/sessions/*
     21cp -f /home/web2py/applications/sqlite/deployment-templates/models/000_config.py /home/web2py/applications/sqlite/models
     22sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' /home/web2py/applications/sqlite/models/000_config.py
     23sed -i 's|127.0.0.1:8000|sqlite.eden.sahanafoundation.org|' /home/web2py/applications/sqlite/models/000_config.py
     24sed -i 's|#deployment_settings.ui.navigate_away_confirm = False|deployment_settings.ui.navigate_away_confirm = False|' /home/web2py/applications/sqlite/models/000_config.py
    2325cd ~web2py
    24 sudo -H -u web2py python web2py.py -S sqlite -M -R applications/sqlite/static/scripts/tools/noop.py
    25 sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' "/home/web2py/applications/sqlite/models/000_config.py"
    26 sed -i 's|deployment_settings.base.prepopulate = True|deployment_settings.base.prepopulate = False|' "/home/web2py/applications/sqlite/models/000_config.py"
    27 apache2ctl restart
     26python web2py.py -S sqlite -M -R applications/sqlite/static/scripts/tools/noop.py
     27sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' /home/web2py/applications/sqlite/models/000_config.py
     28sed -i 's|deployment_settings.base.prepopulate = True|deployment_settings.base.prepopulate = False|' /home/web2py/applications/sqlite/models/000_config.py
     29
     30sudo /etc/init.d/apache2 restart
    2831}}}
     32
     33sudo -H -u jenkins /home/update_mysql.sh
     34{{{
     35cd /home/web2py/applications/mysql
     36bzr pull
     37rm -rf /home/web2py/applications/mysql/databases/*
     38rm -rf /home/web2py/applications/mysql/errors/*
     39rm -rf /home/web2py/applications/mysql/sessions/*
     40sudo /usr/bin/mysqladmin -f drop sahana
     41sudo /usr/bin/mysqladmin create sahana
     42cp -f "/home/web2py/applications/mysql/deployment-templates/models/000_config.py" "/home/web2py/applications/mysql/models"
     43sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/mysql/models/000_config.py"
     44sed -i 's|127.0.0.1:8000|mysql.eden.sahanafoundation.org|' "/home/web2py/applications/mysql/models/000_config.py"
     45sed -i 's|database.db_type = "sqlite"|database.db_type = "mysql"|' "/home/web2py/applications/mysql/models/000_config.py"
     46sed -i 's|database.username = "sahana"|database.username = "root"|' "/home/web2py/applications/mysql/models/000_config.py"
     47sed -i 's|database.password = "password"|database.password = "eden"|' "/home/web2py/applications/mysql/models/000_config.py"
     48sed -i 's|#deployment_settings.ui.navigate_away_confirm = False|deployment_settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/mysql/models/000_config.py"
     49cd ~web2py
     50#sudo -H -u web2py python web2py.py -S mysql -M -R applications/mysql/static/scripts/tools/noop.py
     51python web2py.py -S mysql -M -R applications/mysql/static/scripts/tools/noop.py
     52sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' "/home/web2py/applications/mysql/models/000_config.py"
     53sed -i 's|deployment_settings.base.prepopulate = True|deployment_settings.base.prepopulate = False|' "/home/web2py/applications/mysql/models/000_config.py"
     54sudo /etc/init.d/apache2 restart
     55}}}
     56
     57sudo -H -u jenkins /home/update_postgresql.sh
    2958{{{
    3059cd /home/web2py/applications/postgresql
    3160bzr pull
    32 rm -rf "/home/web2py/applications/postgresql/databases/*"
    33 rm -rf "/home/web2py/applications/postgresql/errors/*"
    34 rm -rf "/home/web2py/applications/postgresql/sessions/*"
    35 su -c - postgres "dropdb sahana" && true
    36 su -c - postgres "createdb -O sahana sahana"
    37 su -c - postgres "createlang plpgsql -d sahana"
    38 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
    39 su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
    40 su -c - postgres "psql -q -d sahana -f ~web2py/applications/geometry.sql"
    41 su -c - postgres "psql -q -d sahana -f ~web2py/applications/autopopulate.sql"
     61rm -rf /home/web2py/applications/postgresql/databases/*
     62rm -rf /home/web2py/applications/postgresql/errors/*
     63rm -rf /home/web2py/applications/postgresql/sessions/*
     64sudo /bin/su -c - postgres "dropdb sahana" && true
     65sudo /bin/su -c - postgres "createdb -O sahana sahana"
     66sudo /bin/su -c - postgres "createlang plpgsql -d sahana"
     67sudo /bin/su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql"
     68sudo /bin/su -c - postgres "psql -q -d sahana -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql"
    4269cp -f "/home/web2py/applications/postgresql/deployment-templates/models/000_config.py" "/home/web2py/applications/postgresql/models"
    4370sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/postgresql/models/000_config.py"
    4471sed -i 's|127.0.0.1:8000|postgresql.eden.sahanafoundation.org|' "/home/web2py/applications/postgresql/models/000_config.py"
     72sed -i 's|deployment_settings.gis.spatialdb = False|deployment_settings.gis.spatialdb = True|' "/home/web2py/applications/postgresql/models/000_config.py"
    4573sed -i 's|database.db_type = "sqlite"|database.db_type = "postgres"|' "/home/web2py/applications/postgresql/models/000_config.py"
    4674sed -i 's|database.password = "password"|database.password = "eden"|' "/home/web2py/applications/postgresql/models/000_config.py"
    4775sed -i 's|#deployment_settings.ui.navigate_away_confirm = False|deployment_settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/postgresql/models/000_config.py"
    4876cd ~web2py
    49 sudo -H -u web2py python web2py.py -S postgresql -M -R applications/postgresql/static/scripts/tools/noop.py
     77#sudo -H -u web2py python web2py.py -S postgresql -M -R applications/postgresql/static/scripts/tools/noop.py
     78python web2py.py -S postgresql -M -R applications/postgresql/static/scripts/tools/noop.py
     79sudo /bin/su -c - postgres "psql -q -d sahana -f ~web2py/applications/geometry.sql"
     80sudo /bin/su -c - postgres "psql -q -d sahana -f ~web2py/applications/autopopulate.sql"
    5081sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' "/home/web2py/applications/postgresql/models/000_config.py"
    5182sed -i 's|deployment_settings.base.prepopulate = True|deployment_settings.base.prepopulate = False|' "/home/web2py/applications/postgresql/models/000_config.py"
    52 apache2ctl restart
     83sudo /etc/init.d/apache2 restart
    5384}}}
     85
     86
     87/home/web2py/applications/geometry.sql
    5488{{{
    55 cd /home/web2py/applications/mysql
    56 bzr pull
    57 rm -rf "/home/web2py/applications/mysql/databases/*"
    58 rm -rf "/home/web2py/applications/mysql/errors/*"
    59 rm -rf "/home/web2py/applications/mysql/sessions/*"
    60 mysqladmin -f drop sahana
    61 mysqladmin create sahana
    62 cp -f "/home/web2py/applications/mysql/deployment-templates/models/000_config.py" "/home/web2py/applications/mysql/models"
    63 sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' "/home/web2py/applications/mysql/models/000_config.py"
    64 sed -i 's|127.0.0.1:8000|mysql.eden.sahanafoundation.org|' "/home/web2py/applications/mysql/models/000_config.py"
    65 sed -i 's|deployment_settings.gis.spatialdb = False|deployment_settings.gis.spatialdb = True|' "/home/web2py/applications/mysql/models/000_config.py"
    66 sed -i 's|database.db_type = "sqlite"|database.db_type = "mysql"|' "/home/web2py/applications/mysql/models/000_config.py"
    67 sed -i 's|database.password = "password"|database.password = "eden"|' "/home/web2py/applications/mysql/models/000_config.py"
    68 sed -i 's|#deployment_settings.ui.navigate_away_confirm = False|deployment_settings.ui.navigate_away_confirm = False|' "/home/web2py/applications/mysql/models/000_config.py"
    69 cd ~web2py
    70 sudo -H -u web2py python web2py.py -S mysql -M -R applications/mysql/static/scripts/tools/noop.py
    71 sed -i 's|deployment_settings.base.migrate = True|deployment_settings.base.migrate = False|' "/home/web2py/applications/mysql/models/000_config.py"
    72 sed -i 's|deployment_settings.base.prepopulate = True|deployment_settings.base.prepopulate = False|' "/home/web2py/applications/mysql/models/000_config.py"
    73 apache2ctl restart
     89UPDATE public.gis_location SET wkt = 'POINT (' || lon || ' ' || lat || ')' WHERE gis_feature_type = 1;
     90SELECT AddGeometryColumn( 'public', 'gis_location', 'the_geom', 4326, 'GEOMETRY', 2 );
     91UPDATE public.gis_location SET the_geom = ST_SetSRID(ST_GeomFromText(wkt), 4326);
    7492}}}
     93
     94/home/web2py/applications/autopopulate.sql
     95{{{
     96CREATE OR REPLACE FUNCTION s3_update_geometry()
     97  RETURNS "trigger" AS
     98$BODY$
     99  DECLARE
     100  BEGIN
     101
     102    if (NEW.wkt != '') then
     103        NEW.the_geom = SetSRID(GeomFromText(NEW.wkt), 4326);
     104        end if;
     105
     106    RETURN NEW;
     107  END;
     108$BODY$
     109  LANGUAGE 'plpgsql' VOLATILE;
     110ALTER FUNCTION s3_update_geometry() OWNER TO sahana;
     111CREATE TRIGGER s3_locations_update
     112  BEFORE INSERT
     113  ON gis_location
     114  FOR EACH ROW
     115  EXECUTE PROCEDURE s3_update_geometry();
     116}}}