Files
DynastyRevolution-Scripts/modules/log

55 lines
1.9 KiB
Bash

#!/bin/bash
# DYNR Module: Log Manager
run_log() {
BLUE='\033[38;5;45m'; PURPLE='\033[38;5;127m'; GOLD='\033[38;5;178m'; RED='\033[38;5;196m'; NC='\033[0m'
clear
echo -e "${PURPLE}=================================================${NC}"
echo -e "${BLUE} 🐉 DYNASTY REVOLUTION: LOG MANAGER 🐉 ${NC}"
echo -e "${PURPLE}=================================================${NC}"
# 1. Select the Log Type
echo -e "${GOLD}Select a Log Path to inspect:${NC}"
options=(
"/var/log/syslog (System)"
"/var/log/auth.log (Security/Login)"
"/var/log/kern.log (Kernel)"
"Custom Path"
"Return"
)
select opt in "${options[@]}"; do
case $opt in
"/var/log/syslog (System)") LOG_PATH="/var/log/syslog"; break;;
"/var/log/auth.log (Security/Login)") LOG_PATH="/var/log/auth.log"; break;;
"/var/log/kern.log (Kernel)") LOG_PATH="/var/log/kern.log"; break;;
"Custom Path") read -p "Enter full path: " LOG_PATH; break;;
"Return") return;;
esac
done
if [ ! -f "$LOG_PATH" ]; then
echo -e "${RED}❌ Error: Scroll not found at $LOG_PATH${NC}"
return
fi
# 2. Action Selection
echo -e "\n${BLUE}Action for $LOG_PATH:${NC}"
echo "1) Tail (Live View - Last 50 lines)"
echo "2) Purge (Clear log content)"
read -p "Selection [1-2]: " LOG_ACT
if [ "$LOG_ACT" == "1" ]; then
echo -e "${GOLD}Reading the scroll... Press Ctrl+C to stop.${NC}"
sleep 1
tail -n 50 -f "$LOG_PATH"
elif [ "$LOG_ACT" == "2" ]; then
echo -e "${RED}🔥 Are you sure you want to wipe this log? (y/n)${NC}"
read -p "> " confirm
if [[ "$confirm" == "y" ]]; then
sudo truncate -s 0 "$LOG_PATH"
echo -e "${GOLD}Log cleared.${NC}"
fi
fi
}