Skip to content

Instantly share code, notes, and snippets.

@rafaelcitario
Last active November 13, 2024 23:36
Show Gist options
  • Save rafaelcitario/9d3afe2fd3c84901cc0af051ffd5821d to your computer and use it in GitHub Desktop.
Save rafaelcitario/9d3afe2fd3c84901cc0af051ffd5821d to your computer and use it in GitHub Desktop.
Install Docker, Node, PHP, Composer, Git, Github CLI
#!/bin/bash
cat<<"Github-And-Linkedin"
# /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$$$$$ /$$ /$$ /$$
# /$$$__ $$$ | $$__ $$ /$$__ $$ | $$ /$$__ $$|__/ | $$ |__/
# /$$_/ \_ $$ | $$ \ $$ /$$$$$$ | $$ \__//$$$$$$ /$$$$$$ | $$| $$ \__/ /$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$$$$$
# /$$/ /$$$$$ $$| $$$$$$$/ |____ $$| $$$$ |____ $$ /$$__ $$| $$| $$ | $$|_ $$_/ |____ $$ /$$__ $$| $$ /$$__ $$
# | $$ /$$ $$| $$| $$__ $$ /$$$$$$$| $$_/ /$$$$$$$| $$$$$$$$| $$| $$ | $$ | $$ /$$$$$$$| $$ \__/| $$| $$ \ $$
# | $$| $$\ $$| $$| $$ \ $$ /$$__ $$| $$ /$$__ $$| $$_____/| $$| $$ $$| $$ | $$ /$$ /$$__ $$| $$ | $$| $$ | $$
# | $$| $$$$$$$$/| $$ | $$| $$$$$$$| $$ | $$$$$$$| $$$$$$$| $$| $$$$$$/| $$ | $$$$/| $$$$$$$| $$ | $$| $$$$$$/
# | $$\________/ |__/ |__/ \_______/|__/ \_______/ \_______/|__/ \______/ |__/ \___/ \_______/|__/ |__/ \______/
# \ $$$ /$$$
# \_ $$$$$$_/
# \______/
Github-And-Linkedin
#
#
#
#
echo "FAZENDO LIMPEZA ANTES DE INSTALAR"
# ------------------------
# Desinstalar Docker Engine
# ------------------------
echo "Removendo Docker Engine..."
sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo rm -rf /etc/apt/keyrings/docker.asc /etc/apt/sources.list.d/docker.list
# ------------------------
# Desinstalar Git
# ------------------------
echo "Removendo Git..."
sudo apt-get purge -y git
# ------------------------
# Desinstalar PHP
# ------------------------
echo "Removendo PHP..."
sudo apt-get purge -y php-common libapache2-mod-php php-cli php-mysql php-curl
# ------------------------
# Desinstalar Composer
# ------------------------
echo "Removendo Composer..."
sudo rm -f /usr/local/bin/composer
# ------------------------
# Desinstalar GitHub CLI
# ------------------------
echo "Removendo GitHub CLI..."
sudo apt-get purge -y gh
sudo rm -f /etc/apt/sources.list.d/github-cli.list
# ------------------------
# Limpeza adicional
# ------------------------
# Limpar pacotes órfãos (se houver)
echo "Removendo dependências órfãs..."
sudo apt-get install -y deborphan
sudo deborphan | xargs sudo apt-get -y purge
# Limpar cache de pacotes baixados
echo "Limpando cache de pacotes..."
sudo apt-get clean
# Limpar logs antigos do sistema
read -p "Você deseja limpar os logs antigos do sistema? (s/n): " CONFIRMAR_LOGS
if [[ "$CONFIRMAR_LOGS" == "s" || "$CONFIRMAR_LOGS" == "S" ]]; then
echo "Limpando logs antigos..."
sudo journalctl --vacuum-time=2weeks
sudo rm -rf /var/log/*.{gz,1}
fi
# Limpeza de volumes e containers Docker (se necessário)
echo "Limpando dados do Docker..."
sudo docker system prune -a --volumes -f
# Limpar arquivos temporários
echo "Limpando arquivos temporários..."
sudo rm -rf /tmp/*
# Finalizar desinstalação
echo "Desinstalação concluída! Todas as ferramentas foram removidas com sucesso."
# ------------------------
# INICIANDO INSTALAÇÃO
# ------------------------
# Atualizar pacotes e instalar dependências essenciais
echo "Atualizando pacotes e instalando dependências..."
sudo apt-get update -y
sudo apt-get install -y ca-certificates sudo lsb-release gnupg curl wget
# Verificar se wget está instalado
if ! command -v wget &> /dev/null; then
echo "wget não encontrado, instalando..."
sudo apt install -y wget
fi
cat<<"Instalando"
# ██╗ ██╗ ███╗ ██╗ ██████╗ ██████╗ ███████╗ ██╗███████╗ ██╗ ██╗
# ████████╗ ████╗ ██║██╔═══██╗██╔══██╗██╔════╝ ██║██╔════╝ ████████╗
# ╚██╔═██╔╝ ██╔██╗ ██║██║ ██║██║ ██║█████╗ ██║███████╗ ╚██╔═██╔╝
# ████████╗ ██║╚██╗██║██║ ██║██║ ██║██╔══╝ ██ ██║╚════██║ ████████╗
# ╚██╔═██╔╝ ██║ ╚████║╚██████╔╝██████╔╝███████╗██╗╚█████╔╝███████║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚════╝ ╚══════╝ ╚═╝ ╚═╝
#
Instalando
# instala a fnm (Fast Node Manager, ou Gestor Rápido de Node)
curl -fsSL https://fnm.vercel.app/install | bash
# ativar a fnm
source ~/.bashrc
# decarregar e instalar a Node.js
fnm use --install-if-missing 22
# verifica se a versão correta da Node.js está no ambiente
node -v # deve imprimir `v22.11.0`
# verifica se a versão correta da npm está no ambiente
npm -v # deve imprimir `10.9.0`
cat<<"Instalando"
# ██╗ ██╗ ██████╗ ██╗ ██╗██████╗ ██╗ ██╗
# ████████╗ ██╔══██╗██║ ██║██╔══██╗ ████████╗
# ╚██╔═██╔╝ ██████╔╝███████║██████╔╝ ╚██╔═██╔╝
# ████████╗ ██╔═══╝ ██╔══██║██╔═══╝ ████████╗
# ╚██╔═██╔╝ ██║ ██║ ██║██║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
#
Instalando
echo "Instalando o PHP e suas extensões..."
sudo apt-get install -y php-common libapache2-mod-php php-cli php-mysql php-curl
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start
cat<<"Instalando"
# ██╗ ██╗ ██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███████╗███████╗██████╗ ██╗ ██╗
# ████████╗ ██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗██╔════╝██╔════╝██╔══██╗ ████████╗
# ╚██╔═██╔╝ ██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║███████╗█████╗ ██████╔╝ ╚██╔═██╔╝
# ████████╗ ██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║╚════██║██╔══╝ ██╔══██╗ ████████╗
# ╚██╔═██╔╝ ╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝███████║███████╗██║ ██║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝
#
Instalando
echo "Instalando o Composer..."
# Baixar o instalador do Composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
# Mover o Composer para /usr/local/bin para torná-lo acessível globalmente
echo "Movendo o Composer para /usr/local/bin..."
sudo mv composer.phar /usr/local/bin/composer
cat<<"Instalando"
# ██╗ ██╗ ██████╗ ██╗████████╗ ██╗ ██╗
# ████████╗ ██╔════╝ ██║╚══██╔══╝ ████████╗
# ╚██╔═██╔╝ ██║ ███╗██║ ██║ ╚██╔═██╔╝
# ████████╗ ██║ ██║██║ ██║ ████████╗
# ╚██╔═██╔╝ ╚██████╔╝██║ ██║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
#
Instalando
echo "Instalando Git..."
sudo apt install git
echo "Git instalado!"
sudo apt autoremove
cat<<"Instalando"
# ██╗ ██╗ ██████╗ ██╗████████╗██╗ ██╗██╗ ██╗██████╗ ██████╗██╗ ██╗ ██╗ ██╗
# ████████╗ ██╔════╝ ██║╚══██╔══╝██║ ██║██║ ██║██╔══██╗ ██╔════╝██║ ██║ ████████╗
# ╚██╔═██╔╝ ██║ ███╗██║ ██║ ███████║██║ ██║██████╔╝ ██║ ██║ ██║ ╚██╔═██╔╝
# ████████╗ ██║ ██║██║ ██║ ██╔══██║██║ ██║██╔══██╗ ██║ ██║ ██║ ████████╗
# ╚██╔═██╔╝ ╚██████╔╝██║ ██║ ██║ ██║╚██████╔╝██████╔╝ ╚██████╗███████╗██║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═╝
#
Instalando
echo "Instalando o GitHub CLI..."
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
cat<<"Instalando"
# ██╗ ██╗ ██████╗ ██████╗ ██████╗██╗ ██╗███████╗██████╗ ██╗ ██╗
# ████████╗ ██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗ ████████╗
# ╚██╔═██╔╝ ██║ ██║██║ ██║██║ █████╔╝ █████╗ ██████╔╝ ╚██╔═██╔╝
# ████████╗ ██║ ██║██║ ██║██║ ██╔═██╗ ██╔══╝ ██╔══██╗ ████████╗
# ╚██╔═██╔╝ ██████╔╝╚██████╔╝╚██████╗██║ ██╗███████╗██║ ██║ ╚██╔═██╔╝
# ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝
#
Instalando
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo usermod -aG docker $USER
grep docker /etc/group
sudo usermod -aG docker $USER
newgrp docker
sudo service docker status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment