#!/bin/bash # vim: set softtabstop=4 tabstop=4 #FUNCIONES AUXILIARES # devuelve 0 si la ruta fue cambiada # y 1 si quedo por defecto function cambiaruta { echo "" echo "Nombre del directorio $1 es: ($2)" echo "Si desea modificarlo ingrese la ruta completa deseada y luego presione ENTER" echo "de lo contrario presione ENTER." echo "" read DIRSELECTED if [ -n "$DIRSELECTED" ]; then return 0 else return 1 fi } #Verifico que el sistema operativo sea correcto. if echo $0 | egrep -q 'AFINSTAL$'; then SISOPTP="Linux" fi if echo $0 | egrep -q 'AFINSTAM$'; then SISOPTP="Mac" fi if echo $0 | egrep -q 'AFINSTAW$'; then SISOPTP="Windows" fi CURSIS=$(uname) # comienzo instalacion si el sistema es correcto if [ "$SISOPTP" != "$CURSIS" ]; then cat< "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "11s(.*(BINDIR = $bindir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "12s(.*(LOGDIR = $logdir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "13s(.*(LOGNAME = $logname(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "14s(.*(LOGSIZE = $logsize(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "15s(.*(DATADIR = $datadir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "16s(.*(DATASIZE = $datasize(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "17s(.*(USERID = $USER(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "18s(.*(FECINS = $fecha(" > "$confdir/afinstal.conf" fi if [ $afic != 0 ]; then fecha=$(date) cat "$confdir/afinstal.conf" | sed "20s/.*/Comando aficonf/" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "21s(.*(BINDIR = $bindir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "22s(.*(LOGDIR = $logdir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "23s(.*(LOGNAME = $logname(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "24s(.*(LOGSIZE = $logsize(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "25s(.*(USERID = $USER(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "26s(.*(FECINS = $fecha(" > "$confdir/afinstal.conf" fi if [ $afim != 0 ]; then fecha=$(date) cat "$confdir/afinstal.conf" | sed "30s/.*/Comando afimonio/" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "31s(.*(BINDIR = $bindir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "32s(.*(LOGDIR = $logdir(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "33s(.*(LOGNAME = $logname(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "34s(.*(LOGSIZE = $logsize(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "35s(.*(USERID = $USER(" > "$confdir/afinstal.conf" cat "$confdir/afinstal.conf" | sed "36s(.*(FECINS = $fecha(" > "$confdir/afinstal.conf" fi if [ $comp == 0 ]; then #busco los datos fecha1=`cat $afinstal | grep -n FECINS | grep 18 | sed s/\.\*\=\ //` fecha2=`cat $afinstal | grep -n FECINS | grep 26 | sed s/\.\*\=\ //` fecha3=`cat $afinstal | grep -n FECINS | grep 36 | sed s/\.\*\=\ //` usu1=`cat $afinstal | grep -n USERID | grep 17 | sed s/\.\*\=\ //` usu2=`cat $afinstal | grep -n USERID | grep 25 | sed s/\.\*\=\ //` usu3=`cat $afinstal | grep -n USERID | grep 35 | sed s/\.\*\=\ //` cat<> "$CONFDIR/afinstal.conf" echo "CONFDIR = $CONFDIR" >> "$CONFDIR/afinstal.conf" for n in `seq 3 51` do echo "" >> "$CONFDIR/afinstal.conf" done linea=10 i=0 fecha=$(date) for comando in antifraude.pl afimonio aficonf ; do op="a" while [ -n "$op" ]; do #Almance el path actual BINDIR="${CURDIR}/bin" DATADIR="${CURDIR}/llamadas" LOGDIR="${CURDIR}/log" echo "La ruta del directorio de instalación es: ($INSTDIR)" echo "La ruta del directorio de configuración es: ($CONFDIR)" echo "La ruta del directorio de ejecutables es: ($BINDIR)" DIRSELECTED="" if cambiaruta "ejecutables" $BINDIR ; then BINDIR=$DIRSELECTED fi if cambiaruta "de datos" $DATADIR ; then DATADIR=$DIRSELECTED fi if cambiaruta "de log" $LOGDIR ; then LOGDIR=$DIRSELECTED fi echo "Nombre del archivo de log: (${comando}.log)" echo "Si desea conservar este nombre presione ENTER, de lo " echo "contrario ingrese un nuevo nombre y luego ENTER" read LOGNAME if [ -z "$logname" ]; then LOGNAME="${comando}.log" fi echo "Tamaño máximo para el archivo <$LOGNAME> (Mb): 20Mb" echo "Si desea conservar este valor presione ENTER, de lo " echo "contrario ingrese un nuevo valor y luego ENTER" read LOGSIZE if [ -z "$LOGSIZE" ]; then LOGSIZE=20 fi cat <, oprima" echo "solamente ENTER, si desea cancelar el proceso oprima" echo "cualquier otra tecla y luego ENTER." read op if [ -n "$op" ]; then echo "Proceso de instalación cancelado" exit 0 fi # Cremos los directorios para este comando echo "Creando Estructura de Directorio...." mkdir -p $BINDIR mkdir -p $DATADIR mkdir -p $DATADIR/{aprocesar,enproceso,rechazadas,procesadas} mkdir -p $LOGDIR touch $LOGDIR/$LOGNAME echo "Moviendo Archivos....." cp $INSTDIR/$comando $BINDIR #cp $INSTDIR/umbrales.param $CONFDIR #cp $INSTDIR/*.data $DATADIR/aprocesar numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s/.*/Comando $comando/" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(BINDIR = $BINDIR(" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(LOGDIR = $LOGDIR(" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(LOGNAME = $LOGNAME(" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(LOGSIZE = $LOGSIZE(" > "$CONFDIR/afinstal.conf" if [ "$FILE" = "antifraude.pl" ]; then i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(DATADIR = $DATADIR(" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(DATASIZE = (" > "$CONFDIR/afinstal.conf" fi i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(USERID = $USER(" > "$CONFDIR/afinstal.conf" i=$(($i+1)) numlinea=$(($linea+$i)) cat "$CONFDIR/afinstal.conf" | sed "$numlinea""s(.*(FECINS = $fecha(" > "$CONFDIR/afinstal.conf" i=0 linea=$(($linea+10)) done #for done #while # Termino la instalacion, muestro informacion. j=10 echo " ***************************************************************** " echo " * Proceso de instalacion concluido * " comandos=`cat "$CONFDIR/afinstal.conf" | grep Comando ` for i in 17 25 35 ; do fecha=`cat "$CONFDIR/afinstal.conf" | grep -n FECINS | grep $i | sed 's/.*= //'` i=$(($i +1)) usu=`cat "$CONDIR/afinstal.conf" | grep -n USERID | grep $i | sed 's/.*= //'` echo " * done fi #else