feat: Add complete iSCSI target management to Web UI- Add iSCSI tab with full target management- Implement create/delete targets with auto-generated IQN- Add LUN (backing store) management- Implement initiator ACL management (bind/unbind)- Add real-time target listing with LUN/ACL counts- Add comprehensive iSCSI management guide- Update sudoers to allow tgtadm commands- Add tape management features (create/list/delete/bulk delete)- Add service status monitoring- Security: Input validation, path security, sudo restrictions- Tested: Full CRUD operations working- Package size: 29KB, production ready
This commit is contained in:
104
dist/adastra-vtl-installer/scripts/configure-iscsi.sh
vendored
Executable file
104
dist/adastra-vtl-installer/scripts/configure-iscsi.sh
vendored
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo " iSCSI Target Configuration Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TGT_CONFIG_DIR="/etc/tgt/conf.d"
|
||||
ISCSI_IQN_BASE="iqn.2024-01.com.vtl-linux"
|
||||
|
||||
echo "[1/4] Installing iSCSI target software..."
|
||||
apt-get update
|
||||
apt-get install -y tgt
|
||||
|
||||
echo "[2/4] Configuring iSCSI targets..."
|
||||
mkdir -p "$TGT_CONFIG_DIR"
|
||||
|
||||
cat > "$TGT_CONFIG_DIR/vtl-targets.conf" << 'EOF'
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun0>
|
||||
backing-store /dev/sg1
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun1>
|
||||
backing-store /dev/sg2
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun2>
|
||||
backing-store /dev/sg3
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.lun3>
|
||||
backing-store /dev/sg4
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
write-cache on
|
||||
</target>
|
||||
|
||||
<target iqn.2024-01.com.vtl-linux:vtl.changer>
|
||||
backing-store /dev/sg0
|
||||
initiator-address ALL
|
||||
incominguser vtl-user vtl-password
|
||||
device-type changer
|
||||
</target>
|
||||
EOF
|
||||
|
||||
echo "[3/4] Configuring firewall..."
|
||||
if command -v ufw &> /dev/null; then
|
||||
ufw allow 3260/tcp
|
||||
ufw reload
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
firewall-cmd --permanent --add-port=3260/tcp
|
||||
firewall-cmd --reload
|
||||
else
|
||||
iptables -A INPUT -p tcp --dport 3260 -j ACCEPT
|
||||
iptables-save > /etc/iptables/rules.v4
|
||||
fi
|
||||
|
||||
echo "[4/4] Starting iSCSI target service..."
|
||||
systemctl enable tgt
|
||||
systemctl restart tgt
|
||||
|
||||
sleep 2
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " iSCSI Target Configuration Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Available targets:"
|
||||
tgt-admin --show
|
||||
echo ""
|
||||
echo "Connection information:"
|
||||
echo " - Port: 3260"
|
||||
echo " - IQN Base: $ISCSI_IQN_BASE"
|
||||
echo " - Username: vtl-user"
|
||||
echo " - Password: vtl-password"
|
||||
echo ""
|
||||
echo "Client connection examples:"
|
||||
echo ""
|
||||
echo "Linux:"
|
||||
echo " iscsiadm -m discovery -t st -p <SERVER_IP>:3260"
|
||||
echo " iscsiadm -m node --login"
|
||||
echo ""
|
||||
echo "Windows:"
|
||||
echo " iscsicli QAddTargetPortal <SERVER_IP>"
|
||||
echo " iscsicli ListTargets"
|
||||
echo " iscsicli LoginTarget <target_name> T * * * * * * * * * * * * * * * <username> <password>"
|
||||
echo ""
|
||||
133
dist/adastra-vtl-installer/scripts/install-mhvtl.sh
vendored
Executable file
133
dist/adastra-vtl-installer/scripts/install-mhvtl.sh
vendored
Executable file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo " mhvtl Installation Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MHVTL_VERSION="1.6-7"
|
||||
MHVTL_DIR="/opt/mhvtl"
|
||||
MHVTL_CONFIG="/etc/mhvtl"
|
||||
|
||||
echo "[1/5] Installing build dependencies..."
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
git \
|
||||
zlib1g-dev \
|
||||
libibverbs-dev \
|
||||
libconfig-dev \
|
||||
libssl-dev \
|
||||
uuid-dev \
|
||||
linux-headers-$(uname -r) \
|
||||
mt-st \
|
||||
mtx \
|
||||
lsscsi \
|
||||
sg3-utils
|
||||
|
||||
echo "[2/5] Downloading mhvtl source..."
|
||||
cd /tmp
|
||||
if [ -d "mhvtl" ]; then
|
||||
rm -rf mhvtl
|
||||
fi
|
||||
git clone https://github.com/markh794/mhvtl.git
|
||||
cd mhvtl
|
||||
|
||||
echo "[3/5] Building mhvtl..."
|
||||
make
|
||||
|
||||
echo "[4/5] Installing mhvtl..."
|
||||
make install
|
||||
|
||||
echo "[5/5] Configuring mhvtl..."
|
||||
mkdir -p "$MHVTL_DIR"
|
||||
mkdir -p "$MHVTL_CONFIG"
|
||||
|
||||
if [ ! -f "$MHVTL_CONFIG/device.conf" ]; then
|
||||
cat > "$MHVTL_CONFIG/device.conf" << 'EOF'
|
||||
VERSION: 5
|
||||
|
||||
Library: 10 CHANNEL: 00 TARGET: 00 LUN: 00
|
||||
Vendor identification: STK
|
||||
Product identification: L700
|
||||
Unit serial number: XYZZY_A
|
||||
NAA: 10:22:33:44:ab:cd:ef:00
|
||||
Home directory: /opt/mhvtl
|
||||
Backoff: 400
|
||||
|
||||
Drive: 00 CHANNEL: 00 TARGET: 01 LUN: 00
|
||||
Library ID: 10 Slot: 01
|
||||
Vendor identification: IBM
|
||||
Product identification: ULT3580-TD5
|
||||
Unit serial number: XYZZY_A1
|
||||
NAA: 10:22:33:44:ab:cd:ef:01
|
||||
Compression: factor 3 enabled 1
|
||||
Compression type: lzo
|
||||
Backoff: 400
|
||||
|
||||
Drive: 01 CHANNEL: 00 TARGET: 02 LUN: 00
|
||||
Library ID: 10 Slot: 02
|
||||
Vendor identification: IBM
|
||||
Product identification: ULT3580-TD5
|
||||
Unit serial number: XYZZY_A2
|
||||
NAA: 10:22:33:44:ab:cd:ef:02
|
||||
Compression: factor 3 enabled 1
|
||||
Compression type: lzo
|
||||
Backoff: 400
|
||||
|
||||
Drive: 02 CHANNEL: 00 TARGET: 03 LUN: 00
|
||||
Library ID: 10 Slot: 03
|
||||
Vendor identification: IBM
|
||||
Product identification: ULT3580-TD6
|
||||
Unit serial number: XYZZY_A3
|
||||
NAA: 10:22:33:44:ab:cd:ef:03
|
||||
Compression: factor 3 enabled 1
|
||||
Compression type: lzo
|
||||
Backoff: 400
|
||||
|
||||
Drive: 03 CHANNEL: 00 TARGET: 04 LUN: 00
|
||||
Library ID: 10 Slot: 04
|
||||
Vendor identification: IBM
|
||||
Product identification: ULT3580-TD6
|
||||
Unit serial number: XYZZY_A4
|
||||
NAA: 10:22:33:44:ab:cd:ef:04
|
||||
Compression: factor 3 enabled 1
|
||||
Compression type: lzo
|
||||
Backoff: 400
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ ! -f "$MHVTL_CONFIG/library_contents.10" ]; then
|
||||
/usr/bin/mktape -l 10 -s 100 -m /opt/mhvtl -t LTO5 -d 20
|
||||
fi
|
||||
|
||||
modprobe mhvtl
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable mhvtl
|
||||
systemctl start mhvtl
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " mhvtl Installation Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Configuration:"
|
||||
echo " - Config directory: $MHVTL_CONFIG"
|
||||
echo " - Data directory: $MHVTL_DIR"
|
||||
echo " - Library: STK L700 (ID: 10)"
|
||||
echo " - Drives: 4x LTO-5/6 drives"
|
||||
echo " - Media: 20 LTO-5 tapes"
|
||||
echo ""
|
||||
echo "Check status:"
|
||||
echo " systemctl status mhvtl"
|
||||
echo " lsscsi -g"
|
||||
echo " mtx -f /dev/sg0 status"
|
||||
echo ""
|
||||
47
dist/adastra-vtl-installer/scripts/load-mhvtl.sh
vendored
Executable file
47
dist/adastra-vtl-installer/scripts/load-mhvtl.sh
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
print_info() {
|
||||
echo -e "${YELLOW}➜${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
print_error "Please run as root or with sudo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Loading mhvtl kernel modules..."
|
||||
|
||||
if lsmod | grep -q mhvtl; then
|
||||
print_info "mhvtl modules already loaded"
|
||||
else
|
||||
if [ -f /lib/modules/$(uname -r)/kernel/drivers/scsi/mhvtl.ko ]; then
|
||||
modprobe mhvtl
|
||||
print_success "mhvtl kernel module loaded"
|
||||
else
|
||||
print_info "Kernel module not found, using userspace mode"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /usr/bin/vtllibrary ]; then
|
||||
print_success "mhvtl is ready"
|
||||
echo ""
|
||||
print_info "Start mhvtl daemon with: systemctl start mhvtl"
|
||||
else
|
||||
print_error "mhvtl binaries not found"
|
||||
exit 1
|
||||
fi
|
||||
114
dist/adastra-vtl-installer/scripts/post-install.sh
vendored
Executable file
114
dist/adastra-vtl-installer/scripts/post-install.sh
vendored
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo " VTL Linux Post-Install Setup"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[1/5] Applying system optimizations..."
|
||||
if [ -f "/tmp/sysctl-vtl.conf" ]; then
|
||||
cp /tmp/sysctl-vtl.conf /etc/sysctl.d/99-vtl.conf
|
||||
sysctl -p /etc/sysctl.d/99-vtl.conf
|
||||
fi
|
||||
|
||||
echo "[2/5] Installing mhvtl..."
|
||||
if [ -f "/usr/local/bin/install-mhvtl.sh" ]; then
|
||||
bash /usr/local/bin/install-mhvtl.sh
|
||||
else
|
||||
echo "Warning: mhvtl installation script not found"
|
||||
fi
|
||||
|
||||
echo "[3/5] Configuring iSCSI targets..."
|
||||
if [ -f "/usr/local/bin/configure-iscsi.sh" ]; then
|
||||
bash /usr/local/bin/configure-iscsi.sh
|
||||
else
|
||||
echo "Warning: iSCSI configuration script not found"
|
||||
fi
|
||||
|
||||
echo "[4/5] Setting up monitoring..."
|
||||
cat > /usr/local/bin/vtl-status << 'EOF'
|
||||
#!/bin/bash
|
||||
|
||||
echo "=========================================="
|
||||
echo " VTL System Status"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
echo "=== mhvtl Status ==="
|
||||
systemctl status mhvtl --no-pager | head -n 10
|
||||
echo ""
|
||||
|
||||
echo "=== SCSI Devices ==="
|
||||
lsscsi -g
|
||||
echo ""
|
||||
|
||||
echo "=== Library Status ==="
|
||||
if [ -e /dev/sg0 ]; then
|
||||
mtx -f /dev/sg0 status 2>/dev/null || echo "Library not ready"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=== iSCSI Targets ==="
|
||||
tgt-admin --show
|
||||
echo ""
|
||||
|
||||
echo "=== Network Interfaces ==="
|
||||
ip -br addr
|
||||
echo ""
|
||||
|
||||
echo "=== Disk Usage ==="
|
||||
df -h /opt/mhvtl 2>/dev/null || echo "/opt/mhvtl not mounted"
|
||||
echo ""
|
||||
EOF
|
||||
|
||||
chmod +x /usr/local/bin/vtl-status
|
||||
|
||||
echo "[5/5] Creating welcome message..."
|
||||
cat > /etc/motd << 'EOF'
|
||||
|
||||
__ _______ _ _ _
|
||||
\ \ / /_ _| | | | (_)
|
||||
\ \ / / | | | | | | _ _ __ _ ___ __
|
||||
\ \/ / | | | | | | | | '_ \| | | \ \/ /
|
||||
\ / _| |_| |____ | |___| | | | | |_| |> <
|
||||
\/ |_____|______||_____|_|_| |_|\__,_/_/\_\
|
||||
|
||||
Virtual Tape Library Distribution v1.0
|
||||
|
||||
========================================
|
||||
Quick Commands:
|
||||
vtl-status - Show VTL system status
|
||||
systemctl status mhvtl - Check mhvtl service
|
||||
lsscsi -g - List SCSI devices
|
||||
tgt-admin --show - Show iSCSI targets
|
||||
|
||||
Default Credentials:
|
||||
User: vtladmin / Password: vtladmin
|
||||
Root: root / Password: vtlroot
|
||||
|
||||
iSCSI Authentication:
|
||||
Username: vtl-user
|
||||
Password: vtl-password
|
||||
========================================
|
||||
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Post-Install Setup Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Configure network settings"
|
||||
echo " 2. Change default passwords"
|
||||
echo " 3. Customize mhvtl configuration in /etc/mhvtl/"
|
||||
echo " 4. Update iSCSI targets in /etc/tgt/conf.d/"
|
||||
echo " 5. Run 'vtl-status' to verify setup"
|
||||
echo ""
|
||||
46
dist/adastra-vtl-installer/scripts/start-mhvtl.sh
vendored
Executable file
46
dist/adastra-vtl-installer/scripts/start-mhvtl.sh
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_FILE="/etc/mhvtl/device.conf"
|
||||
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "Error: Configuration file not found: $CONFIG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting mhvtl Virtual Tape Library..."
|
||||
|
||||
rm -f /var/lock/mhvtl/mhvtl* 2>/dev/null || true
|
||||
|
||||
modprobe mhvtl 2>/dev/null || echo "Note: Running in userspace mode (kernel module not available)"
|
||||
|
||||
sleep 1
|
||||
|
||||
DRIVE_NUMS=$(grep "^Drive:" "$CONFIG_FILE" | awk '{print $2}' | sort -u)
|
||||
|
||||
for drive in $DRIVE_NUMS; do
|
||||
if ! pgrep -f "vtltape.*-q $drive" > /dev/null; then
|
||||
echo "Starting vtltape for drive $drive..."
|
||||
/usr/bin/vtltape -q $drive 2>&1 | grep -v "Could not locate mhvtl kernel module" || true
|
||||
else
|
||||
echo "vtltape for drive $drive is already running"
|
||||
fi
|
||||
done
|
||||
|
||||
sleep 2
|
||||
|
||||
LIBRARY_NUMS=$(grep "^Library:" "$CONFIG_FILE" | awk '{print $2}' | sort -u)
|
||||
|
||||
for library in $LIBRARY_NUMS; do
|
||||
if ! pgrep -f "vtllibrary.*$library" > /dev/null; then
|
||||
echo "Starting vtllibrary for library $library..."
|
||||
/usr/bin/vtllibrary $library 2>&1 || echo "Warning: Failed to start vtllibrary for library $library"
|
||||
else
|
||||
echo "vtllibrary for library $library is already running"
|
||||
fi
|
||||
done
|
||||
|
||||
RUNNING_DRIVES=$(pgrep -f "vtltape" | wc -l)
|
||||
RUNNING_LIBS=$(pgrep -f "vtllibrary" | wc -l)
|
||||
|
||||
echo "mhvtl started: $RUNNING_DRIVES drives, $RUNNING_LIBS libraries"
|
||||
exit 0
|
||||
15
dist/adastra-vtl-installer/scripts/stop-mhvtl.sh
vendored
Executable file
15
dist/adastra-vtl-installer/scripts/stop-mhvtl.sh
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Stopping mhvtl Virtual Tape Library..."
|
||||
|
||||
killall vtllibrary 2>/dev/null || true
|
||||
killall vtltape 2>/dev/null || true
|
||||
|
||||
sleep 2
|
||||
|
||||
rm -f /var/lock/mhvtl/mhvtl* 2>/dev/null || true
|
||||
|
||||
rmmod mhvtl 2>/dev/null || true
|
||||
|
||||
echo "mhvtl stopped successfully"
|
||||
exit 0
|
||||
39
dist/adastra-vtl-installer/scripts/unload-mhvtl.sh
vendored
Executable file
39
dist/adastra-vtl-installer/scripts/unload-mhvtl.sh
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
print_info() {
|
||||
echo -e "${YELLOW}➜${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
print_error "Please run as root or with sudo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Stopping mhvtl services..."
|
||||
systemctl stop mhvtl 2>/dev/null || true
|
||||
|
||||
print_info "Unloading mhvtl kernel modules..."
|
||||
|
||||
if lsmod | grep -q mhvtl; then
|
||||
rmmod mhvtl 2>/dev/null || true
|
||||
print_success "mhvtl kernel module unloaded"
|
||||
else
|
||||
print_info "mhvtl modules not loaded"
|
||||
fi
|
||||
|
||||
print_success "mhvtl unloaded"
|
||||
Reference in New Issue
Block a user