#!/bin/sh
CLUSTER=cluster_zeus_atenea
DB1=guiasweb
DB2=guiasweb
H1=192.168.2.15
H2=192.168.2.18
U=postgres
origin=1
mainset=1

slonik <<_EOF_
cluster name = $CLUSTER;
node 1 admin conninfo = 'dbname=$DB1 host=$H1 user=$U';
node 2 admin conninfo = 'dbname=$DB2 host=$H2 user=$U';
init cluster (id = 1, comment = 'Nodo MAESTRO');

#lista de tablas
create set (id = $mainset, origin = $origin,
                   comment = 'Listado de entidades GuiasWeb');

set add table (set id = $mainset, origin = $origin, 
               id = 1, fully qualified name = 'public.anticipo', comment = 'Tabla anticipo');

set add table (set id = $mainset, origin = $origin, 
               id = 2, fully qualified name = 'public.archivo_guia', comment = 'Tabla archivo_guia');

set add table (set id = $mainset, origin = $origin, 
               id = 3, fully qualified name = 'public.auditoria', comment = 'Tabla auditoria');

set add table (set id = $mainset, origin = $origin, 
               id = 4, fully qualified name = 'public.auditoria_guia', comment = 'Tabla auditoria_guia');

set add table (set id = $mainset, origin = $origin, 
               id = 5, fully qualified name = 'public.beneficiario', comment = 'Tabla beneficiario');

set add table (set id = $mainset, origin = $origin,
               id = 6, fully qualified name = 'public.beneficiario_facturacion', comment = 'Tabla beneficiario_facturacion');

set add table (set id = $mainset, origin = $origin, 
               id = 7, fully qualified name = 'public.centro_costo', comment = 'Tabla centro_costo');

set add table (set id = $mainset, origin = $origin,
               id = 8, fully qualified name = 'public.ciudad_manifiesto', comment = 'Tabla ciudad_manifiesto');

set add table (set id = $mainset, origin = $origin,
               id = 9, fully qualified name = 'public.ciudad_operativo', comment = 'Tabla ciudad_operativo');

set add table (set id = $mainset, origin = $origin,
               id = 10, fully qualified name = 'public.concepto', comment = 'Tabla concepto');

set add table (set id = $mainset, origin = $origin,
               id = 11, fully qualified name = 'public.concepto_anticipo', comment = 'Tabla concepto_anticipo');

set add table (set id = $mainset, origin = $origin,
               id = 12, fully qualified name = 'public.configuracion', comment = 'Tabla configuracion');

set add table (set id = $mainset, origin = $origin,
               id = 13, fully qualified name = 'public.consecutivo_origdes', comment = 'Tabla consecutivo_origdes');

set add table (set id = $mainset, origin = $origin,
               id = 14, fully qualified name = 'public.contacto', comment = 'Tabla contacto');

set add table (set id = $mainset, origin = $origin,
               id = 15, fully qualified name = 'public.control_asistencia', comment = 'Tabla control_asistencia');

set add table (set id = $mainset, origin = $origin,
               id = 16, fully qualified name = 'public.control_operario', comment = 'Tabla control_operario');

set add table (set id = $mainset, origin = $origin,
               id = 17, fully qualified name = 'public.cuenta', comment = 'Tabla cuenta');

set add table (set id = $mainset, origin = $origin,
               id = 18, fully qualified name = 'public.cuenta_cobro', comment = 'Tabla cuenta_cobro');

set add table (set id = $mainset, origin = $origin,
               id = 19, fully qualified name = 'public.destino_anticipo', comment = 'Tabla destino_anticipo');

set add table (set id = $mainset, origin = $origin,
               id = 20, fully qualified name = 'public.entrada_bodega', comment = 'Tabla entrada_bodega');

set add table (set id = $mainset, origin = $origin,
               id = 21, fully qualified name = 'public.entregas', comment = 'Tabla entregas');

set add table (set id = $mainset, origin = $origin,
               id = 22, fully qualified name = 'public.factura', comment = 'Tabla factura');

set add table (set id = $mainset, origin = $origin,
               id = 23, fully qualified name = 'public.guia', comment = 'Tabla guia');

set add table (set id = $mainset, origin = $origin,
               id = 24, full qualified name = 'public.interfase_cuenta_cobro', comment = 'Tabla interfase_cuenta_cobro');

set add table (set id = $mainset, origin = $origin, 
                id = 25, full qualified name = 'public.inventario', comment = 'Tabla inventario');

set add table (set id = $mainset, origin = $origin, 
               id = 26, full qualified name = 'public.lote', comment = 'Tabla lote');

