Skip to content

Instantly share code, notes, and snippets.

@carlosanders
Created April 2, 2019 01:01
Show Gist options
  • Save carlosanders/66232ad6c69d97b80657b3ff1e502d3a to your computer and use it in GitHub Desktop.
Save carlosanders/66232ad6c69d97b80657b3ff1e502d3a to your computer and use it in GitHub Desktop.
Script para configurações: ajuste de data, git, tools...
#!/bin/bash
# Script Autor: Carlos Anders
#########################################################################
############################## var global ###############################
ver_so=`cat /etc/oracle-release`
USUARIO=$USER
### cores ###
c_red_b_white="\033[01;47;31m"
c_amarelo="\033[01;33m"
c_azul="\033[00;36m"
c_fechamento="\033[00m"
#########################################################################
# Rotina principal
main() {
echo -e "${c_red_b_white}>>>>>>>> Servidor: ${ver_so} <<<<<<<<${c_fechamento}"
repos_modo_root_go
install_tools_go
disable_securit_go
install_git_source_go
adjust_date_go
echo -e "${c_red_b_white}----- Provisionamento Concluído ----- ${c_fechamento}"
}
adjust_date_go(){
echo -e "${c_amarelo} >>>>>>>> Ajustando o Relógio do Servidor... <<<<<<<< ${c_fechamento}"
#https://www.linuxnaweb.com/definindo-data-e-hora-no-centos-6-7/
#https://www.vivaolinux.com.br/artigo/Servidor-NTP-Configuracao-e-ajuste-de-data-e-hora
# Definindo timezone
sudo timedatectl set-timezone 'America/Sao_Paulo'
# Definindo timezone no CentOS 6
sudo ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
#instalando o NTP Cliente
sudo yum install ntpdate -y
# Ajustando a hora com o ntp cliente, utilizei o a.ntp.br que é o # NTP brasileiro que é mantido pelo registrobr
sudo ntpdate a.ntp.br
#Iniciar o serviço do ntp e habilitar no SO – CentOS 7
sudo systemctl enable ntpdate
sudo chkconfig ntpdate on && sudo service ntpdate start
#ajusta a data da bios com a data do servidor
sudo hwclock -w
timedatectl
date
echo -e "${c_azul} ----- Concluído ----- ${c_fechamento}"
}
repos_modo_root_go(){
echo -e "${c_amarelo} >>>>>>>> Verificando modo root... <<<<<<<< ${c_fechamento}"
if [ "$EUID" -ne 0 ]
then echo "ERRO: Para configurar os repositórios execute este script como root"
exit
fi
if [ -f /etc/yum.repos.d/public-yum-ol7.repo ]
then
cp /etc/yum.repos.d/public-yum-ol7.repo /root/public-yum-ol7-old.repo
rm /etc/yum.repos.d/public-yum-ol7.repo
curl http://public-yum.oracle.com/public-yum-ol7.repo > /etc/yum.repos.d/public-yum-ol7.repo
else
curl http://public-yum.oracle.com/public-yum-ol7.repo > /etc/yum.repos.d/public-yum-ol7.repo
fi
#habilitando repos
yum-config-manager --enable ol7_addons
yum-config-manager --enable ol7_UEKR4
yum-config-manager --enable ol7_MySQL57
yum-config-manager --enable ol7_optional_latest
#desabilitado, pois as vz apr problemas
#yum-config-manager --enable ol7_developer_EPEL
#yum-config-manager --save --setopt=ol7_developer_EPEL.skip_if_unavailable=true
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
echo -e "${c_azul} ----- Concluído ----- ${c_fechamento}"
}
install_git_source_go() {
echo -e "${c_amarelo} >>>>>>>> Verificando modo root... <<<<<<<< ${c_fechamento}"
GIT_VERSION=2.21.0
GIT_HOME=/var/opt/git
mkdir -p ${GIT_HOME}
sudo yum -y remove git
sudo yum groupinstall "Development Tools"
sudo yum -y install gettext-devel openssl-devel perl-CPAN \
perl-devel zlib-devel perl-ExtUtils-MakeMaker
wget -nv https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz -O ${GIT_HOME}/git.tar.gz -O - | sudo tar -zvxf - --strip=1 -C ${GIT_HOME}
(cd ${GIT_HOME} && sudo make configure)
(cd ${GIT_HOME} && sudo ./configure --prefix=/usr/local)
(cd ${GIT_HOME} && sudo make install)
file="/etc/bashrc"
export PATH=$PATH:/usr/local/git/bin
sudo echo "export PATH=$PATH:/usr/local/git/bin" >> ${file}
source ${file}
git --version
echo -e "${c_azul} ----- Concluído ----- ${c_fechamento}"
}
#sub-rotina para configurações diversas no SO
disable_securit_go() {
echo -e "${c_amarelo} Configurando o Servidor ${c_fechamento}"
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo echo '${USUARIO} ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
sudo setenforce 0
#sudo sed -i "s/SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config
sudo sed -i "s/SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
echo -e "${c_azul} ----- Concluído ----- ${c_fechamento}"
}
#sub-rotina
install_tools_go() {
echo -e "${c_amarelo} Instalando pacotes úteis ${c_fechamento}"
sudo yum groups mark install "Development Tools"
sudo yum -y groupinstall "Development Tools"
sudo yum -y install gcc curl curl-devel gcc-c++ autoconf automake \
binutils make gettext-devel openssl-devel zlib-devel glibc \
glibc-devel libgcc expat-devel
#git git-core
echo -e "${c_azul} ----- Concluído ----- ${c_fechamento}"
}
###############################
main
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment