From fbaba84f41e75ac556dbe4884e07fb0b9babdb08 Mon Sep 17 00:00:00 2001 From: saavagebueno Date: Mon, 13 Apr 2026 01:19:22 -0400 Subject: [PATCH] os hannddilinngggg --- core/OS_handler.func | 62 ++++++++++++++++++++++++++++++++++++++++++++ core/build.func | 24 +++++++++++------ 2 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 core/OS_handler.func diff --git a/core/OS_handler.func b/core/OS_handler.func new file mode 100644 index 0000000..d1fd705 --- /dev/null +++ b/core/OS_handler.func @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +os_detect() { + if [ -f /etc/os-release ]; then + . /etc/os-release + OS_ID=$ID + OS_VERSION_ID=$VERSION_ID + else + OS_ID="unknown" + OS_VERSION_ID="unknown" + fi + + export LC_ALL=C.UTF-8 + export LANG=C.UTF-8 + + case "$OS_ID" in + debian|ubuntu) + PKG_MANAGER="apt-get" + PKG_UPDATE="$PKG_MANAGER update" + PKG_INSTALL="$PKG_MANAGER install -y" + PKG_CLEAN="$PKG_MANAGER autoremove -y && $PKG_MANAGER clean" + BUILD_TOOLS="build-essential" + PYTHON_PKG="python3 python3-pip" + ;; + fedora|centos|rhel) + PKG_MANAGER="dnf" + PKG_UPDATE="$PKG_MANAGER check-update" + PKG_INSTALL="$PKG_MANAGER install -y" + PKG_CLEAN="$PKG_MANAGER autoremove -y && $PKG_MANAGER clean all" + BUILD_TOOLS="@development-tools" + PYTHON_PKG="python3 python3-pip" + ;; + alpine) + PKG_MANAGER="apk" + PKG_UPDATE="$PKG_MANAGER update" + PKG_INSTALL="$PKG_MANAGER add" + PKG_CLEAN="rm -rf /var/cache/apk/*" + BUILD_TOOLS="build-base" + PYTHON_PKG="python3 py3-pip" + ;; + *) + msg_error "Unsupported OS: $OS_ID" + exit 1 + ;; + esac +} + +dynr_initialize_node() { + msg_info "Synchronizing $OS_ID Environment..." + $PKG_UPDATE >/dev/null 2>&1 + + if [[ "$OS_ID" == "debian" || "$OS_ID" == "ubuntu" ]]; then + $PKG_INSTALL locales >/dev/null 2>&1 + sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen >/dev/null 2>&1 + locale-gen en_US.UTF-8 >/dev/null 2>&1 + fi + + $PKG_INSTALL curl wget git sudo tzdata >/dev/null 2>&1 + msg_ok "Universal OS Established." +} + +os_detect \ No newline at end of file diff --git a/core/build.func b/core/build.func index 02d94b0..63e15e2 100644 --- a/core/build.func +++ b/core/build.func @@ -72,7 +72,7 @@ eval "$(curl -fsSL ${DYNR_CORE}/core.func)" eval "$(curl -fsSL ${DYNR_CORE}/error_handler.func)" network_check() { - msg_info "Verifying Fleet Uplink (1.1.1.1 / 1.0.0.1)..." + msg_info "Checking Network Connectivity (1.1.1.1 / 1.0.0.1)..." if ping -c 1 -W 2 1.1.1.1 &>/dev/null || ping -c 1 -W 2 1.0.0.1 &>/dev/null; then msg_ok "Network OK." else @@ -113,7 +113,7 @@ remote_strike_ui() { if command -v osascript &>/dev/null && [[ "$OSTYPE" == "darwin"* ]]; then osascript -e "display dialog \"$prompt\" default answer \"$default\" with title \"$title\" buttons {\"Cancel\", \"Next\"} default button \"Next\"" -e "text returned of result" 2>/dev/null elif command -v whiptail &>/dev/null; then - whiptail --backtitle "$title" --title "TACTICAL INPUT" --inputbox "$prompt" 10 58 "$default" 3>&1 1>&2 2>&3 + whiptail --backtitle "$title" --title "INPUT" --inputbox "$prompt" 10 58 "$default" 3>&1 1>&2 2>&3 else read -p "$prompt [$default]: " val /dev/null) clear echo -e \"${PURPLE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\" @@ -167,7 +169,7 @@ initiate_remote_strike() { echo -e \"${BLUE}Script: ${GOLD}${APP}${NC}\" echo -e \"${PURPLE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\" echo \"\" - read -p \"Proceed y/n ? \" proceed + read -p \"Proceed with Host \$target_hostname (y/n)? \" proceed if [[ \"\$proceed\" =~ ^[Yy] ]]; then METHOD=\"$deploy_mode\" bash -c \"\$(curl -fsSL $script_home)\" else @@ -239,7 +241,7 @@ select_storage() { STORAGE_RESULT="${STORAGE_MAP[${MENU[0]}]}" return 0 fi - local selected_display=$(whiptail --backtitle "$WHIPTITLE" --title "STANCE" --radiolist "Select Storage Pool:" 16 60 6 "${MENU[@]}" 3>&1 1>&2 2>&3) + local selected_display=$(whiptail --backtitle "$WHIPTITLE" --title "STORAGE" --radiolist "Select Storage Pool:" 16 60 6 "${MENU[@]}" 3>&1 1>&2 2>&3) STORAGE_RESULT="${STORAGE_MAP[$selected_display]}" } @@ -268,7 +270,7 @@ advanced_settings() { while [[ $STEP -le $MAX_STEP ]]; do case $STEP in 1) if result=$(whiptail --backtitle "$WHIPTITLE" --title "PRIVILEGES" --radiolist "Select Container Type:" 12 58 2 "1" "LXC (Unprivileged)" ON "0" "LXC (Privileged)" OFF 3>&1 1>&2 2>&3); then CT_TYPE="$result"; STEP=$((STEP + 1)); else exit_script; fi ;; - 2) if result=$(whiptail --backtitle "$WHIPTITLE" --title "OS SELECTION" --radiolist "Select OS:" 12 58 3 "debian" "Debian 12" ON "alpine" "Alpine 3.20" OFF "ubuntu" "Ubuntu 24.04" OFF 3>&1 1>&2 2>&3); then OS_CHOICE="$result"; STEP=$((STEP + 1)); else STEP=$((STEP - 1)); fi ;; + 2) if result=$(whiptail --backtitle "$WHIPTITLE" --title "OS SELECTION" --radiolist "Select OS:" 12 58 6 "debian" "Debian 12 (Recommended)" ON "debian13" "Debian 13 (Recommended)" OFF "alpine" "Alpine 3.20" OFF "ubuntu" "Ubuntu 24.04" OFF "fedora" "Fedora 40" OFF "centos" "CentOS Stream 9" OFF 3>&1 1>&2 2>&3); then OS_CHOICE="$result"; STEP=$((STEP + 1)); else STEP=$((STEP - 1)); fi ;; 3) if result=$(whiptail --backtitle "$WHIPTITLE" --title "PASSWORD" --passwordbox "Root Password (Blank for Auto-Auth):" 12 58 3>&1 1>&2 2>&3); then if [[ -n "$result" ]]; then PW="--password $result"; else PW=""; fi; STEP=$((STEP + 1)); else STEP=$((STEP - 1)); fi ;; 4) if whiptail --backtitle "$WHIPTITLE" --title "VPN CAPABILITY" --yesno "Enable TUN/TAP (/dev/net/tun) for VPN interfaces?" 10 58; then ENABLE_TUN="1"; else ENABLE_TUN="0"; fi; STEP=$((STEP + 1)) ;; 5) if whiptail --backtitle "$WHIPTITLE" --title "SSH ACCESS" --yesno "Enable Root SSH Access?" 10 58; then ENABLE_SSH="1"; else ENABLE_SSH="0"; fi; STEP=$((STEP + 1)) ;; @@ -288,8 +290,11 @@ advanced_settings() { build_container() { if [[ "$OS_CHOICE" == "debian" ]]; then OS_VERSION="12"; fi + if [[ "$OS_CHOICE" == "debian13" ]]; then OS_CHOICE="debian"; OS_VERSION="13"; fi if [[ "$OS_CHOICE" == "alpine" ]]; then OS_VERSION="3.20"; fi if [[ "$OS_CHOICE" == "ubuntu" ]]; then OS_VERSION="24.04"; fi + if [[ "$OS_CHOICE" == "fedora" ]]; then OS_VERSION="40"; fi + if [[ "$OS_CHOICE" == "centos" ]]; then OS_VERSION="9"; fi msg_info "Locating Files for $OS_CHOICE" local template_search="${OS_CHOICE}-${OS_VERSION}" @@ -334,13 +339,15 @@ build_container() { pct start "$CT_ID" msg_info "Awaiting Network ..." - sleep 3 - IP=$(pct exec "$CT_ID" ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n1) + sleep 10 + IP=$(pct exec "$CT_ID" -- ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n1) if [[ "$ENABLE_SSH" == "1" ]]; then msg_info "Enabling Secure Shell (SSH)..." if [[ "$OS_CHOICE" == "alpine" ]]; then pct exec "$CT_ID" -- sh -c "apk add openssh && rc-update add sshd && service sshd start && sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && service sshd restart" >/dev/null 2>&1 + elif [[ "$OS_CHOICE" == "fedora" || "$OS_CHOICE" == "centos" ]]; then + pct exec "$CT_ID" -- sh -c "dnf install -y openssh-server && systemctl enable sshd && systemctl start sshd && sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && systemctl restart sshd" >/dev/null 2>&1 else pct exec "$CT_ID" -- sh -c "apt-get update >/dev/null 2>&1 && apt-get install -y openssh-server >/dev/null 2>&1 && sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config && systemctl restart sshd" >/dev/null 2>&1 fi @@ -348,7 +355,7 @@ build_container() { } echo_default() { - msg_info "Deploying with Defaults for ${GOLD}${app_name}${NC}:" + msg_info "Deploying with Defaults for ${GOLD}${APP}${NC}:" echo -e " ${BLUE}OS Version:${NC} ${GOLD}${OS_CHOICE} ${OS_VERSION}${NC}" echo -e " ${BLUE}Resources:${NC} ${GOLD}${CORE_COUNT} Cores, ${RAM_SIZE}MB RAM, ${DISK_SIZE}GB Storage${NC}" echo -e " ${BLUE}Network:${NC} ${GOLD}${NET} on ${BRG}${NC}" @@ -369,6 +376,7 @@ description() { if [[ "$ENABLE_SSH" == "1" ]]; then echo -e " ${BLUE}SSH :${NC} ${GOLD}ssh root@${IP}${NC}" fi + echo -e " ${BLUE}ID & Name:${NC} ${GOLD}LXC ${CT_ID} (${HN})${NC}" echo -e " ${BLUE}Log Path:${NC} ${GOLD}${INSTALL_LOG}${NC}" echo -e "${GOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" }