set add table (set id = $mainset, origin = $origin,
               id = 27, full qualified name = 'public.manifiesto_carretera', comment = 'Tabla manifiesto_carretera');

set add table (set id = $mainset, origin = $origin, 
               id = 28, full qualified name = 'public.modulo', comment = 'Tabla modulo');

set add table (set id = $mainset, origin = $origin, 
               id = 29, full qualified name = 'public.novedad', comment = 'Tabla novedad');

set add table (set id = $mainset, origin = $origin, 
               id = 30, full qualified name = 'public.oficina', comment = 'Tabla oficina');

set add table (set id = $mainset, origin = $origin, 
               id = 31, full qualified name = 'public.operario', comment = 'Tabla operario');

set add table (set id = $mainset, origin = $origin, 
               id = 32, full qualified name = 'public.operativo', comment = 'Tabla operativo');

set add table (set id = $mainset, origin = $origin, 
               id = 33, full qualified name = 'public.orden_cargue', comment = 'Tabla orden_cargue');

set add table (set id = $mainset, origin = $origin, 
               id = 34, full qualified name = 'public.pago_cuenta', comment = 'Tabla pago_cuenta');

set add table (set id = $mainset, origin = $origin, 
               id = 35, full qualified name = 'public.pago_factura', comment = 'Tabla pago_factura');

set add table (set id = $mainset, origin = $origin, 
               id = 36, full qualified name = 'public.perfil', comment = 'Tabla perfil');

set add table (set id = $mainset, origin = $origin, 
               id = 37, full qualified name = 'public.persona', comment = 'Tabla persona');

set add table (set id = $mainset, origin = $origin, 
               id = 38, full qualified name = 'public.persona_transporte', comment = 'Tabla persona_transporte');

set add table (set id = $mainset, origin = $origin, 
               id = 39, full qualified name = 'public.pieza', comment = 'Tabla pieza');

set add table (set id = $mainset, origin = $origin,
               id = 40, full qualified name = 'public.prefijo', comment = 'Tabla prefijo');

set add table (set id = $mainset, origin = $origin, 
               id = 41, full qualified name = 'public.privilegio', comment = 'Tabla privilegio');

set add table (set id = $mainset, origin = $origin, 
               id = 42, full qualified name = 'public.punto_recogida', comment = 'Tabla punto_recogida');

set add table (set id = $mainset, origin = $origin, 
               id = 43, full qualified name = 'public.recibo_caja', comment = 'Tabla recibo_caja');

set add table (set id = $mainset, origin = $origin,
               id = 44, full qualified name = 'public.reclamo', comment = 'Tabla reclamo');

set add table (set id = $mainset, origin = $origin,
               id = 45, full qualified name = 'public.redespacho', comment = 'Tabla redespacho');

set add table (set id = $mainset, origin = $origin,
               id = 46, full qualified name = 'public.reembolso', comment = 'Tabla reembolso');

set add table (set id = $mainset, origin = $origin,
               id = 47, full qualified name = 'public.registro_llamada', comment = 'Tabla registro_llamada');

set add table (set id = $mainset, origin = $origin, 
               id = 48, full qualified name = 'public.registro_recogida', comment = 'Tabla registro_recogida');

set add table (set id = $mainset, origin = $origin,
               id = 49, full qualified name = 'public.remision_carga', comment = 'Tabla remision_carga');

set add table (set id = $mainset, origin = $origin, 
               id = 50, full qualified name = 'public.remision_guia', comment = 'Tabla remision_guia');

set add table (set id = $mainset, origin = $origin, 
               id = 51, full qualified name = 'public.remision_guia_database', comment = 'Tabla remision_guia_database');

set add table (set id = $mainset, origin = $origin, 
               id = 52, full qualified name = 'public.secuencia', comment = 'Tabla secuencia');

set add table (set id = $mainset, origin = $origin, 
               id = 53, full qualified name = 'public.sucursal', comment = 'Tabla sucursal');

set add table (set id = $mainset, origin = $origin, 
               id = 54, full qualified name = 'public.tarifa', comment = 'Tabla tarifa');

set add table (set id = $mainset, origin = $origin, 
               id = 55, full qualified name = 'public.telemercadeo', comment = 'Tabla telemercadeo');

set add table (set id = $mainset, origin = $origin, 
               id = 56, full qualified name = 'public.tipo', comment = 'Tabla tipo');

set add table (set id = $mainset, origin = $origin, 
               id = 57, full qualified name = 'public.tipo_clasificacion', comment = 'Tabla tipo_clasificacion');

set add table (set id = $mainset, origin = $origin, 
               id = 58, full qualified name = 'public.transaccion', comment = 'Tabla transaccion');

