Files
vtl-appliance/scripts/start-mhvtl.sh

47 lines
1.3 KiB
Bash
Executable File

#!/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