From 35d98237168ac15ac5a492c9faaa2983033e038a Mon Sep 17 00:00:00 2001 From: William Grando Date: Mon, 2 Jun 2025 09:49:47 -0300 Subject: [PATCH] init do projeto. --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ iscsi_connect.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 README.md create mode 100644 iscsi_connect.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..2b351eb --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +## ISCSI Conector +#### 📌 Sobre o Projeto + +Script utilizado para facilitar conexão de discos ISCSI em linux baseados em Debian/Ubuntu. + + --- + + #### 🛠️ Requisitos mínimos + --- + + - Debian/Ubuntu > 14.0 + + --- + + #### 🚀 Como usar + --- + + - Acesse seu terminal; + - Clone o repositorio: + +```shell + git clone https://git.instantti.com.br/instant/iscsi_connector.git +``` + + - acesse o diretorio: + +```shell + cd iscsi_connector/ +``` + - Execute o comando: + +```shell + sh iscsi_connect.sh +``` + +- IP_DO_TARGET_ISCSI: Endereço IP do ISCSI que deseja montar. + +```shell +// Ex: +sh iscsi_connect.sh 172.20.100.20 +``` + +>[!NOTE] +> - O script em questão é interativo, então ao executar siga o passo-a-passo dele. \ No newline at end of file diff --git a/iscsi_connect.sh b/iscsi_connect.sh new file mode 100644 index 0000000..363e874 --- /dev/null +++ b/iscsi_connect.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +IP_ALVO="$1" + +if [ -z "$IP_ALVO" ]; then + echo "❌ Uso: $0 " + exit 1 +fi + +# Verifica se está sendo executado como root +if [ "$EUID" -ne 0 ]; then + echo "❌ Este script precisa ser executado como root." + exit 1 +fi + +echo "🔍 Verificando se o open-iscsi está instalado..." +if ! dpkg -l | grep -q open-iscsi; then + echo "⚙️ Instalando pacote open-iscsi..." + apt update && apt install -y open-iscsi +fi + +echo "📡 Descobrindo targets iSCSI no IP $IP_ALVO..." +iscsiadm -m discovery -t sendtargets -p "$IP_ALVO" + +echo +read -p "🧠 Digite o IQN que deseja conectar (copie e cole da linha acima): " IQN + +echo "🔗 Conectando ao IQN $IQN..." +iscsiadm -m node -T "$IQN" -p "$IP_ALVO" --login + +echo "📌 Habilitando reconexão automática no boot..." +iscsiadm -m node -T "$IQN" -p "$IP_ALVO" --op update -n node.startup -v automatic + +echo "✅ Conexão realizada com sucesso. Use 'lsblk' ou 'dmesg | grep sd' para verificar o disco."