Last active
March 24, 2024 22:56
-
-
Save rederlo/4e20238f3223d7527d048d45539043b1 to your computer and use it in GitHub Desktop.
setup wsl2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
install_dependencies() { | |
echo "Instalando dependências necessárias..." | |
sudo apt update | |
sudo apt install -y software-properties-common network-manager libnss3-tools jq xsel redis-server mysql-server | |
sudo add-apt-repository --yes ppa:ondrej/php | |
sudo apt update | |
sudo apt install -y php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip php8.3-sqlite3 php8.3-pgsql php8.3-pdo php8.3-zip | |
} | |
install_composer() { | |
echo "Instalando Composer..." | |
# Certifica-se de que /usr/local/bin tem as permissões corretas | |
sudo chown -R $(whoami) /usr/local/bin | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
} | |
install_valet_takeout() { | |
install_composer | |
composer global require cpriego/valet-linux tightenco/takeout | |
# Certifica-se de que o caminho do composer esteja no PATH | |
if ! grep -qF "\$HOME/.config/composer/vendor/bin" ~/.bashrc; then | |
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc | |
export PATH="$PATH:$HOME/.config/composer/vendor/bin" | |
fi | |
valet install | |
mkdir -p ~/code | |
cd ~/code | |
valet park | |
} | |
install_mailpit() { | |
bash < <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh) | |
echo "Criando serviço systemd para o Mailpit..." | |
# Cria o arquivo de serviço systemd | |
sudo bash -c 'cat << EOF > /etc/systemd/system/mailpit.service | |
[Unit] | |
Description=Mailpit Fake SMTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
ExecStart=/usr/local/bin/mailpit | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target | |
EOF' | |
# Recarrega o systemd, habilita e inicia o serviço Mailpit | |
sudo systemctl daemon-reload | |
sudo systemctl enable mailpit.service | |
sudo systemctl start mailpit.service | |
echo "Serviço Mailpit habilitado e iniciado." | |
} | |
install_nvm() { | |
echo "Instalando NVM e Node.js LTS..." | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash | |
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
nvm install --lts | |
update_bashrc | |
} | |
update_bashrc() { | |
source ~/.bashrc | |
} | |
main() { | |
install_dependencies | |
install_valet_takeout | |
install_nvm | |
install_mailpit | |
update_bashrc | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment