exit was not presistent

This commit is contained in:
2026-02-06 03:58:06 -05:00
parent 7732f490bb
commit 6d787bc27e

View File

@@ -1,23 +1,18 @@
#!/bin/bash
# -----------------------------------------------------------------------
# Dynasty Revolution CLI Framework (dynr) - DYNAMIC CORE v2.3.4
# Authors: Dynasty Revolution & SaavageBueno
# Dynasty Revolution CLI Framework (dynr) - DYNAMIC CORE v2.3.5
# -----------------------------------------------------------------------
VERSION="2.3.4"
VERSION="2.3.5"
BLUE='\033[38;5;45m'; PURPLE='\033[38;5;127m'; GOLD='\033[38;5;178m'; RED='\033[38;5;196m'; NC='\033[0m'
REPO_RAW="https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main"
MOD_DIR="/opt/dynr/modules"
# --- The Magic Loader ---
load_and_run() {
local mod=$1
local remote="$REPO_RAW/modules/$mod"
# 1. Download if missing
if [ ! -f "$MOD_DIR/$mod" ]; then
echo -e "${GOLD}🐉 Seeking the '$mod' scroll in the archives...${NC}"
# -f fails silently on 404 to allow custom error handling
if curl -sSLf "$remote" -o "$MOD_DIR/$mod"; then
chmod +x "$MOD_DIR/$mod"
else
@@ -25,25 +20,42 @@ load_and_run() {
return 1
fi
fi
# 2. Load the file
source "$MOD_DIR/$mod"
# 3. Execute: run_<module_name> (Converts hyphens to underscores for Bash functions)
# Example: 'system-info' becomes 'run_system_info'
local func_name="run_${mod//-/_}"
if declare -f "$func_name" > /dev/null; then
shift # Remove the module name from the argument list
"$func_name" "$@" # Execute function with remaining args
shift
"$func_name" "$@"
else
echo -e "${RED}❌ Error: Function '$func_name' not defined in module '$mod'.${NC}"
fi
}
# --- Internal Router ---
case "$1" in
# Clean Exit Logic
exit|quit)
FAREWELLS=(
"The
echo -e "${GOLD}🐉 The Dynasty awaits your return. Farewell.${NC}"
exit 0
;;
update)
sudo curl -sSL "$REPO_RAW/core/dynr" -o /usr/local/bin/dynr
sudo chmod +x /usr/local/bin/dynr
echo -e "${GOLD}✨ Dynasty Core updated to v$VERSION.${NC}"
;;
refresh)
[[ -z "$2" ]] && echo "Usage: dynr refresh <mod>" || (rm -f "$MOD_DIR/$2" && load_and_run "$2")
;;
list)
ls "$MOD_DIR" 2>/dev/null | sed 's/^/ 🐉 /' || echo " (Empty)"
;;
*)
if [ -z "$1" ]; then
clear
echo -e "${PURPLE}🐉 DYNASTY REVOLUTION DYNAMIC CLI v$VERSION${NC}"
echo -e "Main Commands: ${GOLD}list, update, refresh, exit, help${NC}"
echo -e "${PURPLE}-------------------------------------------------${NC}"
read -p "dynr > " AUTO_CMD < /dev/tty
[[ ! -z "$AUTO_CMD" ]] && dynr $AUTO_CMD || exit 0
else
load_and_run "$@"
fi
;;
esac