# new cluster  all from scratch
# ===================

pg_dropcluster --stop 8.4 main
pg_createcluster --locale fr_FR.UTF-8 --start 8.4 main

root@vm301:/var/lib/postgresql/8.4/main# su postgres -c'psql -l'
                                  List of databases
   Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | 
 template0 | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres
 template1 | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres
(3 rows)


# creation template:
su postgres -c "/srv/www/grace/prod/geobi-grace-django/scripts/create_template_postgis-debian.sh"

# vérif
root@vm301:/var/lib/postgresql/8.4/main# su postgres -c'psql -l'
                                     List of databases
       Name       |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
------------------+----------+----------+-------------+-------------+-----------------------
 postgres         | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | 
 template0        | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
                                                                    : postgres=CTc/postgres
 template1        | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | =c/postgres
                                                                    : postgres=CTc/postgres
 template_postgis | postgres | UTF8     | fr_FR.UTF-8 | fr_FR.UTF-8 | 
(4 rows)

# create user and dbs
#=================
su postgres

root@vm301:/var/lib/postgresql/8.4/main# su postgres
postgres@vm301:~/8.4/main$ createuser -P  geonode
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n

# dbs
postgres@vm301:~/8.4/main$ createdb -T template_postgis geonode
postgres@vm301:~/8.4/main$ createdb -T template_postgis grace
postgres@vm301:~/8.4/main$ psql -c'ALTER DATABASE geonode OWNER TO geonode'
ALTER DATABASE
postgres@vm301:~/8.4/main$ psql -c'ALTER DATABASE grace OWNER TO geonode'
ALTER DATABASE
postgres@vm301:~/8.4/main$ 

postgres@vm301:~/8.4/main$ psql -l
                                     List of databases
       Name                  |  Owner        | Encoding    |  Collation         |            Ctype    |   Access privileges   
------------------+----------+----------+-------------+-------------+-----------------------
 geonode                   | geonode      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | 
 grace                        | geonode      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | 
 postgres                   | postgres      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | 
 template0                 | postgres      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | =c/postgres
                                                                                                                               : postgres=CTc/postgres
 template1                 | postgres      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | =c/postgres
                                                                                                                               : postgres=CTc/postgres
 template_postgis      | postgres      | UTF8          | fr_FR.UTF-8      | fr_FR.UTF-8     | 
(6 rows)

postgres@vm301:/srv/www/grace/prod/geobi-grace-django$ psql geonode
psql (8.4.13)
Type "help" for help.

geonode=# \d
               List of relations
 Schema |       Name        | Type  |  Owner   
--------+-------------------+-------+----------
 public | geography_columns | view  | postgres
 public | geometry_columns  | table | postgres
 public | spatial_ref_sys   | table | postgres
(3 rows)

 psql -d grace -f /srv/www/grace/prod/geobi-grace-django/sql/insee.sql
 psql -d grace -f /home/makina/grace.sql 
 psql -d grace -f /home/makina/grace_sig.sql
 psql -d grace -f /srv/www/grace/prod/geobi-grace-django/sql/grace_49.sql
 psql -d grace -f /srv/www/grace/prod/geobi-grace-django/sql/grace_modif_base.sql 

# en tant que user grace

grace@vm301:/srv/www/grace/prod/geobi-grace-django$ export DJANGO_SETTINGS_MODULE='grace.settings'
grace@vm301:/srv/www/grace/prod/geobi-grace-django$ bin/django-admin syncdb
/srv/www/grace/prod/geobi-grace-django/grace/content/models.py:8: DeprecationWarning: Using short names for extensions has been deprecated and will be removed in FeinCMS v1.8. Please provide the full python path to the extension titles instead (feincms.module.page.extensions.titles).
  Page.register_extensions('titles')
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table registration_registrationprofile
Creating table notification_noticetype
Creating table notification_noticesetting
Creating table notification_notice
Creating table notification_noticequeuebatch
Creating table notification_observeditem
Creating table avatar_avatar
Creating table south_migrationhistory
Creating table page_page
Creating table page_page_richtextcontent
Creating table page_page_imagecontent
Creating table page_page_videocontent
Creating table thumbnail_kvstore
Creating table contact_form_feedback
Creating table adminfiles_fileupload
Creating table adminfiles_fileuploadreference
Creating table core_objectrole_permissions
Creating table core_objectrole
Creating table core_userobjectrolemapping
Creating table core_groupobjectrolemapping
Creating table core_genericobjectrolemapping
Creating table maps_contact
Creating table maps_layer
Creating table maps_map
Creating table maps_maplayer
Creating table maps_role_permissions
Creating table maps_role
Creating table maps_contactrole
Creating table analyse_analyse

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'grace'): admin
E-mail address: jpc@makina-corpus.com
Password: 
Password (again): 
Error: Your passwords didn't match.
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 10 object(s) from 1 fixture(s)

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.gis
 > django.contrib.staticfiles
 > django.contrib.admin
 > django.contrib.sitemaps
 > django_extensions
 > registration
 > notification
 > avatar
 > south
 > mptt
 > feincms
 > feincms.module.page
 > sorl.thumbnail
 > pure_pagination
 > floppyforms
 > contact_form
 > adminfiles
 > templatetag_handlebars
 > math_captcha
 > geonode.core
 > geonode.maps
 > grace.carto
 > grace.history
 > grace.analyse

Not synced (use migrations):
 - djcelery
 - pybb
 - grace.processing_file
 - grace.mobile
 - grace.content
 - grace.authent
(use ./manage.py migrate to migrate these)


grace@vm301:/srv/www/grace/prod/geobi-grace-django$ bin/django-admin migrate


gr@cep@ssword2012

mkdir -p /srv/www/grace/var/www/grace
mkdir -p /srv/www/grace/static/
mkdir -p /srv/www/grace/uploaded/


root@vm301:/srv/www/grace# chmod -R 775 uploaded/                                                
root@vm301:/srv/www/grace# chown -R grace:www-data uploaded/





#
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(id = 1)

>>> from grace.authent.models import UserProfile
>>> zm = UserProfile.objects.get(user = u)

>>> zm.language
u'Fran\xe7ais'
>>> zm.language = u'fr'
>>> zm.save()




for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" grace` ; do  psql -c "alter table $tbl owner to geonode" grace ; done


root@vm301:/home/makina# cd /etc/init.d/

vim rabbitmq-server

# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6



root@vm301:/etc/init.d# update-rc.d -f celeryd  defaults 99
update-rc.d: using dependency based boot sequencing
root@vm301:/etc/init.d# update-rc.d -f celeryev defaults 99
update-rc.d: using dependency based boot sequencing