set add table (set id = $mainset, origin = $origin, 
               id = 59, full qualified name = 'public.transito', comment = 'Tabla transito');

set add table (set id = $mainset, origin = $origin,
               id = 60, full qualified name = 'public.traslado_guia', comment = 'Tabla traslado_guia');

set add table (set id = $mainset, origin = $origin, 
               id = 61, full qualified name = 'public.ubicacion', comment = 'Tabla ubicacion');

set add table (set id = $mainset, origin = $origin, 
               id = 62, full qualified name = 'public.usuario', comment = 'Tabla usuario');

set add table (set id = $mainset, origin = $origin, 
               id = 63, full qualified name = 'public.validar_recogida', comment = 'Tabla validar_recogida');

set add table (set id = $mainset, origin = $origin, 
               id = 64, full qualified name = 'public.vehiculo', comment = 'Tabla vehiculo');

set add table (set id = $mainset, origin = $origin, 
               id = 65, full qualified name = 'public.vendedor', comment = 'Tabla vendedor');

set add table (set id = $mainset, origin = $origin, 
               id = 66, full qualified name = 'public.zona', comment = 'Tabla zona');

#lista de secuencias
set add sequence (set id = $mainset, origin = $origin,
               id = 67, full qualified name = 'public.auditoria_guia_secuencial_seq', comment = 'Sequence auditoria_guia_secuencial_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 68, full qualified name = 'public.auditoria_secuencial_seq', comment = 'Sequence auditoria_secuencial_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 69, full qualified name = 'public.configuracion_id_seq', comment = 'Sequence configuracion_id_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 70, full qualified name = 'public.cuenta_cobro_numero_cuenta_seq', comment = 'Sequence cuenta_cobro_numero_cuenta_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 71, full qualified name = 'public.entrada_bodega_numero_registro_seq', comment = 'Sequence entrada_bodega_numero_registro_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 72, full qualified name = 'public.manifiestocarretera_numero_manifiesto_seq', comment = 'Sequence manifiestocarretera_numero_manifiesto_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 73, full qualified name = 'public.modulo_codigo_modulo_seq', comment = 'Sequence modulo_codigo_modulo_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 74, full qualified name = 'public.novedad_numero_novedad_seq', comment = 'Sequence novedad_numero_novedad_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 75, full qualified name = 'public.operativo_codigo_operativo_seq', comment = 'Sequence operativo_codigo_operativo_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 76, full qualified name = 'public.orden_cargue_numero_orden_seq', comment = 'Sequence orden_cargue_numero_orden_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 77, full qualified name = 'public.perfil_codigo_perfil_seq', comment = 'Sequence perfil_codigo_perfil_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 78, full qualified name = 'public.punto_recogida_codigo_punto_seq', comment = 'Sequence punto_recogida_codigo_punto_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 79, full qualified name = 'public.reclamo_numero_reclamo_seq', comment = 'Sequence reclamo_numero_reclamo_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 80, full qualified name = 'public.registro_llamada_codigo_llamada_seq', comment = 'Sequence registro_llamada_codigo_llamada_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 81, full qualified name = 'public.registro_recogida_codigo_recogida_seq', comment = 'Sequence registro_recogida_codigo_recogida_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 82, full qualified name = 'public.remision_carga_numero_remision_seq', comment = 'Sequence remision_carga_numero_remision_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 83, full qualified name = 'public.telemercadeo_codigo_seq', comment = 'Sequence telemercadeo_codigo_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 84, full qualified name = 'public.transaccion_secuencia_seq', comment = 'Sequence transaccion_secuencia_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 85, full qualified name = 'public.transito_codigo_transito_seq', comment = 'Sequence transito_codigo_transito_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 86, full qualified name = 'public.traslado_guia_secuencial_seq', comment = 'Sequence traslado_guia_secuencial_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 87, full qualified name = 'public.validacion_recogida_numero_ingreso_seq', comment = 'Sequence validacion_recogida_numero_ingreso_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 88, full qualified name = 'public.vehiculo_codigo_seq', comment = 'Sequence vehiculo_codigo_seq');

set add sequence (set id = $mainset, origin = $origin, 
               id = 89, full qualified name = 'public.concepto_codigo_concepto_seq', comment = 'Sequence vehiculo_codigo_seq');

store node (id = 2, comment = 'Nodo ESCLAVO');
store path (server = 1, client = 2, conninfo = 'dbname=$DB1 host=$H1 user=$U');
store path (server = 2, client = 1, conninfo = 'dbname=$DB2 host=$H2 user=$U');
store listen (origin = 1, provider = 1, receiver = 2);
store listen (origin = 2, provider = 2, receiver = 1);