[5797] | 1 | # Funcoes auxiliares de todo o instalador |
---|
| 2 | |
---|
[6207] | 3 | # Monta um dialog para que o usuario insira a senha. |
---|
| 4 | # Depois grava a informacao em uma variavel global "LDAP_PWD". |
---|
[5797] | 5 | get_pass () |
---|
| 6 | { |
---|
| 7 | # Se a senha ainda não foi requisitada |
---|
| 8 | if [ "x$LDAP_PWD" == "x" ] |
---|
| 9 | then |
---|
[5851] | 10 | LDAP_PWD=$( dialog --backtitle "$BACKTITLE" --stdout --inputbox 'Digite uma senha:' 0 0 ) |
---|
| 11 | LDAP_PWD_CONF=$( dialog --backtitle "$BACKTITLE" --stdout --inputbox 'Confirme a senha:' 0 0 ) |
---|
[5797] | 12 | if [ "x$LDAP_PWD" != "x$LDAP_PWD_CONF" ] |
---|
| 13 | then |
---|
| 14 | dialog --backtitle "$BACKTITLE" --title 'As senhas não conferem' \ |
---|
| 15 | --msgbox 'Favor digitar as duas senhas iguais!!!' 6 45 |
---|
| 16 | # Zera a senha e chama novamente a tela de senha |
---|
| 17 | unset LDAP_PWD |
---|
| 18 | get_pass |
---|
| 19 | fi |
---|
| 20 | # Gera a senha para o arquivo de configuração do LDAP |
---|
| 21 | LDAP_PWD_MD5=`$ARQS/scripts/md5pass.pl $LDAP_PWD` |
---|
| 22 | fi |
---|
| 23 | } |
---|
| 24 | |
---|
[6207] | 25 | # Monta um dialog para que o usuario insira a organizacao e dominio |
---|
| 26 | # Depois grava as informacoes em variaveis globais |
---|
[5797] | 27 | get_org () |
---|
| 28 | { |
---|
| 29 | if [ "x$ORG" == "x" ] || [ "x$DOMAIN" == "x" ] |
---|
| 30 | then |
---|
| 31 | ORG=$( dialog --backtitle "$BACKTITLE" --stdout --inputbox 'Digite uma organização:(ex.: celepar)' 0 55 ) |
---|
| 32 | DOMAIN=$( dialog --backtitle "$BACKTITLE" --stdout --inputbox 'Digite seu domÃnio:(ex.: '$ORG'.com.br)' 0 55 ) |
---|
| 33 | if [ "x$ORG" == "x" ] || [ "x$DOMAIN" == "x" ] |
---|
| 34 | then |
---|
| 35 | dialog --backtitle "$BACKTITLE" --title 'Organização ou domÃnio inválido!' \ |
---|
| 36 | --msgbox 'Favor preencher a organização E o domÃnio!!' 6 50 |
---|
| 37 | # Zera as variaveis e chama o dialog novamente |
---|
| 38 | unset ORG |
---|
| 39 | unset DOMAIN |
---|
| 40 | get_org |
---|
| 41 | fi |
---|
| 42 | # Substitui o '.' por ',dc=' |
---|
| 43 | LDAP_DN=`echo "dc=$DOMAIN" | sed 's/\./,dc=/g'` |
---|
[6202] | 44 | # Substitui qualquer coisa depois do primerio '.' por 'nada' |
---|
| 45 | LDAP_DC=`echo $DOMAIN | sed 's/\..*//g'` |
---|
[6173] | 46 | # Substitui qualquer coisa antes do ultimo '.' por 'nada' |
---|
[6202] | 47 | #LDAP_DC=`echo $DOMAIN | sed 's/.*\.//g'` |
---|
[5797] | 48 | fi |
---|
| 49 | } |
---|
| 50 | |
---|
[6219] | 51 | # Detects which OS and if it is Linux then it will detect which Linux |
---|
| 52 | # Distribution. |
---|
| 53 | # http://linuxmafia.com/faq/Admin/release-files.html |
---|
| 54 | msg_erro () |
---|
| 55 | { |
---|
| 56 | echo "Sistema operacional ($1) não suportado!" |
---|
| 57 | exit 1 |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | qualSO () |
---|
| 61 | { |
---|
| 62 | OS=`uname -s` |
---|
| 63 | REV=`uname -r` |
---|
| 64 | MACH=`uname -m` |
---|
| 65 | |
---|
| 66 | DIST="Desconhecido" |
---|
| 67 | PSEUDONAME="Desconhecido" |
---|
| 68 | REV="Desconhecido" |
---|
| 69 | |
---|
| 70 | if [ "${OS}" = "SunOS" ] ; then |
---|
| 71 | OS=Solaris |
---|
| 72 | ARCH=`uname -p` |
---|
| 73 | OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" |
---|
| 74 | msg_erro $OSSTR |
---|
| 75 | elif [ "${OS}" = "AIX" ] ; then |
---|
| 76 | OSSTR="${OS} `oslevel` (`oslevel -r`)" |
---|
| 77 | msg_erro $OSSTR |
---|
| 78 | elif [ "${OS}" = "Linux" ] ; then |
---|
| 79 | KERNEL=`uname -r` |
---|
| 80 | # RedHat ou Centos |
---|
| 81 | if [ -f /etc/redhat-release ] ; then |
---|
| 82 | DIST=`cat /etc/redhat-release | cut -d' ' -f1` |
---|
| 83 | PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` |
---|
| 84 | REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` |
---|
[6261] | 85 | # Debian, Ubuntu e variantes |
---|
[6219] | 86 | elif [ -f /etc/debian_version ] ; then |
---|
[6261] | 87 | # Verifica se o LSB esta instalado |
---|
| 88 | LSB=`which lsb_release` |
---|
| 89 | # Se nao estiver, configura no braco |
---|
| 90 | if [ -z "$LSB" ] ; then |
---|
| 91 | DIST="Debian" |
---|
| 92 | REV=`cat /etc/debian_version` |
---|
| 93 | # Se nao, usa o LSB. Ubuntu eh reconhecido aqui |
---|
| 94 | else |
---|
| 95 | DIST=`lsb_release -si` |
---|
| 96 | PSEUDONAME=`lsb_release -sc` |
---|
| 97 | REV=`lsb_release -sr` |
---|
| 98 | fi |
---|
[6219] | 99 | # TODO: Validar do suse |
---|
| 100 | elif [ -f /etc/SuSE-release ] ; then |
---|
| 101 | DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//` |
---|
| 102 | REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //` |
---|
| 103 | fi |
---|
| 104 | |
---|
| 105 | OSSTR="${OS} ${DIST} ${REV} (${PSEUDONAME} ${KERNEL} ${MACH})" |
---|
| 106 | fi |
---|
| 107 | } |
---|
| 108 | |
---|
[6261] | 109 | qualSO |
---|
| 110 | echo $OSSTR |
---|
| 111 | |
---|
[6219] | 112 | validaSO () |
---|
| 113 | { |
---|
| 114 | R=1 |
---|
| 115 | #if [ "$DIST" == "$1" ] && [ `echo $REV | grep -q "$2"` ] |
---|
| 116 | echo $REV | grep -q "$2" |
---|
| 117 | if [ $? -eq 0 ] && [ "$DIST" == "$1" ] |
---|
| 118 | then |
---|
| 119 | R=0 |
---|
| 120 | fi |
---|
| 121 | |
---|
| 122 | return $R |
---|
| 123 | } |
---|