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:
47
scripts/load-mhvtl.sh
Executable file
47
scripts/load-mhvtl.sh
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
|
||||
46
scripts/start-mhvtl.sh
Executable file
46
scripts/start-mhvtl.sh
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
scripts/stop-mhvtl.sh
Executable file
15
scripts/stop-mhvtl.sh
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
scripts/unload-mhvtl.sh
Executable file
39
scripts/unload-mhvtl.sh
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