Files
vtl-appliance/dist/adastra-vtl-installer/uninstall.sh

89 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -e
INSTALL_DIR="/opt/adastra-vtl"
WEB_DIR="/var/www/html/mhvtl-config"
SYSTEMD_DIR="/etc/systemd/system"
CONFIG_DIR="/etc/mhvtl"
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"
}
check_root() {
if [ "$EUID" -ne 0 ]; then
print_error "Please run as root or with sudo"
exit 1
fi
}
uninstall_adastra() {
print_info "Stopping services..."
systemctl stop mhvtl 2>/dev/null || true
systemctl disable mhvtl 2>/dev/null || true
print_info "Unloading kernel modules..."
if [ -f /usr/local/bin/mhvtl-unload ]; then
/usr/local/bin/mhvtl-unload 2>/dev/null || true
fi
print_info "Removing files..."
rm -rf "$INSTALL_DIR"
rm -rf "$WEB_DIR"
rm -f "$SYSTEMD_DIR"/mhvtl*.service
rm -f /usr/local/bin/mhvtl-load
rm -f /usr/local/bin/mhvtl-unload
systemctl daemon-reload
print_info "Removing mhvtl..."
rm -f /usr/bin/vtl*
rm -f /usr/bin/mktape
rm -f /lib/modules/$(uname -r)/kernel/drivers/scsi/mhvtl.ko 2>/dev/null || true
depmod -a
print_success "Adastra VTL uninstalled"
echo ""
print_info "Note: Configuration files in $CONFIG_DIR were preserved"
print_info "Note: User 'vtl' and group 'vtl' were preserved"
print_info "To remove them manually:"
echo " userdel vtl"
echo " groupdel vtl"
echo " rm -rf $CONFIG_DIR"
echo " rm -rf /var/lib/mhvtl"
}
main() {
echo "Adastra VTL Uninstaller"
echo ""
check_root
read -p "Are you sure you want to uninstall Adastra VTL? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
uninstall_adastra
else
print_info "Uninstall cancelled"
exit 0
fi
}
main "$@"