#!/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 > /dev/null 2>&1 & 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 > /dev/null 2>&1 & 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