Files
Linux-Server-Management-Too…/run.sh
T
Developer ac6c0b5c12 FIX: Improve startup flow error handling and correctness
CRITICAL: Library sourcing error handling
- launcher.sh lines 21-25: Added error checks for all source commands
- Each library now reports if it fails to load
- Script exits with message instead of silent failure

MEDIUM: init_directories error checking
- launcher.sh lines 630-631: Added error handling for mkdir -p
- Script now reports if directory creation fails
- Better user feedback on initialization errors

HIGH: Stderr redirect cleanup
- run.sh line 14: Removed misplaced 2>/dev/null after closing bracket
- launcher.sh lines 678, 694: Reordered redirects for clarity
  (read ... </dev/tty 2>/dev/null instead of 2>/dev/null </dev/tty)

REASON: Improves startup robustness by catching initialization failures
early and providing helpful error messages instead of silent failures.
2026-03-19 22:37:46 -04:00

65 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
################################################################################
# Wrapper script for Server Toolkit
################################################################################
# This wrapper allows proper history cleanup by running in the current shell
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Fix HISTFILE if set to non-existent path (prevents crashes on sourcing)
if [ -n "$HISTFILE" ]; then
HISTFILE_DIR="$(dirname "$HISTFILE" 2>/dev/null)"
if [ ! -d "$HISTFILE_DIR" ]; then
# Fallback to default history location
export HISTFILE="$HOME/.bash_history"
fi
fi
# Check if being sourced or executed
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "ERROR: This script must be sourced, not executed."
echo ""
echo "Run it like this:"
echo " source $0"
echo ""
echo "Or use the alias:"
echo " . $0"
exit 1
fi
# Run the launcher (source in current shell, don't execute in subshell)
source "$SCRIPT_DIR/launcher.sh"
# Check if cleanup is requested
if [ -f /tmp/.cleanup_requested ]; then
rm -f /tmp/.cleanup_requested
# Clean history in current shell
GREP_PATTERN="git\.mull\.lol|linux-server-management-toolkit|server-toolkit|launcher\.sh|erase-toolkit-traces|run\.sh"
if [ -f ~/.bash_history ]; then
cp ~/.bash_history ~/.bash_history.bak.$$
grep -Ev "$GREP_PATTERN" ~/.bash_history.bak.$$ > ~/.bash_history 2>/dev/null || true
rm -f ~/.bash_history.bak.$$
fi
# Clear current shell's history
history -c
history -r ~/.bash_history
unset HISTFILE
set +o history
# Remove toolkit directory
cd /root 2>/dev/null
rm -rf "$SCRIPT_DIR" 2>/dev/null
clear
echo ""
echo "✓ All traces removed"
echo ""
echo "Type 'exit' and start a new shell."
echo ""
fi