Files
lxs/linux/apps/index.sh
T

106 lines
3.6 KiB
Bash
Executable File

#!/bin/bash
# LXS - Apps index
# Description: Interactive menu listing the application installers in apps/
# Author: LXS
# Date: 2025
# Load LXS common library (colors, separator, run_spinner, loggers)
# Prefers the sibling ../lib/common.sh (repo checkout or installed layout) and
# only hits the network when this script is run standalone via curl.
LXS_RAW_BASE="${LXS_RAW_BASE:-https://git.hyko.cx/hykocx/lxs/raw/branch/main}"
LXS_RAW_PLATFORM_BASE="${LXS_RAW_PLATFORM_BASE:-${LXS_RAW_BASE}/linux}"
_lxs_lib=""
if [ -n "${BASH_SOURCE[0]:-}" ]; then
_lxs_self=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null) \
|| _lxs_self=$(realpath "${BASH_SOURCE[0]}" 2>/dev/null) \
|| _lxs_self="${BASH_SOURCE[0]}"
_lxs_lib="$(dirname "$_lxs_self")/../lib/common.sh"
fi
if [ -n "$_lxs_lib" ] && [ -r "$_lxs_lib" ]; then
# shellcheck disable=SC1090,SC1091
. "$_lxs_lib"
else
_lib=$(curl -fsSL "${LXS_RAW_PLATFORM_BASE}/lib/common.sh") || { echo "Failed to fetch lib/common.sh" >&2; exit 1; }
eval "$_lib"
unset _lib
fi
unset _lxs_lib _lxs_self
# Run a sibling app script. Prefers a file next to this script (installed
# layout); falls back to downloading from LXS_RAW_PLATFORM_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
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 "${CYAN}[..] Fetching ${BOLD}${script_name}${NC}${CYAN}...${NC}"
if curl -fsSL -H "Cache-Control: no-cache" -o "${temp_file}" "${LXS_RAW_PLATFORM_BASE}/${script_path}"; then
echo -e "${GREEN}[OK] Payload acquired${NC}"
chmod +x "${temp_file}"
"${temp_file}" "$@"
exit_code=$?
rm -f "${temp_file}"
return $exit_code
else
echo -e "${RED}[KO] Failed to download ${script_path}${NC}"
rm -f "${temp_file}"
return 1
fi
}
menu_apps() {
while true; do
clear
show_box_top "APPLICATIONS" "APP_REPOSITORY"
echo ""
show_menu_item "01" "Coolify"
show_menu_item "02" "Pterodactyl Panel"
show_menu_item "03" "Uptime Kuma"
show_menu_item "04" "CloudPanel"
show_menu_item "05" "Proxmox VE Tools"
show_menu_item "00" "BACK" "" exit
echo ""
show_box_bottom
echo ""
show_prompt
read -r choice
child_rc=0
case $choice in
1|01) run_sibling "apps/coolify.sh"; child_rc=$? ;;
2|02) run_sibling "apps/pterodactyl.sh"; child_rc=$? ;;
3|03) run_sibling "apps/uptime-kuma.sh"; child_rc=$? ;;
4|04) run_sibling "apps/cloudpanel.sh"; child_rc=$? ;;
5|05) run_sibling "apps/proxmox.sh"; child_rc=$? ;;
0|00) return ;;
*) echo -e "${RED}[KO] Invalid protocol. Select 0-5.${NC}"; sleep 1; continue ;;
esac
# Exit code 75 from a child means it already paused on its own
# (its own "Back" or end-of-run prompt) — skip the redundant prompt.
if [ "$child_rc" -ne 75 ]; then
echo ""
read -r -p "Press Enter to continue..."
fi
done
}
menu_apps