#!/bin/bash #********************************************************************************************************* #* __ __ __ ______ __ __ _______ _______ * #* | |--.| |.---.-..----.| |--.| __ \.---.-..-----.| |_| |--..-----..----. | | __| * #* | _ || || _ || __|| < | __/| _ || || _| || -__|| _| | - |__ | * #* |_____||__||___._||____||__|__||___| |___._||__|__||____|__|__||_____||__| |_______|_______| * #* http://www.blackpantheros.eu | http://www.blackpanther.hu - kbarcza[]blackpanther.hu * Charles Barcza * #*************************************************************************************(c)2002-2026******** #Hello blackPanther USER! #linux-userspace-headers contains the headers for the source code of #Linux kernel. All source code necessary to compile a new kernel is #included in two packages linux-userspace-headers, and kernel-source. #You will need to install both linux-userspace-headers (needed for #general Linux compilation), and kernel-source in order to compile #a new kernel. #The kernel is the central process of your Linux machine, the mediator #between the hardware and your programs. It is responsible for memory #allocations, process managing, device access... #Although modern kernels are very flexible thanks to dynamic modules, you #may need to compile your own kernel for various reasons: your found a #new module which need a more recent kernel, you need a feature of a new #kernel, etc... #Here is a short sum-up of what you can find in the Kernel-HOWTO. Consult #it in case of a problem or if the shortcut here provided does not meet #your needs. You should also consult the README of kernel-sources. # ## MORE INFO : www.blackpanther.hu set -euo pipefail DEBUG=0 DEBUG_LOG="/tmp/kernel-manager-debug.log" URL="https://ftp.blackpanther.hu/blackPanther/OS/All/Seeker/kernel/latest-kernel.info" TMP_FILE="/tmp/latest-kernel.info.$$" WORKDIR="/tmp/kernel-install.$$" SCRIPTNAME=`basename $0` SCRIPTPATH=$(pwd) SCRIPTDIR=${SCRIPTPATH%%$SCRIPTNAME} linux_logo [ ! -n "$(lsb_release -si | grep -i 'ckp')" ]&& exit 0 if [ "$DEBUG" -eq 1 ]; then exec 19>"$DEBUG_LOG" BASH_XTRACEFD=19 set -x fi log() { if [ "$DEBUG" -eq 1 ];then echo "[DEBUG] $*" >&19 fi } trap 'rm -f "$TMP_FILE"; rm -rf "$WORKDIR"' EXIT ### ===== CHECKS ===== for cmd in dialog wget rpm; do command -v "$cmd" >/dev/null || { echo "Hiányzó: $cmd"; exit 1; } done ### ===== INTERNET CHECK ===== if ! wget -q --spider "$URL"; then dialog --msgbox "Nincs internet kapcsolat!" 8 40 exit 1 fi ### ===== DOWNLOAD LIST ===== wget -q -O "$TMP_FILE" "$URL" mapfile -t KERNEL_LINES < <(grep -E 'kernel-power(-devel)?-.*\.rpm' "$TMP_FILE") [ ${#KERNEL_LINES[@]} -eq 0 ] && { dialog --msgbox "Nincs kernel lista!" 8 40 exit 1 } ### ===== VERSION EXTRACT ===== extract_ver() { local fname="$1" fname=${fname#kernel-power-devel-} fname=${fname#kernel-power-} fname=${fname%.x86_64.rpm} echo "$fname" } ### ===== VERSION LIST ===== declare -A VERSIONS for line in "${KERNEL_LINES[@]}"; do fname=$(basename "$line") ver=$(extract_ver "$fname") VERSIONS["$ver"]=1 done mapfile -t SORTED_VERSIONS < <(printf "%s\n" "${!VERSIONS[@]}" | sort -V) ### ===== INSTALLED KERNELS ===== INSTALLED_KERNELS=() for f in /boot/vmlinuz-[0-9]*; do [ -e "$f" ] || continue k=$(basename "$f") base=${k#vmlinuz-} ver=${base%-power-*} rel=${base##*-power-} INSTALLED_KERNELS+=("${ver}-${rel}") done log "INSTALLED: ${INSTALLED_KERNELS[*]}" is_installed() { local v="$1" for i in "${INSTALLED_KERNELS[@]}"; do [[ "$i" == "$v" ]] && return 0 done return 1 } ### ===== MENU ===== MENU_ITEMS=() for v in "${SORTED_VERSIONS[@]}"; do if is_installed "$v"; then MENU_ITEMS+=("$v" "[installed]") else MENU_ITEMS+=("$v" "") fi done CHOICE=$(dialog \ --title "Kernel Forge Terminál" \ --menu "Válassz egy blackPanther rendszermag verziót:" \ 20 70 12 \ "${MENU_ITEMS[@]}" \ 2>&1 >/dev/tty) RET=$? clear [ $RET -ne 0 ] && exit 0 log "CHOICE=$CHOICE" ### ===== REMOVE MODE ===== if is_installed "$CHOICE"; then COUNT=${#INSTALLED_KERNELS[@]} if [ "$COUNT" -le 1 ]; then dialog --msgbox "Ez az utolsó kernel, nem távolítható el!" 8 50 exit 1 fi dialog --yesno "Eltávolítod a(z) $CHOICE kernelt és devel csomagot?" 10 60 RET=$? if [ "$RET" != "0" ];then exec $SCRIPTDIR/$SCRIPTNAME fi rpm -e --nodeps "kernel-power-$CHOICE" 2>/dev/null || true rpm -e --nodeps "kernel-power-devel-$CHOICE" 2>/dev/null || true REM=$? if [ "$REM" -eq 0 ];then dialog --msgbox "Hiba történt az eltávolításkor!$RET" 8 40 else dialog --msgbox "Kernel eltávolítva!" 8 40 fi exec $SCRIPTDIR/$SCRIPTNAME exit 0 fi ### ===== INSTALL MODE ===== SELECTED=() for line in "${KERNEL_LINES[@]}"; do fname=$(basename "$line") ver=$(extract_ver "$fname") [[ "$ver" == "$CHOICE" ]] && SELECTED+=("$line") done POWER="" DEVEL="" for url in "${SELECTED[@]}"; do fname=$(basename "$url") case "$fname" in kernel-power-devel-*) DEVEL="$url" ;; kernel-power-[0-9]*) POWER="$url" ;; esac done [ -z "$POWER" ] && { dialog --msgbox "Hiányzó kernel-power!" 8 40 exit 1 } download_with_progress() { local url="$1" local file=$(basename "$url") wget -c --quiet --show-progress --progress=bar:force:noscroll "$url" 2>&1 \ | stdbuf -oL tr '\r' '\n' \ | grep --line-buffered -o '[0-9]\+%' \ | stdbuf -oL tr -d '%' \ | dialog --title "Letöltés: $file" \ --gauge "Fájl letöltése folyamatban..." 10 70 0 } mkdir -p "$WORKDIR" cd "$WORKDIR" download_with_progress "$POWER" if [[ -n "$DEVEL" ]]; then download_with_progress "$DEVEL" fi RPM_LIST=() RPM_LIST+=("$(basename "$POWER")") [ -n "$DEVEL" ] && RPM_LIST+=("$(basename "$DEVEL")") if ! dialog --yesno "Telepítés?\n\n$(printf "%s\n" "${RPM_LIST[@]}")" 15 60; then clear #return 0 exec $SCRIPTDIR/$SCRIPTNAME fi clear set +e rpm -ivh --nodeps --force "${RPM_LIST[@]}" 2>&1 | tee /tmp/rpm.log IN=$? set -e if [ "$IN" -eq 0 ]; then dialog --msgbox "Kernel telepítve! Újra kell indítani a gépet..." 8 40 else dialog --msgbox "Hiba történt a telepítés során!" 8 60 dialog --textbox /tmp/rpm.log 20 80 exec $SCRIPTDIR/$SCRIPTNAME fi