#!/bin/sh

LIST_STTACMDS="ldapreplicate scanttacache monitor ttasess stta ensrecreate ensrestore ensload ttatcl setenv_vars openldap oldapadm"
LIST_TTACMDS="tta ttabackup"
LIST_TCLS="ensdump ensrestore"
LIST_lib="ldap-lib.pl lists-lib.pl base-lib.pl ttacache-lib.pl global-lib.pl "
LIST_tcls="ttaDumpDs.tcl ttaRestoreDs.tcl"
LIST_DIRS="tcls lib"
LIST_LNKCMDS="tta"
brandInfoFile=.brandinfofile.deploy
SttaBrandInfoFile=.brandinfofile.stta
STTA_SHELLS=shells
TOOLSDIR=tools


keep_ext=".cgi .pl .sh .js .txt .tcl"
keep_prefix="config default module envprofile"
keep_dir="config_dir images lang help info index cgitools update upgrade patch ldaptools gpl dataconf loadfiles shells"
f_toremove="dataconf/*.gz test.cgi test-list.cgi .brandinfofile.deploy "
d_toremove="devtools ldap save tmp tmpf tools-dev images/.xvpics images/.pics images/old images/thumbs old home-tta tools.old info/info-files updates old-cgis perl-ldap-0.26 old-code sp install/tmp tta copia config_dir patch/tmp  update/tmp upgrade/tmp loadfiles/tmp help/save help/tmp help/es/templ help/empty_files install/info/es/templ lang/tmp tools"
to_copyhere="/etc/webmin/stta/admin.acl /etc/webmin/stta/dataconf"

name="Tarantella"
desc_es="Servicios con Tarantella"
desc_en="Services with Tarantella"
depends="1.0"
version="1.3"

# Others 
dn=/dev/null
WKDIR=/usr/tmp/pack.$$
PAGER=more
CINTADIR=/home2/cinta

# Webmin locations 
WEBMIN=`cat /etc/webmin/miniserv.conf 2>/dev/null | egrep "^root=" | sed 's/root=//g'`

origen=`pwd` 
cd $WEBMIN 2>$dn
WEBMINDIR=`pwd`
cd $origen 
[ ! "$WEBMINDIR" ] && echo "NO WEBMIN DIR " && exit 1
MODULE=stta

# To pack & Save
DESTPACK=/home2/packs/stta
SAVEFILE=stta-1.3.wbm
SAVEDIR=/opt/save
SAVEDIR2=/windows/C/save
BACKUPDIR=/home2/packs/backup
TRASHDIR=$WEBMINDIR/$MODULE/tmp/trash
PACKMAKER=makepack

# TTA 
TTAHOME=/opt/tarantella
STTATOOLS=$TTAHOME/tools

# Dev STTA
DEVTOOLS=$WEBMINDIR/$MODULE/devtools

# tools STTA
MKTOOLS=$WEBMINDIR/$MODULE/mktools.sh

# To run STTA
CP_command=backupnow
SAVE_command=save
CLEANUP_command=cleanup
TOOLSDIR=tools

# To clean 
TOREMOVE=$WEBMINDIR/$MODULE/toremove

# For TCLS
tclShell=/opt/tarantella/tools/tcls/ttatcl.sh
dirTools=/opt/tarantella/tools/tcls
dumpCMD=ttaDumpDs.tcl
restoreCMD=ttaRestoreDS.tcl


# Just to start
origen=`pwd` 
ahora=`date +%Y_%m_%d_%H%M%S`

case "$trace" in
x) set -x
esac

show_file () {
   [ "$1" ] && { 
          [ -r "$1.$LANG" ] && $PAGER "$1.$LANG" && return
          [ -r "$1" ] && $PAGER "$1" && return
   }
}
show_help () {
   [ "$1" ] && { 
          fname=`basename $0 2>$dn` 
          show_file $1/$fname
   }
}

make_dir () {
   mkdir $DESTDIR 2>$dn
   [ ! -d $DESTDIR ] && exit 2
   chown root:bin $DESTDIR
   chmod 755 $DESTDIR
}
