1 | # Funcoes auxiliares de todo o instalador |
---|
2 | |
---|
3 | # Monta um dialog para que o usuario insira a senha. |
---|
4 | # Depois grava a informacao em uma variavel global "LDAP_PWD". |
---|
5 | get_pass () |
---|
6 | { |
---|
7 | # Se a senha ainda não foi requisitada |
---|
8 | if [ "x$LDAP_PWD" == "x" ] |
---|
9 | then |
---|
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 ) |
---|
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 | |
---|
25 | # Monta um dialog para que o usuario insira a organizacao e dominio |
---|
26 | # Depois grava as informacoes em variaveis globais |
---|
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'` |
---|
44 | # Substitui qualquer coisa depois do primerio '.' por 'nada' |
---|
45 | LDAP_DC=`echo $DOMAIN | sed 's/\..*//g'` |
---|
46 | # Substitui qualquer coisa antes do ultimo '.' por 'nada' |
---|
47 | #LDAP_DC=`echo $DOMAIN | sed 's/.*\.//g'` |
---|
48 | fi |
---|
49 | } |
---|
50 | |
---|
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 | log_erro () |
---|
61 | { |
---|
62 | echo "$1" |
---|
63 | } |
---|
64 | |
---|
65 | qualSO () |
---|
66 | { |
---|
67 | OS=`uname -s` |
---|
68 | REV=`uname -r` |
---|
69 | MACH=`uname -m` |
---|
70 | |
---|
71 | DIST="Desconhecido" |
---|
72 | PSEUDONAME="Desconhecido" |
---|
73 | REV="Desconhecido" |
---|
74 | |
---|
75 | if [ "${OS}" = "SunOS" ] ; then |
---|
76 | OS=Solaris |
---|
77 | ARCH=`uname -p` |
---|
78 | OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" |
---|
79 | msg_erro $OSSTR |
---|
80 | elif [ "${OS}" = "AIX" ] ; then |
---|
81 | OSSTR="${OS} `oslevel` (`oslevel -r`)" |
---|
82 | msg_erro $OSSTR |
---|
83 | elif [ "${OS}" = "Linux" ] ; then |
---|
84 | KERNEL=`uname -r` |
---|
85 | # RedHat ou Centos |
---|
86 | if [ -f /etc/redhat-release ] ; then |
---|
87 | DIST=`cat /etc/redhat-release | cut -d' ' -f1` |
---|
88 | PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` |
---|
89 | REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` |
---|
90 | # Debian, Ubuntu e variantes |
---|
91 | elif [ -f /etc/debian_version ] ; then |
---|
92 | # Verifica se o LSB esta instalado |
---|
93 | LSB=`which lsb_release` |
---|
94 | # Se nao estiver, configura no braco |
---|
95 | if [ -z "$LSB" ] ; then |
---|
96 | DIST="Debian" |
---|
97 | REV=`cat /etc/debian_version` |
---|
98 | # Se nao, usa o LSB. Ubuntu eh reconhecido aqui |
---|
99 | else |
---|
100 | DIST=`lsb_release -si` |
---|
101 | PSEUDONAME=`lsb_release -sc` |
---|
102 | REV=`lsb_release -sr` |
---|
103 | fi |
---|
104 | # TODO: Validar do suse |
---|
105 | elif [ -f /etc/SuSE-release ] ; then |
---|
106 | DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//` |
---|
107 | REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //` |
---|
108 | fi |
---|
109 | |
---|
110 | OSSTR="${OS} ${DIST} ${REV} (${PSEUDONAME} ${KERNEL} ${MACH})" |
---|
111 | fi |
---|
112 | } |
---|
113 | |
---|
114 | validaSO () |
---|
115 | { |
---|
116 | R=1 |
---|
117 | #if [ "$DIST" == "$1" ] && [ `echo $REV | grep -q "$2"` ] |
---|
118 | echo $REV | grep -q "$2" |
---|
119 | if [ $? -eq 0 ] && [ "$DIST" == "$1" ] |
---|
120 | then |
---|
121 | R=0 |
---|
122 | fi |
---|
123 | |
---|
124 | return $R |
---|
125 | } |
---|