From 8e9d48428b55ea6b65de60fe304496ba0bb4ab60 Mon Sep 17 00:00:00 2001 From: Halbe Bruno Date: Mon, 10 Feb 2025 15:29:27 -0300 Subject: [PATCH] install.sh --- mod/install.sh | 103 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/mod/install.sh b/mod/install.sh index a723a7f..de8a9c9 100644 --- a/mod/install.sh +++ b/mod/install.sh @@ -1 +1,102 @@ -# ZabbixMOD by IPv0 \ No newline at end of file +#!/bin/bash +# ZabbixMOD by IPv0 + + + +# Funções de cores para mensagens +_echo_green(){ /bin/echo -e "\033[0;32m$@\033[0m"; } +_echo_green_n(){ /bin/echo -ne "\033[0;32m$@\033[0m"; } + +_echo_yellow(){ /bin/echo -e "\033[0;33m$@\033[0m"; } +_echo_yellow_n(){ /bin/echo -ne "\033[0;33m$@\033[0m"; } + +_echo_red(){ /bin/echo -e "\033[0;31m$@\033[0m"; } +_echo_red_n(){ /bin/echo -ne "\033[0;31m$@\033[0m"; } + +_echo_success(){ /bin/echo -en "\\033[91G"; /bin/echo -en "\x1B[97m["; /bin/echo -en "\033[1;32m OK \033[0m"; /bin/echo -e "\x1B[97m]\033[0m"; } +_echo_failure(){ /bin/echo -en "\\033[91G"; /bin/echo -en "\033[41m\e[5m"; /bin/echo -en "\033[1;38m\x1B FAILED \033[0m"; /bin/echo -e "\x1B[97m\033[0m"; } + +## Verifica se o usuário é root +if [ "$EUID" -ne 0 ]; then + _echo_red "\n Você deve ser root para executar este script!\n" + exit 1 +fi + +## Dependencias +_dependencias() { +DEPENDENCIAS=( + "figlet" + "python3-apt" + "lsb-release" + "git" +) + +for pkg in "${DEPENDENCIAS[@]}"; do + if ! dpkg -l | grep -q "^ii $pkg"; then + _echo_yellow "Instalando dependência: $pkg..." + apt-get update -y && apt-get install -y "$pkg" + if [ $? -eq 0 ]; then + _echo_success "Dependência $pkg instalada com sucesso." + else + _echo_failure "Falha ao instalar a dependência $pkg." + exit 1 + fi + else + _echo_green "Dependência $pkg já está instalada." + fi +done +} + +## Motd +_motd() { + motd00="00-header" + + > /etc/update-motd.d/$motd00 + + cat << EOF > "/etc/update-motd.d/$motd00" + #!/bin/sh + + _echo_red(){ /bin/echo -e "\033[0;31m\$@\033[0m"; } + + #name=\$(figlet -Wf Broadway -w 480 "ZABBIX") + name=\$(figlet -W -w 480 "ZABBIX") + + [ -r /etc/lsb-release ] && . /etc/lsb-release + + if [ -z "\$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then + # Fall back to using the very slow lsb_release utility + DISTRIB_DESCRIPTION=\$(lsb_release -s -d) + fi + + _echo_red "\$name" + printf "\n" + + printf "Bem vindo ao %s (%s).\n" "\$DISTRIB_DESCRIPTION" "\$(uname -r)" + printf "\n" + EOF + + chmod +x *-* + + cd /etc && rm /etc/motd && rm -rf /var/run/motd* + ln -s /var/run/motd.dynamic.new motd +} + +_issue() { + ## Font adicional pro figlet + wget -O /usr/share/figlet/Broadway.flf https://git.ipv0.com.br/halbebruno/Linux/raw/branch/master/mod/Broadway.flf + + cp /etc/issue /etc/issue.backup + + issue_content=$(cat /etc/issue) + + figlet_output=$(figlet -Wf Broadway -w 480 "ZABBIX") + + cat < /etc/issue + $figlet_output + by TECCNIA - https://teccnia.com.br + + + $issue_content + + EOF +} \ No newline at end of file