#!/bin/sh
# STTA Rev. 1.3 Copyright (c) 2001-2003 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.3pre1049295437- [2003_4_02_165717]

# Environment ...
lang="es";
is_STTA=true;

TTAHOME="/opt/tarantella"
TTA=$TTAHOME"/bin/tarantella"

case "$lang" in 
   es|ES)
          msg_default="Por defecto"
          msg_dbcreate="Creando Base de Datos"
          msg_dbdelete="Borrando Directorio de Base de Datos"
          msg_orgname="Nombre de la Organizacion: "
          ;;       
   *) 
          msg_default="by default"
          msg_dbcreate="Making Data Base"
          msg_dbdelete="Deleting Data Basei Directory"
          msg_orgname="Organization Name: "
          ;;       
esac


RenameOrg() {
    if [ "$#" -eq 0 ] ; then 
             echo -n -e "$msg_orgname" 
             read ouname
    else 
             ouname=`echo $* | sed 's/o=//g' 2>/dev/null` 
    fi    
    outcmd=`$TTA object rename  --name o=organization  --newname o="$ouname" ` 
    [ -n $outcmd ] && echo "$outcmd"  
}

CreateDefaultDB(){
    #/opt/tarantella/bin/scripts/install_scripts/vendor/SCO/Tarantella/SCO.defaults
    #/opt/tarantella/bin/scripts/install_scripts/pip/vendor/SCO/Tarantella/SCO.defaults

    echo "$msg_dbcreate $msg_default ..."

    INSTDIR=$TTAHOME ; export INSTDIR
    TTAINSTSCRIPTS=$INSTDIR/bin/scripts/install_scripts
    cd $TTAINSTSCRIPTS

        for dir in vendor */vendor; do
        (
            cd $dir
            # script names are <vendor>/<product>/<vendor>.defaults
            # (eg SCO/Tarantella/SCO.defaults)
            for DefaultsScript in */*/*.defaults; do
                sh $xflag $DefaultsScript >>$INSTDIR/var/log/setup.log 2>&1
            done
        )
        done
}

tta stop --force
echo "$msg_dbdelete ..."
rm -r $TTAHOME/var/ens 
CreateDefaultDB
tta start

RenameOrg $*
