#!/bin/bash if [ ! -f ${INSTALL_PATH}/uninstaller/install_err.log ]; then echo "" > ${INSTALL_PATH}/uninstaller/install.log fi if [ ! -f ${INSTALL_PATH}/uninstaller/install_err.log ]; then echo "" > ${INSTALL_PATH}/uninstaller/install_err.log fi echo "Unpacking Appserver ..." cd ${INSTALL_PATH}/protheus/bin/appserver_linux mkdir ${INSTALL_PATH}/protheus/bin/appserver #tar xzf ${INSTALL_PATH}/protheus/bin/build_linux_i686_7781_release.tar.gz >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log tar xzf appsrvlinux.tar.gz -C ${INSTALL_PATH}/protheus/bin/appserver_linux >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log # Renomeia o .ini mv ${INSTALL_PATH}/protheus/bin/appserver_linux/appserver_lnx.ini ${INSTALL_PATH}/protheus/bin/appserver/appserver.ini >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log mv ${INSTALL_PATH}/protheus/bin/appserver_linux/* ${INSTALL_PATH}/protheus/bin/appserver/ >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log rm -rf ${INSTALL_PATH}/protheus/bin/appserver_linux/ >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log rm -rf ${INSTALL_PATH}/protheus/bin/appserver/*.tar.gz >> ${INSTALL_PATH}/uninstaller/install.log 2>> ${INSTALL_PATH}/uninstaller/install_err.log #Instalacao do servico # Detecta a distro de forma robusta if [ -f /etc/os-release ]; then . /etc/os-release RAW_ID=$ID # exemplo: ubuntu, debian, rhel, centos, fedora, opensuse-leap else RAW_ID=$(uname -s | tr '[:upper:]' '[:lower:]') fi # Normaliza os nomes para simplificar o case case "$RAW_ID" in ubuntu|debian) VERSION="debian" ;; rhel|redhat|centos|oraclelinux|fedora|ol) VERSION="redhat" ;; suse|sles|opensuse*|sle*) VERSION="suse" ;; *) VERSION="$RAW_ID" ;; esac # Detecta arquitetura case $(uname -m) in x86_64) ARCH=64 ;; i*86) ARCH=32 ;; aarch64) ARCH=arm64 ;; armv7*|armv6*) ARCH=arm32 ;; *) ARCH=$(uname -m) ;; esac echo "Distribuição normalizada: $VERSION" echo "Arquitetura detectada: $ARCH" echo "$VERSION - Registrando Appserver como serviço ..." SERVICE_NAME="appserver" INIT_SCRIPT="/etc/init.d/$SERVICE_NAME" SYSTEMD_UNIT="/etc/systemd/system/$SERVICE_NAME.service" # Copia o script adequado conforme a distro detectada case $VERSION in "RedHatEnterpriseServer"|"redhat"|"CentOS"|"Fedora"|"OracleLinux"|"Red"|"Oracle") cp ${INSTALL_PATH}/appserver_rh.sh $INIT_SCRIPT ;; "suse"|"openSUSE"|"SUSE LINUX"|"SLES") cp ${INSTALL_PATH}/appserver_suse.sh $INIT_SCRIPT ;; "Ubuntu"|"Debian") cp ${INSTALL_PATH}/appserver_ubt.sh $INIT_SCRIPT ;; *) echo "Distribuição não reconhecida, usando script genérico..." cp ${INSTALL_PATH}/appserver_rh.sh $INIT_SCRIPT ;; esac chmod 755 $INIT_SCRIPT # Detecta se o sistema usa systemd if pidof systemd >/dev/null; then echo "Systemd detectado - criando unit file..." cat > $SYSTEMD_UNIT </dev/null; then update-rc.d $SERVICE_NAME defaults 85 elif command -v chkconfig >/dev/null; then chkconfig --add $SERVICE_NAME elif command -v insserv >/dev/null; then insserv $SERVICE_NAME fi service $SERVICE_NAME start fi exit 0