From f7b4baaf0abfb2fd24edab0f323ffaf5670e55d8 Mon Sep 17 00:00:00 2001 From: Mateus Alves <135336248+mathewalves@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:27:18 -0300 Subject: [PATCH] 1.0.1 This version introduces interactive menus using whiptail, translation support for both pt-BR and English, and the option to choose whether to add a custom welcome screen. Additionally, code documentation has been enhanced for improved clarity. --- README.md | 163 ++++++++-------- changelog | 44 +++++ configs/colors.conf | 14 +- configs/language.conf | 1 + scripts/configure_bridge.sh | 286 ++++++++++++++++++---------- scripts/custom_welcome.sh | 69 +++++-- scripts/install_proxmox-1.sh | 360 ++++++++++++++++++++++++----------- scripts/install_proxmox-2.sh | 151 +++++++++------ scripts/welcome.sh | 100 ++++++++++ setup | 343 ++++++++++++++++++++++++--------- 10 files changed, 1075 insertions(+), 456 deletions(-) create mode 100644 changelog create mode 100644 configs/language.conf mode change 100644 => 100755 scripts/custom_welcome.sh create mode 100644 scripts/welcome.sh diff --git a/README.md b/README.md index ce84595..a1fa91e 100644 --- a/README.md +++ b/README.md @@ -1,176 +1,177 @@ -[![Version](https://img.shields.io/badge/Version-1.0.0-red.svg)](version) [![License](https://img.shields.io/badge/License-BSD--Clause_3-green.svg)](LICENSE) [![Readme em Português e Inglês](https://img.shields.io/badge/README-pt--br%2Fen-blue)](#) +[![Version](https://img.shields.io/badge/Version-1.0.1-red.svg)](version) [![License](https://img.shields.io/badge/License-BSD--Clause_3-green.svg)](LICENSE) [![Readme em Português e Inglês](https://img.shields.io/badge/README-en%2Fpt--br-blue)](#) ```bash - _ - _ __ _ __ _____ ___ __ ___ _____ __ ___ ___| |_ _ _ _ __ - | '_ \| '__/ _ \ \/ / '_ ` _ \ / _ \ \/ / / __|/ _ \ __| | | | '_ \ - | |_) | | | (_) > <| | | | | | (_) > < \__ \ __/ |_| |_| | |_) | - | .__/|_| \___/_/\_\_| |_| |_|\___/_/\_\___|___/\___|\__|\__,_| .__/ - |_| |_____| |_| v1.0.0 + _ + _ __ _ __ _____ ___ __ ___ _____ __ ___ ___| |_ _ _ _ __ + | '_ \| '__/ _ \ \/ / '_ ` _ \ / _ \ \/ / / __|/ _ \ __| | | | '_ \ + | |_) | | | (_) > <| | | | | | (_) > < \__ \ __/ |_| |_| | |_) | + | .__/|_| \___/_/\_\_| |_| |_|\___/_/\_\___|___/\___|\__|\__,_| .__/ + |_| |_____| |_| v1.0.1 ``` -###### 🇧🇷 PT-BR: +[![Language](https://img.shields.io/badge/🌎-English:-blue)](#) -# Instalador do Proxmox VE no Debian 12 Bookworm +# Proxmox VE Installer on Debian 12 Bookworm -Este setup/script automatiza a instalação do Proxmox sobre o Debian 12 e a criação da bridge para facilitar a configuração de redes. +This setup/script automates the installation of Proxmox on Debian 12 and the creation of a bridge to facilitate network configuration. -**Nota: Este script foi projetado para ser executado em um sistema Debian 12. Certifique-se de ter permissões de superusuário antes de executar o script.** +**Note: This script is designed to run on a Debian 12 system. Make sure to have superuser permissions before executing the script.** -## Requisitos +## Requirements -- Debian 12 Bookworm instalado -- Permissões de superusuário +- Installed Debian 12 Bookworm +- Superuser permissions ```bash su root ``` -- Git instalado +- Installed Git ```bash apt install git ``` -- (Importante) Clonar o repositório apartir do diretório: +- (Important) Clone the repository from the directory: ```bash cd / ``` -## Instruções de Uso +## Usage Instructions -1. Clone o repositório para o seu sistema Debian 12. +1. Clone the repository to your Debian 12 system. ```bash -# Com o git já instalado na sua máquina clone o repositório +# With git already installed on your machine, clone the repository git clone https://github.com/mathewalves/Proxmox-Debian12.git -# Acesse a pasta baixada com o comando 'cd' +# Access the downloaded folder with the 'cd' command cd /Proxmox-Debian12 ``` -2. Torne o script executável. +2. Make the script executable. ```bash -# Dá permissão de execução para o setup +# Give execution permission to the setup chmod +x ./setup ``` -3. Execute o setup. +3. Run the setup. ```bash ./setup ``` -## Pacotes Adicionais - -O script instala alguns pacotes adicionais para melhorar a experiência e fornecer funcionalidades adicionais. Os pacotes incluem: +## Additional Packages -1. **'sudo':** Ferramenta essencial para conceder permissões administrativas ao usuário selecionado. -2. **'nala':** Uma aplicação que melhora a interface gráfica do 'apt'. -3. **'neofetch':** Uma ferramenta de exibição de informações do sistema com uma interface colorida e amigável. -4. **'net-tools':** Conjunto de utilitários clássicos de rede, como ifconfig e route. -5. **'nmap':** Uma poderosa ferramenta de exploração de rede e auditoria de segurança. +The script installs some additional packages to enhance the experience and provide additional functionalities. The packages include: -Certifique-se de revisar a documentação oficial de cada pacote para obter mais detalhes sobre suas funcionalidades. +1. **'sudo':** Essential tool to grant administrative permissions to the selected user. +2. **'nala':** An application that enhances the graphical interface of 'apt'. +3. **'neofetch':** A system information display tool with a colorful and user-friendly interface. +4. **'net-tools':** A classic set of network utilities, such as ifconfig and route. +5. **'nmap':** A powerful network scanning and security auditing tool. -## Funcionalidades +Make sure to review the official documentation for each package for more details on their functionalities. -1. **Instalação do Proxmox:** O script instala automaticamente o Proxmox sobre a base do Debian 12. +## Features -2. **Pacotes Adicionais:** Esses pacotes adicionais são instalados para melhorar a experiência do usuário e fornecer ferramentas úteis para o sistema e para o ambiente Proxmox. +1. **Proxmox Installation:** The script automatically installs Proxmox on the Debian 12 base. -3. **Criação de Bridge:** Facilita a configuração de redes criando uma bridge chamada `vmbr0`. Você pode optar por configurar manualmente ou usar DHCP. +2. **Additional Packages:** These additional packages are installed to enhance the user experience and provide useful tools for the system and Proxmox environment. -## Atualizações e Suporte +3. **Bridge Creation:** Facilitates network configuration by creating a bridge named vmbr0. You can choose to configure manually or use DHCP. -Para obter suporte ou relatar problemas, [abra uma issue](https://github.com/mathewalves/Proxmox-Debian12/issues). +## Updates and Support -## Licença +For support or to report issues, [ open an issue](https://github.com/mathewalves/Proxmox-Debian12/issues). -Este script é distribuído sob a licença [BSD 3-Clause](https://opensource.org/licenses/BSD-3-Clause). +## License +This script is distributed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause). -## Agradecimentos +## Acknowledgments -Se você identificar oportunidades de melhoria ou quiser contribuir, sinta-se à vontade para criar um pull request. Estamos abertos a colaborações para aprimorar esta ferramenta. +Thank you for using the Proxmox Installation Script on Debian 12 +If you come across any improvements or would like to contribute, feel free to create a pull request. Your contributions are welcome to enhance this script. -Agradecemos por fazer parte da comunidade e por contribuir para o desenvolvimento contínuo deste script. +We appreciate your participation in the community and your contribution to the ongoing development of this script. -**Divirta-se com o Proxmox!** 🚀 +**Enjoy Proxmox!** 🚀 --- -###### 🌎 EN: +[![Language](https://img.shields.io/badge/🇧🇷-PT--BR:-green)](#) -# Proxmox VE Installer on Debian 12 Bookworm -This setup/script automates the installation of Proxmox on Debian 12 and the creation of a bridge to facilitate network configuration. +# Instalador do Proxmox VE no Debian 12 Bookworm -**Note: This script is designed to run on a Debian 12 system. Make sure to have superuser permissions before executing the script.** +Este setup/script automatiza a instalação do Proxmox sobre o Debian 12 e a criação da bridge para facilitar a configuração de redes. -## Requirements +**Nota: Este script foi projetado para ser executado em um sistema Debian 12. Certifique-se de ter permissões de superusuário antes de executar o script.** -- Installed Debian 12 Bookworm -- Superuser permissions +## Requisitos + +- Debian 12 Bookworm instalado +- Permissões de superusuário ```bash su root ``` -- Installed Git +- Git instalado ```bash apt install git ``` -- (Important) Clone the repository from the directory: +- (Importante) Clonar o repositório apartir do diretório: ```bash cd / ``` -## Usage Instructions +## Instruções de Uso -1. Clone the repository to your Debian 12 system. +1. Clone o repositório para o seu sistema Debian 12. ```bash -# With git already installed on your machine, clone the repository +# Com o git já instalado na sua máquina clone o repositório git clone https://github.com/mathewalves/Proxmox-Debian12.git -# Access the downloaded folder with the 'cd' command +# Acesse a pasta baixada com o comando 'cd' cd /Proxmox-Debian12 ``` -2. Make the script executable. +2. Torne o script executável. ```bash -# Give execution permission to the setup +# Dá permissão de execução para o setup chmod +x ./setup ``` -3. Run the setup. +3. Execute o setup. ```bash ./setup ``` -## Additional Packages +## Pacotes Adicionais -The script installs some additional packages to enhance the experience and provide additional functionalities. The packages include: +O script instala alguns pacotes adicionais para melhorar a experiência e fornecer funcionalidades adicionais. Os pacotes incluem: -1. **'sudo':** Essential tool to grant administrative permissions to the selected user. -2. **'nala':** An application that enhances the graphical interface of 'apt'. -3. **'neofetch':** A system information display tool with a colorful and user-friendly interface. -4. **'net-tools':** A classic set of network utilities, such as ifconfig and route. -5. **'nmap':** A powerful network scanning and security auditing tool. +1. **'sudo':** Ferramenta essencial para conceder permissões administrativas ao usuário selecionado. +2. **'nala':** Uma aplicação que melhora a interface gráfica do 'apt'. +3. **'neofetch':** Uma ferramenta de exibição de informações do sistema com uma interface colorida e amigável. +4. **'net-tools':** Conjunto de utilitários clássicos de rede, como ifconfig e route. +5. **'nmap':** Uma poderosa ferramenta de exploração de rede e auditoria de segurança. -Make sure to review the official documentation for each package for more details on their functionalities. +Certifique-se de revisar a documentação oficial de cada pacote para obter mais detalhes sobre suas funcionalidades. -## Features +## Funcionalidades -1. **Proxmox Installation:** The script automatically installs Proxmox on the Debian 12 base. +1. **Instalação do Proxmox:** O script instala automaticamente o Proxmox sobre a base do Debian 12. -2. **Additional Packages:** These additional packages are installed to enhance the user experience and provide useful tools for the system and Proxmox environment. +2. **Pacotes Adicionais:** Esses pacotes adicionais são instalados para melhorar a experiência do usuário e fornecer ferramentas úteis para o sistema e para o ambiente Proxmox. -3. **Bridge Creation:** Facilitates network configuration by creating a bridge named vmbr0. You can choose to configure manually or use DHCP. +3. **Criação de Bridge:** Facilita a configuração de redes criando uma bridge chamada `vmbr0`. Você pode optar por configurar manualmente ou usar DHCP. -## Updates and Support +## Atualizações e Suporte -For support or to report issues, [ open an issue](https://github.com/mathewalves/Proxmox-Debian12/issues). +Para obter suporte ou relatar problemas, [abra uma issue](https://github.com/mathewalves/Proxmox-Debian12/issues). -## License -This script is distributed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause). +## Licença -## Acknowledgments +Este script é distribuído sob a licença [BSD 3-Clause](https://opensource.org/licenses/BSD-3-Clause). -Thank you for using the Proxmox Installation Script on Debian 12 -If you come across any improvements or would like to contribute, feel free to create a pull request. Your contributions are welcome to enhance this script. +## Agradecimentos -We appreciate your participation in the community and your contribution to the ongoing development of this script. +Se você identificar oportunidades de melhoria ou quiser contribuir, sinta-se à vontade para criar um pull request. Estamos abertos a colaborações para aprimorar esta ferramenta. -**Enjoy Proxmox!** 🚀 +Agradecemos por fazer parte da comunidade e por contribuir para o desenvolvimento contínuo deste script. + +**Divirta-se com o Proxmox!** 🚀 \ No newline at end of file diff --git a/changelog b/changelog new file mode 100644 index 0000000..fd0e8b4 --- /dev/null +++ b/changelog @@ -0,0 +1,44 @@ +[current version] --> 1.0.1 +Version 1.0.1 of the Proxmox Installation Setup on Debian 12 +Summary: +This version introduces interactive menus using whiptail, translation support for both pt-BR and English, and the option to choose whether to add a custom welcome screen. Additionally, code documentation has been enhanced for improved clarity. + +Changes: + +1. Interactive Menus with Whiptail: + - Utilized whiptail for interactive menus, enhancing user experience and simplifying navigation. + +2. Translation Support: + - Added language support for both pt-BR and English, allowing users to choose their preferred language during the installation. + +3. Custom Welcome Screen Option: + - Included an option to choose whether to add a custom welcome screen during installation, providing flexibility based on user preferences. + +4. Code Documentation: + - Improved code documentation for better readability and understanding of the installation scripts. + +5. Bug Fixes and Code Enhancements: + - Implemented various bug fixes and code improvements to enhance overall reliability and performance. + +These updates aim to make the Proxmox installation setup more user-friendly, versatile, and well-documented, ensuring a smoother installation process for users with different language preferences and levels of expertise. + +[...] + +Version 1.0.0 of the Proxmox Installation Setup on Debian 12 +Summary: +This version marks the initial release of the Proxmox installation setup on Debian 12, providing an efficient and automated way to configure a robust virtualization environment. + +Description: +Version 1.0.0 of the Proxmox installation setup on Debian 12 offers a practical solution for implementing Proxmox Virtual Environment (VE) on top of the stable Debian 12 base. This set of automated scripts aims to simplify the process of installing, configuring, and customizing Proxmox, allowing users to quickly establish a high-performance virtualized environment. + +Key Features: + +Automated Installation: The script automates the installation of Proxmox VE on the Debian 12 base, reducing the time and complexity of the process. + +Simplified Network Configuration: Facilitates network configuration, including the creation and customization of the vmbr0 network interface to facilitate communication between virtual machines and the external network. + +Customized Welcome Message: An informative and personalized welcome message is displayed to the user after installation, providing useful information, including details for accessing the Proxmox interface. + +Version Management: Prepares the environment for future updates and adjustments, facilitating the ongoing management of Proxmox VE on Debian 12. + +This release signifies a continued commitment to improving and expanding the toolset to simplify the Proxmox installation experience, making it accessible to users with different levels of expertise. \ No newline at end of file diff --git a/configs/colors.conf b/configs/colors.conf index 037f539..7fc765a 100644 --- a/configs/colors.conf +++ b/configs/colors.conf @@ -1,10 +1,10 @@ -# Proxmox Setup v1.0.0 +# Proxmox Setup v1.0.1 # by: Matheew Alves # colors.conf -ciano='\e[1;96m' -azul='\e[;94m' -normal='\e[0m' -vermelho='\e[1;91m' -amarelo='\e[1;93m' -verde='\e[1;32m' \ No newline at end of file +cyan='\e[1;96m' +blue='\e[;94m' +default='\e[0m' +red='\e[1;91m' +yellow='\e[1;93m' +green='\e[1;32m' \ No newline at end of file diff --git a/configs/language.conf b/configs/language.conf new file mode 100644 index 0000000..613db39 --- /dev/null +++ b/configs/language.conf @@ -0,0 +1 @@ +LANGUAGE=en diff --git a/scripts/configure_bridge.sh b/scripts/configure_bridge.sh index c73dc5e..b2a0ebe 100755 --- a/scripts/configure_bridge.sh +++ b/scripts/configure_bridge.sh @@ -1,50 +1,162 @@ #!/bin/bash -# Proxmox Setup v1.0.0 +# Proxmox Setup v1.0.1 # by: Matheew Alves -# Carregar as variáveis de cores do arquivo colors.conf cd /Proxmox-Debian12 -source ./configs/colors.conf -# Tornando-se root -if [ "$(whoami)" != "root" ]; then - echo -e "${ciano}Tornando-se superusuário...${normal}" - sudo -E bash "$0" "$@" # Executa o script como root - exit $? -fi +# Load configs files // Carregar os arquivos de configuração +source ./configs/colors.conf +source ./configs/language.conf -# Caminho para o arquivo de configuração -config_file="configs/network.conf" +# Becoming superuser // Tornando-se superusuário +super_user() +{ + if [ "$(whoami)" != "root" ]; then + if [ "$LANGUAGE" == "en" ]; then + echo -e "${ciano}Log in as superuser...${default}" + else + echo -e "${ciano}Faça o login como superusuário...${default}" + fi + sudo -E bash "$0" "$@" + exit $? + fi +} configure_bridge() { + config_file="configs/network.conf" + + # Check if the configuration file exists + if [ ! -f "$config_file" ]; then + whiptail --title "Network Configuration" --msgbox "The configuration file $config_file does not exist. Run the script install_proxmox-1.sh first or configure manually." 15 60 + fi + + # Read configurations from the file + source "$config_file" + + # Display network information + whiptail --title "Network Configuration" --msgbox "Interface Information:\n\nPhysical Interface: $INTERFACE\nIP Address: $IP_ADDRESS\nGateway: $GATEWAY" 15 60 + + # Use the variables read from the file or prompt for new ones if blank + while true; do + choice=$(whiptail --title "Network Configuration" --menu "Select an option:" 15 60 6 \ + "1" "Configure Manually" \ + "2" "Use DHCP" \ + "3" "Exit" 3>&1 1>&2 2>&3) + + case $choice in + "1") + # Manual configuration + physical_interface=$(whiptail --inputbox "Enter the name of the physical interface (leave blank to keep $INTERFACE):" 10 60 "$INTERFACE" --title "Manual Configuration" 3>&1 1>&2 2>&3) + ip_address=$(whiptail --inputbox "Enter the IP address for the bridge (leave blank to keep $IP_ADDRESS):" 10 60 "$IP_ADDRESS" --title "Manual Configuration" 3>&1 1>&2 2>&3) + gateway=$(whiptail --inputbox "Enter the gateway for the bridge (leave blank to keep $GATEWAY):" 10 60 "$GATEWAY" --title "Manual Configuration" 3>&1 1>&2 2>&3) + + # Use the variables read or the new ones entered + INTERFACE=${physical_interface:-$INTERFACE} + IP_ADDRESS=${ip_address:-$IP_ADDRESS} + + # Validate if the gateway is a valid IP address + if [[ -n "$gateway" && ! "$gateway" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + whiptail --title "Network Configuration" --msgbox "Invalid gateway. Exiting..." 10 60 + exit 1 + fi + + GATEWAY=${gateway:-$GATEWAY} + + # Update the configuration file + echo "INTERFACE=$INTERFACE" > "$config_file" + echo "IP_ADDRESS=$IP_ADDRESS" >> "$config_file" + echo "GATEWAY=$GATEWAY" >> "$config_file" + + # Comment out the physical interface configurations in the configuration file + sed -i "/iface $INTERFACE inet static/,/iface/ s/^/#/" /etc/network/interfaces + sed -i "/iface $INTERFACE inet dhcp/,/iface/ s/^/#/" /etc/network/interfaces + + # Create the vmbr0 bridge with the new information + cat <> /etc/network/interfaces +# Proxmox Bridge +auto vmbr0 +iface vmbr0 inet static + address $IP_ADDRESS + gateway $GATEWAY + bridge_ports $INTERFACE + bridge_stp off + bridge_fd 0 +EOF + + whiptail --title "Network Configuration" --msgbox "The vmbr0 bridge was created successfully!" 10 60 + break + ;; + + "2") + # DHCP configuration + + # Comment out the physical interface configurations in the configuration file + sed -i "/iface $INTERFACE inet static/,/iface/ s/^/#/" /etc/network/interfaces + sed -i "/iface $INTERFACE inet dhcp/,/iface/ s/^/#/" /etc/network/interfaces + + # Create the vmbr0 bridge with DHCP + cat <> /etc/network/interfaces +# Proxmox Bridge +auto vmbr0 +iface vmbr0 inet dhcp + bridge_ports $INTERFACE + bridge_stp off + bridge_fd 0 +EOF + + whiptail --title "Network Configuration" --msgbox "The vmbr0 bridge was configured with DHCP." 10 60 + break + ;; + + "3") + whiptail --title "Network Configuration" --msgbox "You can configure the vmbr0 bridge later by running the script /Proxmox-Debian12/scripts/configure_bridge.sh, manually, or through the Proxmox web interface. Refer to the Proxmox documentation for more information." 15 60 + exit 0 + ;; + + *) + whiptail --title "Network Configuration" --msgbox "Invalid option" 10 60 + ;; + esac + done + + # Restart the network service to apply the changes + whiptail --title "Network Configuration" --msgbox "Restarting the network service to apply the changes..." 10 60 + systemctl restart networking + ip link set dev vmbr0 up + + whiptail --title "Network Configuration" --msgbox "The vmbr0 bridge was created successfully!" 10 60 +} + +configurar_bridge() +{ + config_file="configs/network.conf" + # Verificar se o arquivo de configuração existe if [ ! -f "$config_file" ]; then - echo -e "${amarelo}O arquivo de configuração ${ciano}$config_file${amarelo} não existe. Execute o script ${ciano}install_proxmox-1.sh${amarelo} primeiro ou configure manualmente.${normal}" + whiptail --title "Configuração de Rede" --msgbox "O arquivo de configuração $config_file não existe. Execute o script install_proxmox-1.sh primeiro ou configure manualmente." 15 60 fi # Ler as configurações do arquivo source "$config_file" # Exibindo informações de rede - echo -e "${ciano}Exibindo interface de network.conf:${normal}" - echo -e "${azul}Interface Física:${normal} $INTERFACE" - echo -e "${azul}Endereço IP:${normal} $IP_ADDRESS" - echo -e "${azul}Gateway:${normal} $GATEWAY ${normal}" + whiptail --title "Configuração de Rede" --msgbox "Informações da Interface:\n\nInterface Física: $INTERFACE\nEndereço IP: $IP_ADDRESS\nGateway: $GATEWAY" 15 60 # Utilizar as variáveis lidas do arquivo ou solicitar novas se estiverem em branco - echo -e "${azul}Revisando configurações e as informações de interface de rede para criação da bridge...${normal}" - PS3="Selecione uma opção (Digite o número): " - options=("Configurar Manualmente" "Usar DHCP" "Sair") - - select opt in "${options[@]}"; do - case $opt in - "Configurar Manualmente") + while true; do + choice=$(whiptail --title "Configuração de Rede" --menu "Selecione uma opção:" 15 60 6 \ + "1" "Configurar Manualmente" \ + "2" "Usar DHCP" \ + "3" "Sair" 3>&1 1>&2 2>&3) + + case $choice in + "1") # Leitura manual das configurações - read -p "Informe o nome da interface física / netmask (deixe em branco para manter "$INTERFACE"): " interface_fisica - read -p "Informe o endereço IP para a bridge com net mask (deixe em branco para manter "$IP_ADDRESS"): " endereco_ip - read -p "Informe o gateway para a bridge (deixe em branco para manter "$GATEWAY"): " gateway + interface_fisica=$(whiptail --inputbox "Informe o nome da interface física (deixe em branco para manter $INTERFACE):" 10 60 "$INTERFACE" --title "Configuração Manual" 3>&1 1>&2 2>&3) + endereco_ip=$(whiptail --inputbox "Informe o endereço IP para a bridge (deixe em branco para manter $IP_ADDRESS):" 10 60 "$IP_ADDRESS" --title "Configuração Manual" 3>&1 1>&2 2>&3) + gateway=$(whiptail --inputbox "Informe o gateway para a bridge (deixe em branco para manter $GATEWAY):" 10 60 "$GATEWAY" --title "Configuração Manual" 3>&1 1>&2 2>&3) # Utilizar as variáveis lidas ou as novas informadas INTERFACE=${interface_fisica:-$INTERFACE} @@ -52,7 +164,7 @@ configure_bridge() # Validar se o gateway é um endereço IP válido if [[ -n "$gateway" && ! "$gateway" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo -e "${vermelho}Gateway inválido. Saindo...${normal}" + whiptail --title "Configuração de Rede" --msgbox "Gateway inválido. Saindo..." 10 60 exit 1 fi @@ -69,7 +181,6 @@ configure_bridge() # Criar a bridge vmbr0 com as novas informações cat <> /etc/network/interfaces - # Bridge Proxmox auto vmbr0 iface vmbr0 inet static @@ -80,19 +191,19 @@ iface vmbr0 inet static bridge_fd 0 EOF - break 2 + whiptail --title "Configuração de Rede" --msgbox "A bridge vmbr0 foi criada com sucesso!" 10 60 + break ;; - "Usar DHCP") + "2") # Configuração para DHCP # Comentar as configurações da interface física no arquivo de configuração sed -i "/iface $INTERFACE inet static/,/iface/ s/^/#/" /etc/network/interfaces sed -i "/iface $INTERFACE inet dhcp/,/iface/ s/^/#/" /etc/network/interfaces -# Criar a bridge vmbr0 com as novas informações -cat <> /etc/network/interfaces - + # Criar a bridge vmbr0 com as novas informações + cat <> /etc/network/interfaces # Bridge Proxmox auto vmbr0 iface vmbr0 inet dhcp @@ -101,100 +212,73 @@ iface vmbr0 inet dhcp bridge_fd 0 EOF - break 2 + whiptail --title "Configuração de Rede" --msgbox "A bridge vmbr0 foi configurada com DHCP." 10 60 + break ;; - "Sair") - remove_start-script - echo -e "${amarelo}Você pode configurar a bridge vmbr0 posteriormente executando o script ${ciano}/Proxmox-Debian12/scripts/configure_bridge.sh${amarelo}" - echo -e ", manualmente ou através da interface web do Proxmox. Consulte a documentação do Proxmox para mais informações.${normal}" - echo -e "${vermelho}Saindo...${normal}" + "3") + whiptail --title "Configuração de Rede" --msgbox "Você pode configurar a bridge vmbr0 posteriormente executando o script /Proxmox-Debian12/scripts/configure_bridge.sh, manualmente ou através da interface web do Proxmox. Consulte a documentação do Proxmox para mais informações." 15 60 exit 0 ;; - *) echo -e "${amarelo}Opção inválida${normal}";; + *) + whiptail --title "Configuração de Rede" --msgbox "Opção inválida" 10 60 + ;; esac done # Reiniciar o serviço de rede para aplicar as alterações - echo -e "${amarelo}Reiniciando o serviço de rede...${normal}" + whiptail --title "Configuração de Rede" --msgbox "Reiniciando o serviço de rede para aplicar as alterações..." 10 60 systemctl restart networking ip link set dev vmbr0 up - echo -e "${verde}A bridge vmbr0 foi criada com sucesso!${normal}" + whiptail --title "Configuração de Rede" --msgbox "A bridge vmbr0 foi criada com sucesso!" 10 60 } -# Remover inicialização do script junto com o sistema -remove_start-script() +remove_start_script() { + # Remove script initialization along with the system // Remover inicialização do script junto com o sistema for user_home in /home/*; do PROFILE_FILE="$user_home/.bashrc" - - # Remover a linha do script do arquivo de perfil - sed -i '/# Executar script após o login/,/# Fim do script 2/d' "$PROFILE_FILE" - echo -e "${azul}Removida a configuração do perfil para o usuário:${ciano} $(basename "$user_home").${normal}" - - # Remover as linhas adicionadas ao /root/.bashrc - sed -i '/# Executar script após o login/,/\/Proxmox-Debian12\/scripts\/configure_bridge.sh/d' /root/.bashrc - echo -e "${azul}Removida a configuração automática do script no /root/.bashrc.${normal}" - done -} - -add_welcome() -{ - for user_home in /home/*; do - PROFILE_FILE="$user_home/.bashrc" - - # Verifica se o arquivo de perfil existe antes de adicionar - if [ -f "$PROFILE_FILE" ]; then - # Adiciona a linha de execução do script ao final do arquivo - echo "" >> "$PROFILE_FILE" - echo "# Executar script após o login" >> "$PROFILE_FILE" - echo "/Proxmox-Debian12/scripts/custom_welcome.sh" >> "$PROFILE_FILE" - echo "" >> "$PROFILE_FILE" - - echo "Configuração automática concluída para o usuário: $(basename "$user_home")." - fi - - # Adicione as seguintes linhas ao final do arquivo /root/.bashrc - echo "" >> /root/.bashrc - echo "# Executar script após o login" >> /root/.bashrc - echo "/Proxmox-Debian12/scripts/custom_welcome.sh" >> /root/.bashrc - echo "" >> /root/.bashrc - echo "Configuração automática concluída para o usuário root." + # Remove the script line from the profile file + sed -i '/# Run script after login/,/# End of script 2/d' "$PROFILE_FILE" + echo -e "${blue}Removed configuration from the profile for user:${cyan} $(basename "$user_home").${normal}" done + + # Remove the lines added to /root/.bashrc + sed -i '/# Run script after login/,/\/Proxmox-Debian12\/scripts\/configure_bridge.sh/d' /root/.bashrc + echo -e "${blue}Removed automatic script configuration from /root/.bashrc.${normal}" } main() { - echo -e "${ciano}3º parte: Atualizando /etc/hosts..." - echo -e "Passo 1/3" - echo -e "...${normal}" - configure_bridge - remove_start-script - add_welcome - echo -e "${amarelo}(Opcional)${ciano}Deseja reiniciar o computador agora? [S/N]${normal}" - read -p "Resposta: " perguntar_reboot - - perguntar_reboot=$(echo "$perguntar_reboot" | tr '[:upper:]' '[:lower:]') - - if [ "$perguntar_reboot" == "s" ]; then - echo -e "${verde}Instalação e configuração de rede do Proxmox concluída com sucesso!${normal}" - echo -e "${amarelo}Lembre-se de configurar o Proxmox conforme necessário.${normal}" - echo -e "${amarelo}Reiniciando o Sistema...${normal}" - sleep 5 - systemctl reboot + super_user + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}3rd part: Configuring bridge" + echo -e "...${default}" + configure_bridge + else + echo -e "${cyan}3ª parte: Configurando a ponte (bridge)" + echo -e "...${default}" + configurar_bridge fi - echo -e "${verde}Instalação e configuração de rede do Proxmox concluída com sucesso!${normal}" - echo -e "${amarelo}Lembre-se de configurar o Proxmox conforme necessário!${normal}" - echo -e "${amarelo}Você pode configurar a bridge vmbr0 posteriormente executando o script ${ciano}/Proxmox-Debian12/scripts/configure_bridge.sh${amarelo}" - echo -e ", manualmente ou através da interface web do Proxmox. Consulte a documentação do Proxmox para mais informações.${normal}" - sleep 5 - clear + remove_start_script + + if [ "$LANGUAGE" == "en" ]; then + ask_reboot + clear + whiptail --title "Installation Completed" --msgbox "Proxmox installation and network configuration completed successfully!\nRemember to configure Proxmox as needed." 15 60 + whiptail --title "Network Configuration" --msgbox "You can configure the vmbr0 bridge later by running the script /Proxmox-Debian12/scripts/configure_bridge.sh or through the Proxmox web interface. Refer to the Proxmox documentation for more information." 15 60 + else + clear + whiptail --title "Instalação Concluída" --msgbox "Instalação e configuração de rede do Proxmox concluídas com sucesso!\nLembre-se de configurar o Proxmox conforme necessário." 15 60 + whiptail --title "Configuração de Rede" --msgbox "Você pode configurar a bridge vmbr0 posteriormente executando o script /Proxmox-Debian12/scripts/configure_bridge.sh, ou através da interface web do Proxmox. Consulte a documentação do Proxmox para mais informações." 15 60 + fi - ./scripts/custom_welcome + cd /Proxmox-Debian12 + ./scripts/welcome.sh } main diff --git a/scripts/custom_welcome.sh b/scripts/custom_welcome.sh old mode 100644 new mode 100755 index dbd4c5f..8758776 --- a/scripts/custom_welcome.sh +++ b/scripts/custom_welcome.sh @@ -1,26 +1,66 @@ #!/bin/bash -# Proxmox Setup v1.0.0 +# Proxmox Setup v1.0.1 # by: Matheew Alves cd /Proxmox-Debian12 + +# Load configs files // Carregar os arquivos de configuração source ./configs/colors.conf +source ./configs/language.conf welcome() { - current_user=$(whoami) - echo -e "${ciano} ${verde}Bem-vindo, $current_user!" + # Welcome message and ASCII art block + echo -e "${cyan} ${green}Welcome, $current_user!" - # Bloco ASCII art - echo -e "${vermelho} + # ASCII art block +echo -e "${red} ____ _________ _ ______ ___ ____ _ __ / __ \/ ___/ __ \| |/_/ __ \`__ \/ __ \| |/_/ / /_/ / / / /_/ /> < - / .___/_/ \____/_/|_/_/ /_/ /_/\____/_/|_| ${amarelo}https://pve.proxmox.com/${vermelho} + / .___/_/ \____/_/|_/_/ /_/ /_/\____/_/|_| ${yellow}https://pve.proxmox.com/${red} /_/ ${normal}" + # Check if neofetch is installed and display system information + if command -v neofetch &> /dev/null; then + echo "" + neofetch + fi + + # Get the IP address + ip=$(hostname -I | cut -d' ' -f1) + + # Default Proxmox port number + proxmox_port=8006 + + # Welcome message with access information +echo -e "${yellow} + +---------------------------------------------------------------------+ + | To access the ${red}Proxmox${yellow} interface, open a browser and type: | + ### ${blue}https://$ip:$proxmox_port/${yellow} ### + | User: ${green}root${yellow} | Password: ${green}(root password)${yellow} | + +---------------------------------------------------------------------+ + +${default}" +} + +bem_vindo() +{ + echo -e "${cyan} ${green}Bem-vindo, $current_user!" + + # Bloco ASCII art + echo -e "${red} + ____ _________ _ ______ ___ ____ _ __ + / __ \/ ___/ __ \| |/_/ __ \`__ \/ __ \| |/_/ + / /_/ / / / /_/ /> < + / .___/_/ \____/_/|_/_/ /_/ /_/\____/_/|_| ${yellow}https://pve.proxmox.com/${red} + /_/ + + ${default}" + if command -v neofetch &> /dev/null; then echo "" neofetch @@ -33,20 +73,25 @@ welcome() porta_proxmox=8006 # Mensagem de boas-vindas - echo -e "${amarelo} + echo -e "${yellow} +---------------------------------------------------------------------+ - | Para acessar a interface do ${vermelho}Proxmox${amarelo}, abra um navegador e digite: | - ### ${azul}https://$ip:$porta_proxmox/${amarelo} ### - | Usuário: ${verde}root${amarelo} | Senha: ${verde}(a senha do root)${amarelo} | + | Para acessar a interface do ${red}Proxmox${yellow}, abra um navegador e digite: | + ### ${blue}https://$ip:$porta_proxmox/${yellow} ### + | Usuário: ${green}root${yellow} | Senha: ${green}(a senha do root)${yellow} | +---------------------------------------------------------------------+ -${normal}" +${default}" } main() { + current_user=$(whoami) clear - welcome + if [ "$LANGUAGE" == "en" ]; then + welcome + else + bem_vindo + fi cd ~ } diff --git a/scripts/install_proxmox-1.sh b/scripts/install_proxmox-1.sh index edcc8b2..e76df2b 100755 --- a/scripts/install_proxmox-1.sh +++ b/scripts/install_proxmox-1.sh @@ -1,50 +1,155 @@ #!/bin/bash -# Proxmox Setup v1.0.0 +# Proxmox Setup v1.0.1 # by: Matheew Alves cd /Proxmox-Debian12 -# Carregar as variáveis de cores do arquivo colors.conf +# Load configs files // Carregar os arquivos de configuração source ./configs/colors.conf +source ./configs/language.conf -install_proxmox-1() +install_proxmox-1() { - echo -e "${ciano}Setup Proxmox 1º parte." - echo -e "Passo 1/3: Atualizando /etc/hosts" - echo -e "...${normal}" + echo -e "${cyan}Setting up Proxmox - 1st part." + echo -e "Step 1/3: Updating /etc/hosts" + echo -e "...${default}" + + # Get the current hostname + current_hostname=$(hostname) + + echo -e "${blue}Current Hostname: ${cyan}" + hostname + echo -e "${default}" + + # Display network interfaces using Whiptail + config_dir="./configs" + config_file="$config_dir/network.conf" + + if [ ! -d "$config_dir" ]; then + mkdir -p "$config_dir" + fi + echo -e "${cyan}Select your network interface: [Enter the number]${normal}" + + # Function to display interface information + display_interface_info() + { + interface="$1" + ip_address="$2" + gateway="$3" + + echo -e "${blue}Interface Information ${default}$interface" + echo -e "${blue}IP Address: ${default}$ip_address" + echo -e "${blue}Gateway: ${default}$gateway" + } + + # Associative array to store interface information + declare -A interfaces + + # Populate the associative array with interface information + while read -r interface ip_address _; do + if [ -n "$interface" ]; then + interfaces["$interface"]="$ip_address" + fi + done < <(ip addr show | awk '/inet / {split($2, a, "/"); print $NF, a[1]}') + + # Main loop + while true; do + # Display options to the user + PS3="Select an option (Enter the number): " + options=() + for interface_option in "${!interfaces[@]}"; do + options+=("$interface_option" "") + done + + selected_interface=$(whiptail --title "Network Interface Selection" --menu "Select a network interface:" 15 60 6 "${options[@]}" 3>&1 1>&2 2>&3) + + if [ $? -eq 0 ]; then + read -r ip_address <<< "$(echo "${interfaces[$selected_interface]}" | awk '{print $1}')" + gateway="$(ip route show dev "$selected_interface" | awk '/via/ {print $3}')" + subnet_mask="$(ip addr show dev "$selected_interface" | awk '/inet / {split($2, a, "/"); print a[2]}')" + subnet_mask="${subnet_mask:-24}" + ip_address_with_mask="$ip_address/$subnet_mask" + + display_interface_info "$selected_interface" "$ip_address" "$gateway" + + # Display selected interface information + whiptail --title "Interface Information" --msgbox "Selected Interface: $selected_interface\nIP Address: $ip_address_with_mask\nGateway: $gateway" 10 60 + + # Ask the user to confirm the selection + whiptail --yesno "Do you want to select this interface?" 8 40 + case $? in + 0) + clear + echo "INTERFACE=$selected_interface" > "$config_file" + echo "IP_ADDRESS=$ip_address_with_mask" >> "$config_file" + echo "GATEWAY=$gateway" >> "$config_file" + + echo -e "${green}Settings saved to the file ${cyan}$config_file.${default}" + break 2 + ;; + 1) + ;; + *) + echo -e "${yellow}Invalid choice. Please select again.${default}" + ;; + esac + else + echo -e "${yellow}Please select a valid option.${default}" + fi + done + + echo -e "${blue}Adding or updating an entry in /etc/hosts for your IP address...${default}" + + if grep -qE "$ip_address\s+$current_hostname\.proxmox\.com\s+$current_hostname" /etc/hosts; then + sed -i -E "s/($ip_address\s+$current_hostname\.proxmox\.com\s+$current_hostname).*/$ip_address $current_hostname.proxmox.com $current_hostname/" /etc/hosts + echo -e "${blue}Entry for ${cyan}'$current_hostname'${blue} has been updated in the ${cyan}/etc/hosts${blue} file.${default}" + else + echo "$ip_address $current_hostname.proxmox.com $current_hostname" | tee -a /etc/hosts > /dev/null + echo -e "${green}Entry successfully added to the ${cyan}/etc/hosts${green} file:${normal}" + cat /etc/hosts | grep "$current_hostname" + fi + + echo -e "${cyan}...${default}" +} + +instalar_proxmox-1() +{ + echo -e "${cyan}Configurando o Proxmox - 1ª parte." + echo -e "Passo 1/3: Atualizando /etc/hosts" + echo -e "...${default}" # Obtendo o nome do host atual current_hostname=$(hostname) - echo -e "${azul}nome do Host atual: ${ciano}" + echo -e "${blue}Nome do Host Atual: ${cyan}" hostname - echo -e "${normal}" - - # Exibindo interfaces de rede - # Caminho para o diretório de configuração + echo -e "${default}" + + # Exibindo interfaces de rede usando o Whiptail config_dir="./configs" config_file="$config_dir/network.conf" - # Verificar se o diretório existe ou criar se não existir if [ ! -d "$config_dir" ]; then mkdir -p "$config_dir" fi - echo -e "${ciano}Selecione a sua interface de rede: [Digite o número]${normal}" - # Função para exibir informações da interface - exibir_informacoes_interface() { + echo -e "${cyan}Selecione a sua interface de rede: [Digite o número]${normal}" + + # Função para exibir informações da interface + display_interface_info() + { interface="$1" ip_address="$2" gateway="$3" - echo -e "${azul}Informações da interface ${ciano}$interface" - echo -e "${azul}Endereço IP: ${normal}$ip_address" - echo -e "${azul}Gateway: ${normal}$gateway" + echo -e "${blue}Informações da Interface ${default}$interface" + echo -e "${blue}Endereço IP: ${default}$ip_address" + echo -e "${blue}Gateway: ${default}$gateway" } - # Criar um array associativo para armazenar as informações + # Array associativo para armazenar informações da interface declare -A interfaces # Preencher o array associativo com informações das interfaces @@ -58,157 +163,190 @@ install_proxmox-1() while true; do # Exibir opções para o usuário PS3="Selecione uma opção (Digite o número): " - select interface_option in "${!interfaces[@]}"; do - if [ -n "$interface_option" ]; then - # Exibir informações completas da interface - read -r ip_address <<< "$(echo "${interfaces[$interface_option]}" | awk '{print $1}')" - gateway="$(ip route show dev "$interface_option" | awk '/via/ {print $3}')" - - # Obter a máscara de sub-rede (por padrão, /24 se não especificado) - mascara_subrede="$(ip addr show dev "$interface_option" | awk '/inet / {split($2, a, "/"); print a[2]}')" - mascara_subrede="${mascara_subrede:-24}" - - # Adicionar a máscara de sub-rede ao endereço IP - ip_address_with_mask="$ip_address/$mascara_subrede" - - exibir_informacoes_interface "$interface_option" "$ip_address" "$gateway" - - # Perguntar ao usuário se deseja selecionar essa interface - read -p "Deseja selecionar essa interface? [S/N]: " escolha - case "$escolha" in - [sS]) - # Guardar as informações no arquivo network.conf - echo "INTERFACE=$interface_option" > "$config_file" - echo "IP_ADDRESS=$ip_address_with_mask" >> "$config_file" - echo "GATEWAY=$gateway" >> "$config_file" - - echo -e "${verde}Configurações salvas no arquivo ${ciano}$config_file.${normal}" - break 2 # Sair do loop principal - ;; - [nN]) - # Continuar com o restante do loop - ;; - *) - echo -e "${amarelo}Escolha inválida. Por favor, selecione novamente.${normal}" - ;; - esac - else - echo -e "${amarelo}Por favor, selecione uma opção válida.${normal}" - fi + options=() + for interface_option in "${!interfaces[@]}"; do + options+=("$interface_option" "") done + + selected_interface=$(whiptail --title "Seleção de Interface de Rede" --menu "Selecione uma interface de rede:" 15 60 6 "${options[@]}" 3>&1 1>&2 2>&3) + + if [ $? -eq 0 ]; then + read -r ip_address <<< "$(echo "${interfaces[$selected_interface]}" | awk '{print $1}')" + gateway="$(ip route show dev "$selected_interface" | awk '/via/ {print $3}')" + mascara_subrede="$(ip addr show dev "$selected_interface" | awk '/inet / {split($2, a, "/"); print a[2]}')" + mascara_subrede="${mascara_subrede:-24}" + ip_address_with_mask="$ip_address/$mascara_subrede" + + display_interface_info "$selected_interface" "$ip_address" "$gateway" + + # Exibir informações da interface selecionada + whiptail --title "Informações da Interface" --msgbox "Interface Selecionada: $selected_interface\nEndereço IP: $ip_address_with_mask\nGateway: $gateway" 10 60 + + # Perguntar ao usuário se deseja confirmar a seleção + whiptail --yesno "Deseja selecionar esta interface?" 8 40 + case $? in + 0) + clear + echo "INTERFACE=$selected_interface" > "$config_file" + echo "IP_ADDRESS=$ip_address_with_mask" >> "$config_file" + echo "GATEWAY=$gateway" >> "$config_file" + + echo -e "${green}Configurações salvas no arquivo ${cyan}$config_file.${default}" + break 2 + ;; + 1) + ;; + *) + echo -e "${yellow}Escolha inválida. Por favor, selecione novamente.${default}" + ;; + esac + else + echo -e "${yellow}Por favor, selecione uma opção válida.${default}" + fi done - echo -e "${azul}Adicionando ou atualizando uma entrada em /etc/hosts para seu endereço IP...${normal}" - # Verificar se o arquivo /etc/hosts já contém uma entrada para o nome do host + echo -e "${blue}Adicionando ou atualizando uma entrada em /etc/hosts para o seu endereço IP...${default}" + if grep -qE "$ip_address\s+$current_hostname\.proxmox\.com\s+$current_hostname" /etc/hosts; then - # A entrada já existe, atualize-a sed -i -E "s/($ip_address\s+$current_hostname\.proxmox\.com\s+$current_hostname).*/$ip_address $current_hostname.proxmox.com $current_hostname/" /etc/hosts - echo -e "${azul}A entrada para ${ciano}'$current_hostname'${azul} foi atualizada no arquivo ${ciano}/etc/hosts.${normal}" + echo -e "${blue}Entrada para ${cyan}'$current_hostname'${blue} foi atualizada no arquivo ${cyan}/etc/hosts.${default}" else - # A entrada não existe, adicione-a echo "$ip_address $current_hostname.proxmox.com $current_hostname" | tee -a /etc/hosts > /dev/null - echo -e "${verde}Entrada adicionada com sucesso ao arquivo ${ciano}/etc/hosts:${normal}" + echo -e "${green}Entrada adicionada com sucesso ao arquivo ${cyan}/etc/hosts:${normal}" cat /etc/hosts | grep "$current_hostname" fi - echo -e "${ciano}...${normal}" + echo -e "${cyan}...${default}" } install_proxmox-2() { - echo -e "${ciano}Setup Proxmox 1º parte." - echo -e "Passo 2/3: Adicionando o repositório do Proxmox VE" - echo -e "...${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}Setting up Proxmox - 1st part." + echo -e "Step 2/3: Adding Proxmox VE Repository" + echo -e "...${default}" + else + echo -e "${cyan}Configurando o Proxmox - 1ª parte." + echo -e "Passo 2/3: Adicionando o Repositório do Proxmox VE" + echo -e "...${default}" + fi echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg - echo -e "${amarelo}Verificando Key...${normal}" + echo -e "${yellow}Checking Key...${default}" - # Calcula o hash da chave - chave_hash=$(sha512sum /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg | cut -d ' ' -f1) + # Calculate the hash of the key + key_hash=$(sha512sum /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg | cut -d ' ' -f1) - # Verifica se a chave está vazia - if [ -z "$chave_hash" ]; then - echo -e "${vermelho}Erro: A chave não corresponde à esperada ou está vazia. A instalação do Proxmox pode ser comprometida.${normal}" - exit 1 + # Check if the key is empty + if [ -z "$key_hash" ]; then + echo -e "${red}Error: The key does not match the expected one or is empty. Proxmox installation may be compromised.${default}" + exit 1 else - echo -e "${verde}Sucesso: A chave corresponde à esperada.${normal}" + echo -e "${green}Success: The key matches the expected one.${default}" fi apt-get update && apt-get -y full-upgrade - - echo -e "${ciano}...${normal}" - + echo -e "${cyan}...${default}" } install_proxmox-3() { - echo -e "${ciano}Setup Proxmox 1º parte." - echo -e "Passo 3/3: Baixando o Proxmox VE Kernel..." - echo -e "...${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}Setting up Proxmox - 1st part." + echo -e "Step 3/3: Downloading Proxmox VE Kernel..." + echo -e "...${default}" + else + echo -e "${cyan}Configurando o Proxmox - 1ª parte." + echo -e "Passo 3/3: Baixando o Kernel do Proxmox VE..." + echo -e "...${default}" + fi - if command -v nala &> /dev/null; then - # Executar com 'nala' se estiver instalado + if command -v nala &> /dev/null; then + # Run with 'nala' if installed nala install -y proxmox-default-kernel else - # Executar com 'apt' se 'nala' não estiver instalado - apt install -y proxmox-default-kernel + # Run with 'apt' if 'nala' is not installed + apt install -y proxmox-default-kernel fi - echo -e "${verde}Instalação da 1ºParte do ProxMox concluída com sucesso!${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${green}Installation of Proxmox 1st Part completed successfully!${default}" + else + echo -e "${green}Instalação da 1ª Parte do Proxmox concluída com sucesso!${default}" + fi } reboot_setup() { - echo -e "${amarelo}A 2º Parte da instalação será iniciada após o proximo reboot.${normal}" - - # Exibe mensagem de aviso sobre a reinicialização - echo -e "${amarelo}AVISO: O sistema precisará ser reiniciado. Salvando trabalho...${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${yellow}The 2nd Part of the installation will commence after the next reboot." + # Display warning message about reboot + echo -e "${red}WARNING: ${yellow}The system needs to be rebooted. Saving work...${normal}" + else + echo -e "${yellow}A 2ª parte da instalação será iniciada após o próximo reboot." + # Exibir mensagem de aviso sobre o reboot + echo -e "${red}ATENÇÃO: ${yellow}O sistema precisa ser reiniciado. Salvando o trabalho...${normal}" + fi + # Add script execution to user profiles for user_home in /home/*; do PROFILE_FILE="$user_home/.bashrc" - - # Verifica se o arquivo de perfil existe antes de adicionar + + # Check if the profile file exists before adding if [ -f "$PROFILE_FILE" ]; then - # Adiciona a linha de execução do script ao final do arquivo + # Add the script execution line at the end of the file echo "" >> "$PROFILE_FILE" - echo "# Executar script após o login" >> "$PROFILE_FILE" + echo "# Execute script after login" >> "$PROFILE_FILE" echo "/Proxmox-Debian12/scripts/install_proxmox-2.sh" >> "$PROFILE_FILE" echo "" >> "$PROFILE_FILE" - echo "Configuração automática concluída para o usuário: $(basename "$user_home")." + echo "Automatic configuration completed for user: $(basename "$user_home")." fi - - # Adicione as seguintes linhas ao final do arquivo /root/.bashrc - echo "" >> /root/.bashrc - echo "# Executar script após o login" >> /root/.bashrc - echo "/Proxmox-Debian12/scripts/install_proxmox-2.sh" >> /root/.bashrc - echo "" >> /root/.bashrc - - echo "Configuração automática concluída para o usuário root." done - # Habilita o serviço para iniciar na inicialização + # Add the following lines at the end of the /root/.bashrc file + echo "" >> /root/.bashrc + echo "# Execute script after login" >> /root/.bashrc + echo "/Proxmox-Debian12/scripts/install_proxmox-2.sh" >> /root/.bashrc + echo "" >> /root/.bashrc + + echo "Automatic configuration completed for the root user." - echo -e "${verde}Trabalho Salvo!${ciano}" - echo -e "${ciano}Reiniciado o sistema automaticamente para concluir a instalação...${normal}" - echo -e "${amarelo}Faça o login como usuário '${ciano}root${amarelo}' após o reboot!${normal}" + if [ "$LANGUAGE" == "en" ]; then + # Enable the service to start on boot + echo -e "${green}Work Saved!${cyan}" + echo -e "Rebooting the system automatically to complete the installation..." + echo -e "${yellow}Login as the '${cyan}root${yellow}' user after the reboot!${default}" + else + # Habilitar o serviço para iniciar com o sistema + echo -e "${green}Trabalho Salvo!${cyan}" + echo -e "Reiniciando o sistema automaticamente para concluir a instalação..." + echo -e "${yellow}Faça login como usuário '${cyan}root${yellow}' após o reboot!${default}" + fi - # Aguarda alguns segundos antes de reiniciar + # Wait for a few seconds before rebooting sleep 5 - # Reinicia o sistema + # Reboot the system systemctl reboot } main() { - # Instalação do Proxmox - echo -e "${ciano}iniciando instalação da 1ºParte do setup do Proxmox${normal}" - install_proxmox-1 + if [ "$LANGUAGE" == "en" ]; then + # Proxmox Installation + echo -e "${cyan}Initiating installation of the 1st Part of Proxmox setup${default}" + install_proxmox-1 + else + # Instalação do Proxmox + echo -e "${cyan}iniciando a instalação da 1ºParte do setup do Proxmox${default}" + instalar_proxmox-1 + fi + install_proxmox-2 install_proxmox-3 reboot_setup diff --git a/scripts/install_proxmox-2.sh b/scripts/install_proxmox-2.sh index c91f6b5..72cb5b9 100755 --- a/scripts/install_proxmox-2.sh +++ b/scripts/install_proxmox-2.sh @@ -1,87 +1,107 @@ #!/bin/bash -# Proxmox Setup v1.0.0 +# Proxmox Setup v1.0.1 # by: Matheew Alves -# Carregar as variáveis de cores do arquivo colors.conf cd /Proxmox-Debian12 + +# Load configs files // Carregar os arquivos de configuração source ./configs/colors.conf +source ./configs/language.conf -# Tornando-se root -if [ "$(whoami)" != "root" ]; then - echo -e "${ciano}Tornando-se superusuário...${normal}" - sudo -E bash "$0" "$@" # Executa o script como root - exit $? -fi +# Becoming superuser // Tornando-se superusuário +super_user() +{ + if [ "$(whoami)" != "root" ]; then + if [ "$LANGUAGE" == "en" ]; then + echo -e "${ciano}Log in as superuser...${default}" + else + echo -e "${ciano}Faça o login como superusuário...${default}" + fi + sudo -E bash "$0" "$@" + exit $? + fi +} -# Remover inicialização do script junto com o sistema -remove_start-script() +# Remove script initialization along with the system // Remover inicialização do script junto com o sistema +remove_start_script() { for user_home in /home/*; do PROFILE_FILE="$user_home/.bashrc" - # Remover a linha do script do arquivo de perfil - sed -i '/# Executar script após o login/,/# Fim do script 2/d' "$PROFILE_FILE" - echo -e "${azul}Removida a configuração do perfil para o usuário:${ciano} $(basename "$user_home").${normal}" + # Remove the script line from the profile file + sed -i '/# Execute script after login/,/# End of script 2/d' "$PROFILE_FILE" + echo -e "${blue}Removed profile configuration for user:${cyan} $(basename "$user_home").${normal}" - # Remover as linhas adicionadas ao /root/.bashrc - sed -i '/# Executar script após o login/,/\/Proxmox-Debian12\/scripts\/install_proxmox-2.sh/d' /root/.bashrc - echo -e "${azul}Removida a configuração automática do script no /root/.bashrc.${normal}" + # Remove the lines added to /root/.bashrc + sed -i '/# Execute script after login/,/\/Proxmox-Debian12\/scripts\/install_proxmox-2.sh/d' /root/.bashrc + echo -e "${blue}Removed automatic script configuration in /root/.bashrc.${normal}" done } -# Iniciar configuração da bridge após o reboot +# Start bridge configuration after reboot // Iniciar configuração da bridge após o reboot configure_bridge() { for user_home in /home/*; do PROFILE_FILE="$user_home/.bashrc" - - # Verifica se o arquivo de perfil existe antes de adicionar + + # Check if the profile file exists before adding if [ -f "$PROFILE_FILE" ]; then - # Adiciona a linha de execução do script ao final do arquivo - echo "" >> "$PROFILE_FILE" - echo "# Executar script após o login" >> "$PROFILE_FILE" + # Add the script execution line at the end of the file + echo -e "\n# Run script after login" >> "$PROFILE_FILE" echo "/Proxmox-Debian12/scripts/configure_bridge.sh" >> "$PROFILE_FILE" - echo "" >> "$PROFILE_FILE" - echo "Configuração automática concluída para o usuário: $(basename "$user_home")." + echo "Automatic configuration completed for user: $(basename "$user_home")." fi + done - # Adicione as seguintes linhas ao final do arquivo /root/.bashrc - echo "" >> /root/.bashrc - echo "# Executar script após o login" >> /root/.bashrc - echo "/Proxmox-Debian12/scripts/configure_bridge.sh" >> /root/.bashrc - echo "" >> /root/.bashrc + # Add the following lines at the end of the /root/.bashrc file + echo -e "\n# Run script after login" >> /root/.bashrc + echo "/Proxmox-Debian12/scripts/configure_bridge.sh" >> /root/.bashrc - echo "Configuração automática concluída para o usuário root." - done + echo "Automatic configuration completed for the root user." } + proxmox-ve_packages() { - echo -e "${ciano}Setup Proxmox 2º parte." - echo -e "${ciano}Passo 1/3: Proxmox VE packages" - echo -e "...${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}Setting up Proxmox 2nd part." + echo -e "Step 1/3: Proxmox VE packages" + echo -e "...${default}" + else + echo -e "${cyan}Configurando a 2ª parte do Proxmox." + echo -e "Passo 1/3: Pacotes do Proxmox VE" + echo -e "...${default}" + fi + if command -v nala &> /dev/null; then - # Executar com 'nala' se estiver instalado + # Execute with 'nala' if installed nala install -y proxmox-ve postfix open-iscsi chrony else - # Executar com 'apt' se 'nala' não estiver instalado + # Execute with 'apt' if 'nala' is not installed apt install -y proxmox-ve postfix open-iscsi chrony fi } -# Remover kernel do Debian +# Remove Debian kernel // Remover kernel do Debian remove_kernel() { - echo -e "${ciano}Setup Proxmox 2º parte." - echo -e "Passo 2/3: Removendo kernel antigo" - echo -e "...${normal}" + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}Setting up Proxmox 2nd part." + echo -e "Step 2/3: Removing old kernel" + echo -e "...${default}" + else + echo -e "${cyan}Configurando a 2ª parte do Proxmox." + echo -e "Passo 2/3: Removendo o kernel antigo" + echo -e "...${default}" + fi + if command -v nala &> /dev/null; then - # Executar com 'nala' se estiver instalado + # Execute with 'nala' if installed nala remove -y linux-image-amd64 'linux-image-6.1*' else - # Executar com 'apt' se 'nala' não estiver instalado + # Execute with 'apt' if 'nala' is not installed apt remove -y linux-image-amd64 'linux-image-6.1*' fi @@ -90,41 +110,54 @@ remove_kernel() remove_os-prober() { - echo -e "${ciano}Setup Proxmox 2º parte." - echo -e "${ciano}Passo 3/3: Removendo os-prober" - echo -e "...${normal}" - if command -v nala &> /dev/null; then - # Executar com 'nala' se estiver instalado + if [ "$LANGUAGE" == "en" ]; then + echo -e "${cyan}Setting up Proxmox 2nd part." + echo -e "Step 3/3: Removing os-prober" + echo -e "...${default}" + else + echo -e "${cyan}Configurando a 2ª parte do Proxmox." + echo -e "Passo 3/3: Removendo o os-prober" + echo -e "...${default}" + fi + + if command -v nala &> /dev/null; then + # Execute with 'nala' if installed nala remove -y os-prober else - # Executar com 'apt' se 'nala' não estiver instalado + # Execute with 'apt' if 'nala' is not installed apt remove -y os-prober - fi + fi } main() { + super_user proxmox-ve_packages remove_kernel remove_os-prober - # Verificar se o comando neofetch está instalado + # Check if the neofetch command is installed // Verificar se o comando neofetch está instalado if command -v neofetch &> /dev/null; then neofetch fi - remove_start-script - echo -e "${verde}2º Parte da instalação do ProxMox concluída com sucesso!${normal}" - configure_bridge + if [ "$LANGUAGE" == "en" ]; then + echo -e "${green}2º Part of ProxMox installation completed successfully!${default}" + else + echo -e "${green}2º Parte da instalação do ProxMox concluída com sucesso!${default}" + fi - echo -e "${ciano}Reiniciado o sistema automaticamente para concluir a instalação...${normal}" - echo -e "${amarelo}Faça o login como usuário '${ciano}root${amarelo}' após o reboot!${normal}" - + remove_start_script + configure_bridge - # Aguarda alguns segundos antes de reiniciar + if [ "$LANGUAGE" == "en" ]; then + echo -e "${red}WARNING: ${yellow}System automatically restarted to complete the installation..." + echo -e "Log in as the '${cyan}root${yellow}' user after the reboot!${default}" + else + echo -e "${red}AVISO: ${yellow}Reiniciado o sistema automaticamente para concluir a instalação..." + echo -e "Faça o login como usuário '${cyan}root${yellow}' após o reboot!${default}" + fi sleep 5 - - # Reinicia o sistema systemctl reboot } diff --git a/scripts/welcome.sh b/scripts/welcome.sh new file mode 100644 index 0000000..6d75c4a --- /dev/null +++ b/scripts/welcome.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# Proxmox Setup v1.0.1 +# by: Matheew Alves + +cd /Proxmox-Debian12 + +# Load configs files +source ./configs/colors.conf +source ./configs/language.conf + +# Becoming superuser // Tornando-se superusuário +super_user() +{ + if [ "$(whoami)" != "root" ]; then + if [ "$LANGUAGE" == "en" ]; then + echo -e "${ciano}Log in as superuser...${default}" + else + echo -e "${ciano}Faça o login como superusuário...${default}" + fi + sudo -E bash "$0" "$@" + exit $? + fi +} + +add_welcome() +{ + # Add script execution to user profiles + for user_home in /home/*; do + PROFILE_FILE="$user_home/.bashrc" + + # Check if the profile file exists before adding + if [ -f "$PROFILE_FILE" ]; then + # Add the script execution line to the end of the file + echo "" >> "$PROFILE_FILE" + echo "# Execute script after login" >> "$PROFILE_FILE" + echo "/Proxmox-Debian12/scripts/custom_welcome.sh" >> "$PROFILE_FILE" + echo "" >> "$PROFILE_FILE" + + echo "Automatic configuration completed for user: $(basename "$user_home")." + fi + + # Add the following lines to the end of the /root/.bashrc file + echo "" >> /root/.bashrc + echo "# Execute script after login" >> /root/.bashrc + echo "/Proxmox-Debian12/scripts/custom_welcome.sh" >> /root/.bashrc + echo "" >> /root/.bashrc + + echo "Automatic configuration completed for the root user." + done +} + +ask_reboot() +{ + # Prompt for restarting the computer using whiptail + if whiptail --yesno "(Optional) Do you want to restart your computer now?" 10 50 --yes-button "Yes" --no-button "No"; then + # Messages after choosing to restart + whiptail --title "Installation Completed" --msgbox "Proxmox installation and network configuration completed successfully!\nRemember to configure Proxmox as needed." 15 60 + whiptail --title "Restarting the System" --msgbox "Restarting the system..." 10 50 + systemctl reboot + else + # Message after choosing not to restart + whiptail --title "Installation Completed" --msgbox "Proxmox installation and network configuration completed successfully!\nRemember to configure Proxmox as needed." 15 60 + fi +} + +perguntar_reboot() +{ + # Question about restarting the computer using whiptail + if whiptail --yesno "(Opcional) Deseja reiniciar o computador agora?" 10 50 --yes-button "Sim" --no-button "Não"; then + # Messages after choosing to restart + whiptail --title "Reiniciando o Sistema" --msgbox "Reiniciando o sistema..." 10 50 + systemctl reboot + else + # Message after choosing not to restart + exit 1 + fi +} + +main() +{ + super_user + if [ "$LANGUAGE" == "en" ]; then + if whiptail --yesno "(Optional) Do you want to add a custom welcome screen?" 10 50 --yes-button "Yes" --no-button "No"; then + add_welcome + ask_reboot + else + exit 1 + fi + else + if whiptail --yesno "(Opcional) Deseja adicionar tela de bem-vindo customizada?" 10 50 --yes-button "Sim" --no-button "Não"; then + add_welcome + perguntar_reboot + else + exit 1 + fi + fi +} + +main \ No newline at end of file diff --git a/setup b/setup index 1f41115..0c08f28 100755 --- a/setup +++ b/setup @@ -1,132 +1,305 @@ #!/bin/bash -cd /Proxmox-Debian12 -clear -# Carregar as variáveis de cores do arquivo colors.conf -source ./configs/colors.conf -# Tornando-se root -if [ "$(whoami)" != "root" ]; then - echo -e "${ciano}Tornando-se superusuário...${normal}" - sudo -E bash "$0" "$@" # Executa o script como root - exit $? -fi - -chmod +x scripts/* -chmod +rw configs/* - -# Função para instalar sudo + +# Proxmox Setup v1.0.1 +# by: Matheew Alves + +cd /Proxmox-Debian12 && clear + +# Load configs files // Carregar os arquivos de configuração +source ./configs/* + +# Function to display the language choice menu // Função para exibir o menu de escolha de linguagem +show_language_menu() +{ + whiptail --title "Language Selection" --menu "Select your preferred language:" 15 40 2 \ + 1 "Português Brasileiro" \ + 2 "English" 2>tempfile + + choice=$(cat tempfile) + rm -f tempfile + + # Ask user for language preference // Perguntar ao usuário a preferência de linguagem + case $choice in + 1) + language="pt-br" + ;; + 2) + language="en" + ;; + *) + echo -e "${red}Canceling the installation...${default}" + exit 1 + ;; + esac + + # Save the language choice in the setup_language.conf file // Salvar a escolha da linguagem no arquivo setup_language.conf + echo "LANGUAGE=$language" > ./configs/language.conf + + echo -e "\nLanguage preference set to $language." +} + +# Prerequisites // Pré-Requisitos +super_user() +{ + # Becoming root // Tornando-se root + if [ "$(whoami)" != "root" ]; then + echo -e "${ciano}Log in as superuser...${default}" + sudo -E bash "$0" "$@" # Run the script as root // Executa o script como root + exit $? + fi + + chmod +x scripts/* + chmod +rw configs/* +} + +# Welcome +welcome() +{ + # Welcome with Style + echo -e "${cyan} Script developed by: \e[1;92mhttps://github.com/mathewalves${normal}." && sleep 0.5 + echo "" + echo "" + echo -e "${cyan} --> Welcome to the Proxmox Installation Script on Debian 12 ~~${default}" && sleep 0.5 + echo -e "${blue} This script will install Proxmox on your Debian 12 and provide the option to install some additional packages...${default}" && sleep 0.5 + echo "" + # Adding reboot message + echo -e "${yellow}WARNING: During the installation, the system may reboot several times. Avoid closing the script during installation!" + echo -e "Please be aware of this. Press 'Enter' to continue...${default}" + read ok +} + +bem_vindo() +{ + # Bem-vindo com estilo + echo -e "${cyan} Script desenvolvido por: \e[1;92mhttps://github.com/mathewalves${default}." && sleep 0.5 + echo "" + echo "" + echo -e "${cyan} --> Bem-vindo ao Script de Instalação do Proxmox no Debian 12 ~~${default}" && sleep 0.5 + echo -e "${blue} Este script instalará o Proxmox no seu Debian 12 e oferecerá a opção de instalar alguns pacotes adicionais...${default}" && sleep 0.5 + echo "" + # Adicionando mensagem sobre reinicialização + echo -e "${yellow}AVISO: Durante a instalação, o sistema pode reiniciar várias vezes. Evite Fechar o Script durante a instalação!" + echo -e "Por favor, esteja ciente disso. Aperte 'Enter' para continuar...${default}" + read ok +} + +additional_packages() +{ + # Ask the user if they want to install additional packages + if whiptail --title "Installation of Additional Packages" --yesno "Do you want to install the additional packages?" 10 50; then + clear + # Installation of Additional Packages + install_nala + install_sudo + install_neofetch + install_network_tools + + # Update system + update_system + + # Install Proxmox part 1 + ./scripts/install_proxmox-1.sh + else + # If the answer is not 'Yes', assume it's 'No' + echo -e "${cyan}Skipping installation of additional packages...${default}" + ./scripts/install_proxmox-1.sh + fi +} + +pacotes_adicionais() +{ + # Perguntar ao usuário se deseja instalar pacotes adicionais + if whiptail --title "Instalação de Pacotes Adicionais" --yesno "Deseja instalar os pacotes adicionais?" 10 50; then + clear + # Instalação de Pacotes adicionais + install_nala + instalar_sudo + install_neofetch + install_network_tools + + # Atualizar sistema + update_system + + # Install proxmox parte 1 + ./scripts/install_proxmox-1.sh + else + # Se a resposta não for 'Sim', então assume que é 'Não' + echo -e "${cyan}Pulando instalação dos pacotes adicionais...${default}" + ./scripts/install_proxmox-1.sh + fi +} + +# (en) Function to install sudo install_sudo() { - echo -e "${ciano}Iniciando instalação do sudo...${normal}" + echo -e "${cyan}Starting sudo installation...${default}" + nala install -y sudo + + echo -e "${blue}Looking for users to grant sudo permissions...${default}" + + # List all users in the system with sudo permissions + all_sudo_users=$(grep -E '^[^:]+:[^:]+:[0-9]{4,}' /etc/passwd | cut -d: -f1) + + # Build an array for use with whiptail + user_array=() + for user in $all_sudo_users; do + user_array+=("$user" "") + done + + # Loop to allow the user to select or skip + while true; do + selected_user=$(whiptail --title "User Selection" --menu "Select a user to grant sudo permissions:" 15 60 6 "${user_array[@]}" 3>&1 1>&2 2>&3) + + # Check the user's choice + if [ $? -eq 0 ]; then + # Check if the selected user already has sudo permissions + if id "$selected_user" &>/dev/null && groups "$selected_user" | grep -qw sudo; then + clear + echo -e "${blue}User ${cyan}$selected_user${blue} already has sudo permissions. No action needed.${default}" + else + clear + sed -i "/^sudo/s/$/$selected_user/" /etc/group + echo -e "${green}Sudo permissions updated for user:${cyan} $selected_user${default}." + fi + break + else + clear + echo -e "${yellow}Sudo permissions were not changed.${default}" + break + fi + done +} + +# (pt-br) Função para instalar o sudo +instalar_sudo() +{ + echo -e "${cyan}Iniciando instalação do sudo...${default}" nala install -y sudo - echo -e "${azul}Procurando usuários para adicionar permissões sudo...${normal}" + echo -e "${blue}Procurando usuários para adicionar permissões sudo...${default}" # Lista todos os usuários do sistema com permissões de sudo all_sudo_users=$(grep -E '^[^:]+:[^:]+:[0-9]{4,}' /etc/passwd | cut -d: -f1) - # Pergunta ao usuário se deseja adicionar permissões de sudo - PS3="Selecione um usuário para adicionar permissões de sudo ou digite 'pular' para pular: " - select novo_sudo_user in $all_sudo_users; do - if [[ -n "$novo_sudo_user" ]]; then + # Constrói um array para usar com o whiptail + user_array=() + for user in $all_sudo_users; do + user_array+=("$user" "") + done + + # Loop para permitir que o usuário selecione ou pule + while true; do + selected_user=$(whiptail --title "Seleção de Usuário" --menu "Selecione um usuário para adicionar permissões de sudo:" 15 60 6 "${user_array[@]}" 3>&1 1>&2 2>&3) + + # Verifica a escolha do usuário + if [ $? -eq 0 ]; then # Verifica se o usuário selecionado já tem permissões de sudo - if id "$novo_sudo_user" &>/dev/null && groups "$novo_sudo_user" | grep -qw sudo; then - echo -e "${azul}O usuário ${ciano}$novo_sudo_user${azul} já possui permissões de sudo. Nenhuma ação necessária.${normal}" + if id "$selected_user" &>/dev/null && groups "$selected_user" | grep -qw sudo; then + clear + echo -e "${blue}O usuário ${cyan}$selected_user${blue} já possui permissões de sudo. Nenhuma ação necessária.${default}" else - sed -i "/^sudo/s/$/$novo_sudo_user/" /etc/group - echo -e "${verde}Permissões de sudo atualizadas para o usuário:${ciano} $novo_sudo_user${normal}." + clear + sed -i "/^sudo/s/$/$selected_user/" /etc/group + echo -e "${green}Permissões de sudo atualizadas para o usuário:${cyan} $selected_user${default}." fi + break else - echo "${amarelo}Permissões de sudo não foram alteradas.${normal}" + clear + echo "${yellow}Permissões de sudo não foram alteradas.${default}" + break fi - break done } -# Função para instalar o nala +# Function to install nala install_nala() { - echo -e "${ciano}Iniciando a instalação do 'nala'...${normal}" + if [ "$language" == "en" ]; then + echo -e "${cyan}Starting the installation of 'nala'...${default}" + else + echo -e "${cyan}Iniciando a instalação do 'nala'...${default}" + fi apt install -y nala - echo -e "${verde}'nala' instalado com sucesso!${normal}" + if [ "$language" == "en" ]; then + echo -e "${green}'nala' installed successfully!${default}" + else + echo -e "${green}'nala' instalado com sucesso!${default}" + fi } -# Função para instalar o neofetch +# Function to install neofetch install_neofetch() { - echo -e "${ciano}Iniciando a instalação do 'neofetch' com o nala...${normal}" + if [ "$language" == "en" ]; then + echo -e "${cyan}Starting the installation of 'neofetch' with nala...${default}" + else + echo -e "${cyan}Iniciando a instalação do 'neofetch' com 'nala'...${default}" + fi nala install -y neofetch - echo -e "${verde}'neofetch' instalado com sucesso!${normal}" + if [ "$language" == "en" ]; then + echo -e "${green}'neofetch' installed successfully!${default}" + else + echo -e "${green}'neofetch' instalado com sucesso!${default}" + fi } -# Função para instalar ferramentas de rede +# Function to install network tools install_network_tools() { - echo -e "${ciano}Iniciando a instalação do 'net-tools' & 'nmap' com o nala...${normal}" + if [ "$language" == "en" ]; then + echo -e "${cyan}Starting the installation of 'net-tools' & 'nmap' with nala...${default}" + else + echo -e "${cyan}Iniciando a instalação de 'net-tools' e 'nmap' com nala...${default}" + fi nala install -y nmap && nala install -y net-tools - echo -e "${verde}Pacotes instalados com sucesso!${normal}" + if [ "$language" == "en" ]; then + echo -e "${green}Packages installed successfully!${default}" + else + echo -e "${green}Pacotes instalados com sucesso!${default}" + fi } -# Função para atualizar o sistema +# Function to update the system update_system() { - echo -e "${ciano}Atualizando o sistema...${normal}" - if [ "$resposta" == "sim" ]; then - nala update && nala upgrade + if [ "$language" == "en" ]; then + echo -e "${cyan}Updating the system...${default}" else - apt-get update && apt-get upgrade + echo -e "${cyan}Atualizando o sistema...${default}" + fi + nala update -y && nala upgrade -y + if [ "$language" == "en" ]; then + echo -e "${green}Update successful!${default}" + else + echo -e "${green}Atualização bem-sucedida!${default}" fi - echo -e "${verde}Atualização feita com sucesso!${normal}" } main() { + super_user + show_language_menu + clear # Emoji ASCII - echo -e "${ciano} _ " - echo -e "${ciano} _ __ _ __ _____ ___ __ ___ _____ __ ___ ___| |_ _ _ _ __ " - echo -e "${ciano} | '_ \| '__/ _ \ \/ / '_ \` _ \ / _ \ \/ / / __|/ _ \ __| | | | _ \\" - echo -e "${ciano} | |_) | | | (_) > <| | | | | | (_) > < \__ \ __/ |_| |_| | |_) |" - echo -e "${ciano} | .__/|_| \___/_/\_\_| |_| |_|\___/_/\_\ _____ |___/\___|\__|\__,_| .__/" - echo -e "${ciano} |_| |_____| |_| " + echo -e "${red} _ " + echo -e "${red} _ __ _ __ _____ ___ __ ___ _____ __ ___ ___| |_ _ _ _ __ " + echo -e "${red} | '_ \| '__/ _ \ \/ / '_ \` _ \ / _ \ \/ / / __|/ _ \ __| | | | _ \\" + echo -e "${red} | |_) | | | (_) > <| | | | | | (_) > < \__ \ __/ |_| |_| | |_) |" + echo -e "${red} | .__/|_| \___/_/\_\_| |_| |_|\___/_/\_\ _____ |___/\___|\__|\__,_| .__/" + echo -e "${red} |_| |_____| |_| ${yellow}v1.0.1${default}" echo -e "\e[0m" - - # Bem-vindo com estilo - echo -e "${ciano} Script desenvolvido por: \e[1;92mhttps://github.com/mathewalves${normal}." - echo "" - echo "" - echo -e "${ciano} --> Bem-vindo ao Script de Instalação do Proxmox no Debian 12 ~~${normal}" - echo -e "${azul} Este script instalará o Proxmox no seu Debian 12 e oferecerá a opção de instalar alguns pacotes adicionais...${normal}" - echo "" - # Adicionando mensagem sobre reinicialização - echo -e "${vermelho}AVISO: Durante a instalação, o sistema pode reiniciar várias vezes. Evite Fechar o Script durante a instalação!${normal}" - echo -e "${amarelo}Por favor, esteja ciente disso. Aperte 'Enter' para continuar...${normal}" - read ok - - echo -e "${ciano}Deseja instalar os ${verde}pacotes adicionais${ciano}? [S/N]${normal}" - read -p "Resposta: " resposta - - # Converte a resposta para minúsculas antes de comparar - resposta=$(echo "$resposta" | tr '[:upper:]' '[:lower:]') - - if [ "$resposta" == "s" ]; then - # Instalação de Pacotes adicionais - install_nala - install_sudo - install_neofetch - install_network_tools - - # Atualizar sistema - update_system + sleep 0.5 + if [ "$language" == "en" ]; then + welcome + else + bem_vindo + fi - # Install proxmox parte 1 - ./scripts/install_proxmox-1.sh - else - if [ "$resposta" != "n" ]; then - echo -e "${amarelo}Resposta inválida. Saindo do script.${normal}" - exit 1 + if [ "$language" == "en" ]; then + additional_packages + else + pacotes_adicionais fi - echo -e "${ciano}Pulando instalação dos pacotes adicionais...${normal}" - ./scripts/install_proxmox-1.sh - fi } main