cdcd89b5b2
- add `tools/welcome-message.sh` with view, set, and reset actions - register `lxs tool welcome|motd` command in `lxs.sh` - add option 7 to interactive tools menu in `tools/index.sh` - document `lxs tool welcome` in README
92 lines
3.5 KiB
Bash
Executable File
92 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# LXS - Tools index
|
|
# Description: Interactive menu listing the scripts in tools/
|
|
# Author: LXS
|
|
# Date: 2025
|
|
|
|
# Load LXS common library (colors, separator, run_spinner, loggers)
|
|
LXS_RAW_BASE="${LXS_RAW_BASE:-https://git.hyko.cx/hykocx/lxs/raw/branch/main}"
|
|
_lib=$(curl -fsSL "${LXS_RAW_BASE}/lib/common.sh") || { echo "Failed to fetch lib/common.sh" >&2; exit 1; }
|
|
eval "$_lib"
|
|
unset _lib
|
|
|
|
# Run a sibling tool script. Prefers a file next to this script (installed
|
|
# layout); falls back to downloading from LXS_RAW_BASE.
|
|
run_sibling() {
|
|
local script_path=$1
|
|
shift
|
|
local script_name self_dir resolved src="${BASH_SOURCE[0]}"
|
|
script_name=$(basename "$script_path")
|
|
|
|
if [ -n "$src" ]; then
|
|
resolved=$(readlink -f "$src" 2>/dev/null) \
|
|
|| resolved=$(realpath "$src" 2>/dev/null) \
|
|
|| resolved="$src"
|
|
self_dir=$(dirname "$resolved")
|
|
fi
|
|
|
|
# self_dir points at tools/; the install layout puts siblings here too.
|
|
if [ -n "$self_dir" ] && [ -f "${self_dir}/${script_name}" ]; then
|
|
chmod +x "${self_dir}/${script_name}" 2>/dev/null || true
|
|
"${self_dir}/${script_name}" "$@"
|
|
return $?
|
|
fi
|
|
|
|
local temp_file exit_code
|
|
temp_file=$(mktemp "/tmp/lxs.${script_name%.*}.XXXXXX.sh")
|
|
echo -e "${PURPLE}[*] Downloading ${BOLD}${script_name}${NC}${PURPLE}...${NC}"
|
|
if curl -fsSL -H "Cache-Control: no-cache" -o "${temp_file}" "${LXS_RAW_BASE}/${script_path}"; then
|
|
echo -e "${GREEN}[✓] Downloaded${NC}"
|
|
chmod +x "${temp_file}"
|
|
"${temp_file}" "$@"
|
|
exit_code=$?
|
|
rm -f "${temp_file}"
|
|
return $exit_code
|
|
else
|
|
echo -e "${RED}[✗] Failed to download ${script_path}${NC}"
|
|
rm -f "${temp_file}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
menu_tools() {
|
|
while true; do
|
|
clear
|
|
echo -e "${WHITE}╔═══════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${WHITE}║ TOOLS ║${NC}"
|
|
echo -e "${WHITE}╚═══════════════════════════════════════════════════════╝${NC}"
|
|
echo ""
|
|
echo -e " ${CYAN}[1]${NC} System Infos"
|
|
echo -e " ${PURPLE}[2]${NC} Server Benchmark"
|
|
echo -e " ${YELLOW}[3]${NC} Harden Server"
|
|
echo -e " ${GREEN}[4]${NC} Change Root Password"
|
|
echo -e " ${CYAN}[5]${NC} Update Server"
|
|
echo -e " ${YELLOW}[6]${NC} Root SSH Password Login"
|
|
echo -e " ${PURPLE}[7]${NC} Welcome Message (MOTD)"
|
|
echo -e " ${RED}[0]${NC} Back"
|
|
echo ""
|
|
echo -e -n "${BOLD}Choice [0-7]: ${NC}"
|
|
read -r choice
|
|
|
|
case $choice in
|
|
1) run_sibling "tools/system-infos.sh" ;;
|
|
2) run_sibling "tools/server-benchmark.sh" ;;
|
|
3) run_sibling "tools/harden.sh" ;;
|
|
4) run_sibling "tools/root-password.sh" ;;
|
|
5) run_sibling "tools/update-server.sh" ;;
|
|
6) run_sibling "tools/root-ssh-login.sh" ;;
|
|
7) run_sibling "tools/welcome-message.sh" ;;
|
|
0) return ;;
|
|
*) echo -e "${RED}[✗] Invalid option. Please select 0-7.${NC}"; sleep 1; continue ;;
|
|
esac
|
|
|
|
if [ "$choice" != "0" ]; then
|
|
echo ""
|
|
read -r -p "Press Enter to continue..."
|
|
fi
|
|
done
|
|
}
|
|
|
|
menu_tools
|