#!/bin/bash # > ----------------------------------------- # Run that script with bash even if the user use sh/dash or any sh like # interpreter. This way it correctly works with either: # "sh ./my_script.bash" or "bash ./my_script.bash" or "./my_script.bash" if [ -z "$BASH_VERSION" ] then exec bash "$0" "$@" fi # < ----------------------------------------- # NOTE: Evita problemas com caminhos relativos! By Questor SCRIPTDIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . $SCRIPTDIR_V/ez_i.bash # > -------------------------------------------------------------------------- # INÍCIO! # -------------------------------------- read -d '' TITLE_F <<"EOF" LBC - LBConverter Installer EOF # NOTE: Para versionamento usar "MAJOR.MINOR.REVISION.BUILDNUMBER"! # Usar a mesma versão contida no setup.py! By Questor # http://programmers.stackexchange.com/questions/24987/what-exactly-is-the-build-number-in-major-minor-buildnumber-revision read -d '' VERSION_F <<"EOF" 0.1.2.0 EOF read -d '' ABOUT_F <<"EOF" This script will install LBC - LBConverter the LightBase OCR (Optical Character Recognition)/data extractor component that obtain data from submitted files! Have fun! =D EOF read -d '' WARNINGS_F <<"EOF" - This installer is compatible with RHEL, SUSE, Debian or distributions based on these. - We RECOMMEND you... Install all the components (answer yes to everything) and use the default values. Except contrary guidance! Check for previous installations! If there is previous installations consider this variant in the process! Although this is not mandatory, do the installation process in an exclusive machine for this. - We NOTICE you... This installer assumes that the target distribution has a "standard setup". This may include components such as firewall, SELinux and others. - We WARNING you... THIS INSTALLER AND RESULTING PRODUCTS COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! WE ARE NOT RESPONSIBLE FOR ANY DAMAGE TO YOURSELF, HARDWARE, OR CO-WORKERS. EXCEPT IN CASES WHERE THERE ARE SIGNED CONTRACT THAT REGULATES THIS! EOF read -d '' COMPANY_F <<"EOF" BR Light LTDA - LightBase Consulting in Public Software/LightBase Consultoria em Software Público Software livre! Abrace essa idéia!/Free software! Embrace that idea! +55-61-3347-1949/+55-61-3340-6966 - http://brlight.org/ - Brasil-DF EOF f_begin "$TITLE_F" "$VERSION_F" "$ABOUT_F" "$WARNINGS_F" "$COMPANY_F" ABOUT_F="" WARNINGS_F="" # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # TERMOS E LICENÇA! # -------------------------------------- read -d '' TERMS_LICEN_F <<"EOF" BY USING THIS INSTALLER YOU ARE AGREEING TO THE TERMS OF USE OF ALL INVOLVED SOFTWARE! EOF f_terms_licen "$TERMS_LICEN_F" TERMS_LICEN_F="" # < -------------------------------------------------------------------------- # > ----------------------------------------- # Checar se o usuário é root! f_is_root # < ----------------------------------------- # > -------------------------------------------------------------------------- # INTRUÇÕES! # -------------------------------------- read -d '' INSTRUCT_F <<"EOF" - TO CANCEL installation at any time use Ctrl+c! EOF f_instruct "$INSTRUCT_F" INSTRUCT_F="" # < -------------------------------------------------------------------------- DISTRO_TYPE="" DISTRO_NAME="" # > ----------------------------------------- # Checar se a distro é compatível! f_open_section f_about_distro f_div_section echo "DISTRO INFORMATION:" f_div_section echo "NAME: .... ${F_ABOUT_DISTRO_R[0]}" echo "VERSION: . ${F_ABOUT_DISTRO_R[1]}" echo "BASED: ... ${F_ABOUT_DISTRO_R[2]}" echo "ARCH: .... ${F_ABOUT_DISTRO_R[3]}" f_div_section if [[ "${F_ABOUT_DISTRO_R[2]}" == "Debian" ]] || [[ "${F_ABOUT_DISTRO_R[2]}" == "RedHat" ]] || [[ "${F_ABOUT_DISTRO_R[2]}" == "Suse" ]] ; then if [[ "${F_ABOUT_DISTRO_R[2]}" == "Debian" ]] ; then DISTRO_TYPE="DEB" if [[ "${F_ABOUT_DISTRO_R[0]}" == "Ubuntu" ]] ; then DISTRO_NAME="Ubuntu" if [[ "${F_ABOUT_DISTRO_R[1]}" != "14.04" ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 14.04/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "Debian GNU/Linux" ]] ; then DISTRO_NAME="Debian" if [[ "${F_ABOUT_DISTRO_R[1]}" != "8" ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 8/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: Ubuntu or Debian/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[2]}" == "RedHat" ]] ; then DISTRO_TYPE="RH" if [[ "${F_ABOUT_DISTRO_R[0]}" == "Red Hat Enterprise Linux Server" ]] ; then DISTRO_NAME="RedHat" if [[ "${F_ABOUT_DISTRO_R[1]}" != "7"* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 7.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "CentOS Linux" ]] ; then DISTRO_NAME="CentOS" if [[ "${F_ABOUT_DISTRO_R[1]}" != "7"* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 7.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: CentOS or Red Hat Enterprise Linux Server/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[2]}" == "Suse" ]] ; then DISTRO_TYPE="SUSE" if [[ "${F_ABOUT_DISTRO_R[0]}" == "openSUSE" ]] ; then DISTRO_NAME="openSUSE" if [[ "${F_ABOUT_DISTRO_R[1]}" != "13."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 13.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "SLES" ]] ; then DISTRO_NAME="SLES" if [[ "${F_ABOUT_DISTRO_R[1]}" != "12."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 12.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: openSUSE or SUSE Linux Enterprise Server/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi fi if [[ "${F_ABOUT_DISTRO_R[3]}" != "x86_64" ]] ; then f_enter_to_cont "Linux architecture completely incompatible with this installer (expected: x86_64/obtained: ${F_ABOUT_DISTRO_R[3]})!" exit 0 fi else f_enter_to_cont "Linux distro completely incompatible with this installer (expected: Debian (or based) or RedHat (or based) or SUSE (or based)/obtained: ${F_ABOUT_DISTRO_R[2]})!" exit 0 fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Dá ao usuário a possibilidade de usar o instalador no modo rápido. Bom para # conhecer/testar o sistema de forma simples sem preucupar-se com configurações! # NOTE: É possível forçar o processo de instalação no modo rápido setando # "FAST_INST" com 1! By Questor FAST_INST=0 if [ ${FAST_INST} -eq 0 ] ; then f_open_section f_div_section f_yes_no "Use fast install (use default values for most of the options)? NOTE: RECOMMENDED FOR THOSE who want to KNOW and TEST the LB system components quickly and easily. DO NOT USE FOR PRODUCTION ENVIRONMENT! If YES the installation of all LB system components MUST AND WILL BE LOCAL! Use it?" if [ ${YES_NO_R} -eq 1 ] ; then # NOTE: Essa variável serve apenas para "preservar" o valor # setado pelo usuário sendo somente "leitura". A variável a # ser usada nas regras deve ser "EZ_I_SKIP_ON_V" (ez_i.bash)! Essa # estratégia serve para mudarmos o comportamento do "ez_i.bash" # de acordo com as circunstâncias! By Questor FAST_INST=1 # NOTE: Essa variável é para consumo do "ez_i.bash", para que ele # não execute algumas funções e torne o processo de # instalação mais simples! By Questor EZ_I_SKIP_ON_V=1 fi f_close_section sleep 1 fi # < ----------------------------------------- # > ----------------------------------------- # Desabilita o SElinux! if [[ "$DISTRO_TYPE" == "RH" ]] ; then EZ_I_SKIP_ON_V=0 f_open_section f_div_section f_yes_no "Disable SElinux (use "y" if you never did it)?" if [ ${YES_NO_R} -eq 1 ] ; then setenforce 0 # NOTE: As condições abaixo visam evitar que o arquivo seja # desnecessariamente e erroneamente modificado! By Questor EZ_I_SKIP_ON_V=$FAST_INST f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" EZ_I_SKIP_ON_V=0 if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_fl_cont_str "SELINUX=disabled" "/etc/sysconfig/selinux" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "SELINUX=enforcing" "# SELINUX=enforcing\nSELINUX=disabled" "/etc/sysconfig/selinux" fi fi fi f_close_section fi # < ----------------------------------------- # > ----------------------------------------- # Atualizar a distro (repositório)! EZ_I_SKIP_ON_V=$FAST_INST f_open_section if [[ "$DISTRO_TYPE" == "RH" ]] ; then if [[ "$DISTRO_NAME" == "RedHat" ]] ; then RESOURCES_ARR_P=("Red Hat Enterprise Linux Server") f_chk_distro_status "$DISTRO_NAME" RESOURCES_ARR_P[@] fi f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then yum -y update fi f_pack_is_inst "git" "yum" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install git fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then apt-get -y update fi f_pack_is_inst "git" "apt-get" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install git fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then if [[ "$DISTRO_NAME" == "SLES" ]] ; then RESOURCES_ARR_P=("SUSE_Linux_Enterprise_Server_12_SP1_x86_64" "SUSE_Linux_Enterprise_Software_Development_Kit_12_SP1_x86_64" "Web_and_Scripting_Module_12_x86_64") f_chk_distro_status "SLES" RESOURCES_ARR_P[@] fi f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then zypper --non-interactive update fi f_pack_is_inst "git-core" "zypper" "\"git-core\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install git-core fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar pacotes que são comuns a determinados componentes! F_COM_PKS_INSTALLED=0 f_common_packs() { : 'Instalar pacotes que são comuns a determinados componentes.' if [ ${F_COM_PKS_INSTALLED} -eq 0 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "gcc-c++" "yum" "\"gcc-c++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install gcc-c++ fi f_pack_is_inst "autoconf" "yum" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install autoconf fi f_pack_is_inst "automake" "yum" "\"automake\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install automake fi f_pack_is_inst "libtool" "yum" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libtool fi f_pack_is_inst "zlib-devel" "yum" "\"zlib-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install zlib-devel fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "g++" "apt-get" "\"g++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install g++ fi f_pack_is_inst "autoconf" "apt-get" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install autoconf fi f_pack_is_inst "make" "apt-get" "\"make\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install make fi f_pack_is_inst "libtool" "apt-get" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libtool fi f_pack_is_inst "zlib1g-dev" "apt-get" "\"zlib1g-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install zlib1g-dev fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "gcc-c++" "zypper" "\"gcc-c++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install gcc-c++ fi if [[ "$DISTRO_NAME" != "SLES" ]] ; then f_pack_is_inst "autoconf" "zypper" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install autoconf fi f_pack_is_inst "automake" "zypper" "\"automake\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install automake fi f_pack_is_inst "make" "zypper" "\"make\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install make fi f_pack_is_inst "libtool" "zypper" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libtool fi fi f_pack_is_inst "zlib-devel" "zypper" "\"zlib-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install zlib-devel fi fi F_COM_PKS_INSTALLED=1 fi } # < ----------------------------------------- # > ----------------------------------------- # Passa comando para serviços conforme a distro em execução! f_svc_helper() { : 'Passa comando para serviços conforme a distro em execução. Args: SVC_HLP_NM_P (str): Nome do serviço. SVC_HLP_CMD_P (str): Comando para o serviço executar. SVC_HLP_IN_SILENCE (Optional[int]): 1 - Sem saída para o terminal; 0 - Com saída para o terminal. Padrão 0. ' SVC_HLP_NM_P=$1 SVC_HLP_CMD_P=$2 SVC_HLP_IN_SILENCE=$3 if [ -z "$SVC_HLP_IN_SILENCE" ] ; then SVC_HLP_IN_SILENCE=0 fi if [ ${SVC_HLP_IN_SILENCE} -eq 1 ] ; then SVC_HLP_SILENCE_CMD=" &>/dev/null" fi if [[ "$DISTRO_TYPE" == "RH" ]] ; then eval "systemctl $SVC_HLP_CMD_P $SVC_HLP_NM_P.service$SVC_HLP_SILENCE_CMD" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then eval "service $SVC_HLP_NM_P $SVC_HLP_CMD_P$SVC_HLP_SILENCE_CMD" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then eval "service $SVC_HLP_NM_P $SVC_HLP_CMD_P$SVC_HLP_SILENCE_CMD" fi } # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para uma porta definida para um dado serviço f_fire_hlp() { : 'Abrir o firewall para uma porta definida para um dado serviço. Args: FIRE_SVC_NM_P (str): Nome do serviço. FIRE_PORT_P (int): Porta a ser aberta. ' FIRE_SVC_NM_P=$1 FIRE_PORT_P=$2 if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then EZ_I_SKIP_ON_V=$FAST_INST if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_div_section f_yes_no "Open firewall for $FIRE_SVC_NM_P (TCP $FIRE_PORT_P)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables $FIRE_PORT_P "Port $FIRE_PORT_P is already open!" 0 "ACCEPT" "tcp" "NEW" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then firewall-cmd --zone=public --add-port=$FIRE_PORT_P/tcp --permanent firewall-cmd --reload fi fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_div_section f_yes_no "Open firewall for $FIRE_SVC_NM_P (TCP $FIRE_PORT_P)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables $FIRE_PORT_P "Port $FIRE_PORT_P is already open!" 0 "ACCEPT" "tcp" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then SuSEfirewall2 open EXT TCP $FIRE_PORT_P SuSEfirewall2 stop SuSEfirewall2 start fi fi fi fi } # < ----------------------------------------- # > -------------------------------------------------------------------------- # INSTALAÇÃO DO LBC - LBConverter! # -------------------------------------- BASE_INST_DIR_V="/usr/local/lb" # > ----------------------------------------- # Criar o diretório base da instalação! f_create_base_dir() { EZ_I_SKIP_ON_V=$FAST_INST QUESTION_F="Insert where the base installation directory (name \"lb\") will be created (don't use \"/\" at the end). Use empty for \"/usr/local\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ -z "$GET_USR_INPUT_R" ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then mkdir -p "$BASE_INST_DIR_V" fi else BASE_INST_DIR_V="$GET_USR_INPUT_R/lb" f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then mkdir -p "$BASE_INST_DIR_V" fi fi } # < ----------------------------------------- # > ----------------------------------------- # Instalar o virtualenv-1.11.6 no python2.X! PYTHON_2_X="" VE_2_X="" f_inst_ve_py2X() { : 'Instala a virtualenv no Python2.X! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [[ "$DISTRO_TYPE" == "RH" ]] ; then PYTHON_2_X="2.7" VE_2_X="ve27" elif [[ "$DISTRO_TYPE" == "DEB" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then PYTHON_2_X="2.7" VE_2_X="ve27" fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install virtualenv-1.11.6 on python$PYTHON_2_X?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_chk_by_path_hlp "/usr/bin/virtualenv-$PYTHON_2_X" "f" "virtualenv-1.11.6 already installed!" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_chk_by_path_hlp "/usr/local/bin/virtualenv-$PYTHON_2_X" "f" "virtualenv-1.11.6 already installed!" fi if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "python-setuptools" "yum" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install python-setuptools fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "python-setuptools" "apt-get" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install python-setuptools fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then # >>>>>>>>>>>>> * Para "zypper --non-interactive install python-setuptools", se o problema abaixo aparecer... # Problem: python-setuptools-5.4.1-2.1.4.noarch requires python, but this requirement cannot be provided # uninstallable providers: python-2.7.8-1.1.x86_64[openSUSE-13.2-0] # python3-3.4.1-4.2.1.x86_64[openSUSE-13.2-0] # python-2.7.8-1.1.i586[repo-oss] # python3-3.4.1-4.2.1.i586[repo-oss] # python-2.7.8-1.1.x86_64[repo-oss] # python3-3.4.1-4.2.1.x86_64[repo-oss] # Solution 1: deinstallation of patterns-openSUSE-minimal_base-conflicts-20141007-2.1.x86_64 # Solution 2: do not install python-setuptools-5.4.1-2.1.4.noarch # Solution 3: do not install python-setuptools-5.4.1-2.1.4.noarch # Solution 4: break python-setuptools-5.4.1-2.1.4.noarch by ignoring some of its dependencies # Choose from above solutions by number or cancel [1/2/3/4/c] (c): # <<<<<<<<<<<<< # >>>>>>>>>>>>> * Usar 1 e y... # Choose from above solutions by number or cancel [1/2/3/4/c] (c): 1 # Resolving dependencies... # Resolving package dependencies... # The following 4 NEW packages are going to be installed: # libsqlite3-0 python python-setuptools python-xml # The following package is going to be REMOVED: # patterns-openSUSE-minimal_base-conflicts # The following pattern is going to be REMOVED: # minimal_base-conflicts # 4 new packages to install, 1 to remove. # Overall download size: 1.1 MiB. Already cached: 0 B After the operation, additional 4.2 MiB will be used. # Continue? [y/n/? shows all options] (y): # <<<<<<<<<<<<< # f_pack_is_inst "python-setuptools" "zypper" "\"python-setuptools\" already installed!" # if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then # zypper --non-interactive install python-setuptools # zypper --non-interactive install python-devel # fi f_pack_is_inst "python-setuptools" "zypper" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then f_get_stderr_stdout "zypper --non-interactive install python-setuptools" if [[ $F_GET_STDERR_R$F_GET_STDOUT_R == *"Problem: python-setuptools-"* ]] && [[ $F_GET_STDERR_R$F_GET_STDOUT_R == *".noarch requires python, but this requirement cannot be provided"* ]] ; then EZ_I_SKIP_ON_V=0 f_enter_to_cont "The package management \"zypper\" WILL ASK YOU FOR ADDITIONAL OPTIONS! We highly recommended you answer \"1\" and \"y\", respectively!" EZ_I_SKIP_ON_V=$FAST_INST zypper install python-setuptools zypper --non-interactive install python-devel else echo "$F_GET_STDERR_R$F_GET_STDOUT_R" fi fi fi f_common_packs cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf virtualenv-1.11.6.tar.gz cd virtualenv-1.11.6 python$PYTHON_2_X setup.py install cd .. rm -rf virtualenv-1.11.6 fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Criar o ambiente virtual (python2.X)! f_create_ve2X() { : 'Cria o ambiente virtual (python2.X)! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja criar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi f_enter_to_cont "Create the virtual environment (python$PYTHON_2_X)!" EZ_I_SKIP_ON_V=$FAST_INST f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X" "d" "Virtual environment (python$PYTHON_2_X) already created in \"$BASE_INST_DIR_V/$VE_2_X\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then f_common_packs cd "$BASE_INST_DIR_V" virtualenv-$PYTHON_2_X $VE_2_X mkdir "$BASE_INST_DIR_V/$VE_2_X/src" fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar o catdoc, unzip e ImageMagick para o LBConverter! f_inst_catdoc_unzip_imagemagick() { : 'Instala os componentes catdoc, unzip e imagemagick. Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi INST_CATDOC_UNZIP_IMAGMAG="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then INST_CATDOC_UNZIP_IMAGMAG="Install catdoc, unzip and ImageMagick?" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then INST_CATDOC_UNZIP_IMAGMAG="Install catdoc, unzip and ImageMagick?" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then INST_CATDOC_UNZIP_IMAGMAG="Install catdoc and ImageMagick?" fi f_yes_no "$INST_CATDOC_UNZIP_IMAGMAG" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST UP_CATDOC=1 f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X/lib/catdoc-0.94.2" "d" "catdoc-0.94.2 already installed in \"$BASE_INST_DIR_V/$VE_2_X/lib/catdoc-0.94.2\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then if [ ${EZ_I_SKIP_ON_V} -eq 0 ] ; then f_div_section f_yes_no "Update/reinstall catdoc-0.94.2? (\"y\" recommended)" UP_CATDOC=$YES_NO_R if [ ${UP_CATDOC} -eq 1 ] ; then rm -rf "$BASE_INST_DIR_V/$VE_2_X/lib/catdoc-0.94.2" fi fi fi if [ ${UP_CATDOC} -eq 1 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_common_packs f_pack_is_inst "unzip" "yum" "\"unzip\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install unzip fi f_pack_is_inst "ImageMagick" "yum" "\"ImageMagick\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install ImageMagick fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_common_packs f_pack_is_inst "unzip" "apt-get" "\"unzip\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install unzip fi f_pack_is_inst "imagemagick" "apt-get" "\"imagemagick\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install imagemagick fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_common_packs f_pack_is_inst "ImageMagick" "zypper" "\"ImageMagick\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install ImageMagick fi fi cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf catdoc-0.94.2.tar.gz mv ./catdoc-0.94.2 $BASE_INST_DIR_V/$VE_2_X/lib cd $BASE_INST_DIR_V/$VE_2_X/lib/catdoc-0.94.2 ./configure make && make install fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar o tesseract-ocr-3.02.02! f_inst_tesseract() { : 'Instala o tesseract. Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install tesseract-ocr-3.02.02?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST UP_TESSERACT_OCR=1 f_chk_by_path_hlp "/usr/local/lib/tesseract-ocr" "d" "tesseract-ocr-3.02.02 already installed in \"/usr/local/lib/tesseract-ocr\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then if [ ${EZ_I_SKIP_ON_V} -eq 0 ] ; then f_div_section f_yes_no "Update/reinstall tesseract-ocr-3.02.02? (\"y\" recommended)" UP_TESSERACT_OCR=$YES_NO_R fi fi if [ ${UP_TESSERACT_OCR} -eq 1 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_common_packs f_pack_is_inst "libpng12-devel" "yum" "\"libpng12-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libpng-devel fi f_pack_is_inst "libjpeg-turbo-devel" "yum" "\"libjpeg-turbo-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libjpeg-turbo-devel fi f_pack_is_inst "libtiff-devel" "yum" "\"libtiff-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libtiff-devel fi f_pack_is_inst "openjpeg-libs" "yum" "\"openjpeg-libs\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install openjpeg-libs fi f_pack_is_inst "giflib" "yum" "\"giflib\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install giflib fi if [[ "$DISTRO_NAME" == "RedHat" ]] ; then f_pack_is_inst "libwebp" "yum" "\"libwebp\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libwebp fi else f_pack_is_inst "libwebp-devel" "yum" "\"libwebp-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libwebp-devel fi fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_common_packs f_pack_is_inst "libpng-dev" "apt-get" "\"libpng-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libpng-dev fi f_pack_is_inst "libjpeg-dev" "apt-get" "\"libjpeg-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libjpeg-dev fi f_pack_is_inst "libtiff-dev" "apt-get" "\"libtiff-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libtiff-dev fi f_pack_is_inst "libopenjpeg2" "apt-get" "\"libopenjpeg2\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libopenjpeg2 fi f_pack_is_inst "libgif-dev" "apt-get" "\"libgif-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libgif-dev fi f_pack_is_inst "libwebp-dev" "apt-get" "\"libwebp-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libwebp-dev fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_common_packs f_pack_is_inst "libpng-devel" "zypper" "\"libpng-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libpng-devel fi f_pack_is_inst "libjpeg-devel" "zypper" "\"libjpeg-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libjpeg-devel fi f_pack_is_inst "libtiff-devel" "zypper" "\"libtiff-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libtiff-devel fi if [[ "$DISTRO_NAME" != "SLES" ]] ; then f_pack_is_inst "libopenjp2-7" "zypper" "\"libopenjp2-7\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libopenjp2-7 fi fi f_pack_is_inst "libgif6" "zypper" "\"libgif6\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libgif6 fi f_pack_is_inst "libwebp-devel" "zypper" "\"libwebp-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libwebp-devel fi fi cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf leptonica-1.71.tar.gz mv ./leptonica-1.71 /usr/local/lib cd /usr/local/lib/leptonica-1.71 ./autobuild ./configure make -j 4 && make install cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf tesseract-ocr-3.02.02.tar.gz mv ./tesseract-ocr /usr/local/lib cd /usr/local/lib/tesseract-ocr ./autogen.sh ./configure make -j 4 && make install ldconfig cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf tesseract-ocr-3.01.eng.tar.gz tar -zxvf tesseract-ocr-3.02.por.tar.gz mv ./tesseract-ocr /usr/local/lib/tesseract-ocr cp /usr/local/lib/tesseract-ocr/tesseract-ocr/tessdata/eng.traineddata /usr/local/share/tessdata export TESSDATA_PREFIX=/usr/local/lib/tesseract-ocr/tesseract-ocr fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python2.X do LBC - LBConverter! f_inst_lbc_py_packs() { : 'Instala as dependências do LBI - LBIndex! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi cd "$SCRIPTDIR_V" bash py-packs-LBConverter.bash "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" "$PYTHON_2_X" "$VE_2_X" EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- HTTP_PORT_F=6544 # > ----------------------------------------- # Instalar e configurar o LBC - LBConverter! EZ_I_SKIP_ON_V=$FAST_INST f_open_main_section f_div_section f_yes_no "Install the LBC - LBConverter?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then # NOTE: As funções abaixo provêm recursos necessários ao # LBC - LBConverter! By Questor f_create_base_dir f_inst_ve_py2X 1 f_create_ve2X 1 f_inst_catdoc_unzip_imagemagick 1 f_inst_tesseract 1 f_inst_lbc_py_packs 1 f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter" "d" "\"LBConverter\" already installed in \"$BASE_INST_DIR_V/$VE_2_X/src\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then cd "$SCRIPTDIR_V" tar -zxvf LBConverter.tar.gz mv "$SCRIPTDIR_V/LBConverter" "$BASE_INST_DIR_V/$VE_2_X/src/" cd "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter" eval "$BASE_INST_DIR_V/$VE_2_X/bin/python$PYTHON_2_X setup.py install" \cp "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-dist" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-prov" if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_ez_sed "" "# chkconfig: 2345 99 01\n# description: Esquema de inicialização do LBConverter\n# processname: lbconverter" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-prov" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_ez_sed "" "### BEGIN INIT INFO\n# Provides: lbconverter\n# Required-Start: \$remote_fs \$syslog\n# Required-Stop: \$remote_fs \$syslog\n# Default-Start: 2 3 4 5\n# Default-Stop: 0 1 6\n# Short-Description: Start daemon at boot time\n# Description: Enable service provided by daemon.\n### END INIT INFO" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-prov" fi f_ez_sed "" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconvertermg" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-prov" rm -rf "/etc/init.d/lbconverter" mv "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconverter-prov" "/etc/init.d/lbconverter" cd /etc/init.d/ if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then # TODO: A linha logo abaixo é realmente necessária? Rever p/ os outros instaladores tb! By Questor chmod 755 lbconverter chkconfig --add lbconverter &>/dev/null chkconfig --level 345 lbconverter on elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then update-rc.d -f lbconverter remove &>/dev/null chmod +x ./lbconverter update-rc.d lbconverter defaults fi \cp "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconvertermg-dist" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconvertermg" f_ez_sed "" "$BASE_INST_DIR_V/$VE_2_X" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/lbconvertermg" LBG_URL_F="http://127.0.0.1:8008/lbg" QUESTION_F="Enter the LBG - LBGenerator URL. Use empty for \"$LBG_URL_F\" (LOCALHOST)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then LBG_URL_F=$GET_USR_INPUT_R fi QUESTION_F="Enter the port number for http service. Use empty for \"$HTTP_PORT_F\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then HTTP_PORT_F=$GET_USR_INPUT_R fi \cp "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/production.ini-dist" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/production.ini" f_ez_sed "" "$HTTP_PORT_F" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/production.ini" f_ez_sed "" "$LBG_URL_F" "$BASE_INST_DIR_V/$VE_2_X/src/LBConverter/production.ini" f_svc_helper "lbconverter" "restart" fi f_fire_hlp "lbconverter" $HTTP_PORT_F fi f_close_main_section # < ----------------------------------------- # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # FINAL! # -------------------------------------- EZ_I_SKIP_ON_V=0 read -d '' TITLE_F <<"EOF" Installer finished! Thanks! EOF LBC_SVC_SYNTAX="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then LBC_SVC_SYNTAX="systemctl start lbconverter.service systemctl stop lbconverter.service" else LBC_SVC_SYNTAX="service lbconverter start service lbconverter stop" fi USEFUL_INFO_F="To configure... vi $BASE_INST_DIR_V/$VE_2_X/src/LBConverter/production.ini python$PYTHON_2_X virtual environment path... $BASE_INST_DIR_V/$VE_2_X To start/stop... $LBC_SVC_SYNTAX Log... less /var/log/lbconverter.log" f_end "$TITLE_F" "$USEFUL_INFO_F" TITLE_F="" USEFUL_INFO_F="" # < --------------------------------------------------------------------------