dcInstall ; 
 ; ----------------------------------------------------------------------------
 ; #
 ; #  DivConq
 ; #
 ; #  http://divconq.com/
 ; #
 ; #  Copyright:
 ; #    Copyright 2012 eTimeline, LLC. All rights reserved.
 ; #
 ; #  License:
 ; #    See the dcLicense.txt file in the project's top-level directory for details.
 ; #
 ; #  Authors:
 ; #    * Andy White
 ; #
 ; ----------------------------------------------------------------------------
 ;
 n input
 w "All data will be lost"
 w !,"Are you sure you want to install? "
 r input
 s input=$tr(input,"Y","y")
 i $e(input,1)'="y" q
 ;
 w !,"Hub Id (5 digits, zero pad): "
 r input			
 ;
 i input'?5N w !,"Invalid Id" quit
 ;
 d install(input)
 w !,"OK"
 quit
 ;
 ; start fresh but keep Hub settings
 ;
reinstall n input,hub
 s input=^Hub("Id")
 d install(input)
 w !,"OK"
 quit
 ;
install(id) n x
 ;
 ; clean out old
 ;
 d trunc
 ;
 ; setup install
 ;
 s ^Hub("Id")=id
 s ^Hub("Seed")=$$buildCode^dcStrUtil(64)
 ;s ^Hub("BackupDir")="/home/gtmuser/backup/"
 s ^Hub("DebugLevel")="Info"
 ;s ^Hub("TimeZone")="America/New_York"		TODO
 s ^Hub("Locale")="en_US"
 ;
 w !,"Audit level (1-4): "				; TODO check inputs
 r x
 s:x="" x=1
 i x'?5N w !,"Invalid Level, using 1" s x=1
 ;
 s ^Hub("Audit")=x
 ;
 d minSchema
 ;
 quit
 ;
 ;
 ;
minSchema ; core procedures
 s ^Proc("dcPing")="ping^dcConn"
 s ^Proc("dcEcho")="echo^dcConn"
 s ^Proc("dcSchemaUpdate")="update^dcSchema"
 s ^Proc("dcSeed")="seed^dcUser"
 s ^Proc("dcCleanup")="cleanup^dcUser"
 ;
 ; core translations
 s ^Locale("en","_code_50000")="'{$1}' not recognized"
 s ^Locale("en","_code_50001")="Exception in operation '{$1}'"
 s ^Locale("en","_code_50002")="Missing execute context for '{$1}'"
 s ^Locale("en","_code_50100")="Missing backup time stamp"
 ;
 quit 
 ;
 ;
 ;
uninstall n input
 w "All data will be lost"
 w !,"Are you sure you want to continue? "
 r input
 s input=$tr(input,"Y","y")
 i $e(input,1)="y" d trunc w !,"OK"
 quit
 ;
trunc ;
 k ^Record
 k ^Cache
 k ^Params
 k ^Index1
 k ^Index2
 k ^DynamicIndex
 k ^RecordTasks
 k ^Audit
 k ^AuditTime
 k ^Log
 k ^LogUser
 k ^LogTime
 k ^Replication
 k ^RecordMeta
 k ^XLog
 k ^Session
 ;
 k ^Locale
 k ^Schema
 k ^Hub
 k ^Proc
 k ^Filter1
 k ^Filter2
 k ^Composer1
 k ^Composer2
 k ^Composer3
 k ^Collector
 ;
 quit 
 ;
