Created
March 18, 2025 15:18
-
-
Save Welpyes/937bd05fb9d156b701b1abfa1ae4385b to your computer and use it in GitHub Desktop.
pseudo systemd like bootloader script for termux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # **NOTE** | |
| # This is just the bootloader startup script, | |
| # if you want to get a log in script | |
| # for proot-distro i recommend visiting this repo | |
| # https://github.com/LinuxDroidMaster/Termux-Desktops/ | |
| # Global Variables | |
| SCRIPT="$HOME/fedora.sh" | |
| TIMEOUT=5 | |
| SCRIPT_DELAY=1 | |
| DISTRO="Fedora Linux (aarch64)" | |
| PD="fedora" | |
| # Terminal setup | |
| COLUMNS=$(tput cols) | |
| LINES=$(tput lines) | |
| HIGHLIGHT=$(tput smso) | |
| GREEN=$(tput setaf 2) | |
| RED=$(tput setaf 1) | |
| RESET=$(tput sgr0) | |
| BOLD=$(tput bold) | |
| # horizontally centering prompt function | |
| center_text() { | |
| local text="$1" | |
| local clean_text=$(echo -e "$text" | sed 's/\x1B\[[0-9;]*m//g') | |
| local len=${#clean_text} | |
| local padding=$(( (COLUMNS - len) / 2 )) | |
| printf "%${padding}s%s\n" "" "$text" | |
| } | |
| # pseudo linux services startup | |
| start_service() { | |
| local service="$1" | |
| local delay=${2:-0.2} # default delay in seconds | |
| local status=$(( RANDOM % 10 )) # randomized failed chance | |
| printf "Starting %-40s" "$service..." | |
| sleep "$delay" # Simulate processing time | |
| if [ "$status" -eq 0 ]; then | |
| echo -e "[ ${RED}FAILED${RESET} ]" | |
| return 1 | |
| else | |
| echo -e "[ ${GREEN}OK${RESET} ]" | |
| return 0 | |
| fi | |
| } | |
| # Menu options | |
| OPTIONS=( | |
| "${DISTRO}" | |
| "${DISTRO} Root Shell(fallback)" | |
| "Turn off Computer" | |
| ) | |
| # Calculate menu height | |
| MENU_HEIGHT=11 | |
| TOP_PADDING=$(( (LINES - MENU_HEIGHT) / 2 )) | |
| # Clear screen and add vertical padding | |
| clear | |
| for ((i=1; i<=TOP_PADDING; i++)); do | |
| echo "" | |
| done | |
| # Draw the centered menu | |
| center_text "${BOLD}Boot Menu${RESET}" | |
| center_text "==============" | |
| center_text " " | |
| # Display options, highlight the default (1) | |
| for i in "${!OPTIONS[@]}"; do | |
| if [ $i -eq 0 ]; then | |
| center_text "${HIGHLIGHT}${OPTIONS[$i]}${RESET}" | |
| else | |
| center_text "${OPTIONS[$i]}" | |
| fi | |
| done | |
| center_text " " | |
| center_text "Select an option (1-3) within ${TIMEOUT}s [default: 1]" | |
| center_text "==============" | |
| # Read input with timeout | |
| read -t "$TIMEOUT" -p "$(center_text "Choice: ")" choice | |
| # Function to run the startup sequence | |
| run_startup() { | |
| clear | |
| echo "Welcome to ${DISTRO}" | |
| echo "Booting system..." | |
| echo "----------------------------------------" | |
| sleep 1 | |
| # Services list (add more if you like) | |
| SERVICES=( | |
| "kernel modules" | |
| "network interfaces" | |
| "mounting filesystems" | |
| "udev device manager" | |
| "system clock synchronization" | |
| "dbus service" | |
| "ssh daemon" | |
| "cron scheduler" | |
| "pulseaudio sound server" | |
| "graphical target" | |
| "syslog daemon" | |
| "firewalld service" | |
| "bluetooth daemon" | |
| "avahi mDNS/DNS-SD stack" | |
| "cups printing service" | |
| "apparmor profiles" | |
| "selinux policy enforcement" | |
| "rngd entropy daemon" | |
| "lvm volume activation" | |
| "swap space initialization" | |
| "auditd logging service" | |
| "postfix mail server" | |
| "network manager" | |
| "gdm display manager" | |
| "docker container runtime" | |
| "systemd-tmpfiles setup" | |
| "plymouth boot splash" | |
| "smartd disk monitoring" | |
| "rsyslog logging service" | |
| "acpid power management" | |
| "chronyd time service" | |
| "sssd authentication service" | |
| "polkit authorization service" | |
| "laptop-mode tools" | |
| "irqbalance daemon" | |
| "systemd-oomd out-of-memory daemon" | |
| "anacron scheduler" | |
| "dmraid device mapper" | |
| "fstrim SSD trimming" | |
| "systemd-backlight service" | |
| "systemd-resolved DNS resolver" | |
| "openvpn service" | |
| "rpcbind NFS service" | |
| "zfs filesystem support" | |
| "snapd service" | |
| "thermald thermal daemon" | |
| "ufw firewall" | |
| "fail2ban intrusion prevention" | |
| "systemd-networkd network service" | |
| "power-profiles-daemon" | |
| ) | |
| # Simulate service startup | |
| for service in "${SERVICES[@]}"; do | |
| start_service "$service" "$(printf "0.%d" $(( RANDOM % 3 + 1 )))" # Random delay between 0.1 and 0.3s | |
| done | |
| echo "----------------------------------------" | |
| sleep 1 | |
| echo -e "${GREEN}System boot completed.${RESET}" | |
| echo "Opening Display..." | |
| clear | |
| } | |
| # Process choice, default to 1 | |
| case "${choice:-1}" in | |
| 1) | |
| clear | |
| center_text "Booting: ${OPTIONS[0]}..." | |
| sleep 1 # Mimic boot delay | |
| (sleep "$SCRIPT_DELAY" && bash "$SCRIPT" > /dev/null 2>&1) & | |
| run_startup | |
| ;; | |
| 2) | |
| clear | |
| center_text "Logging in ${DISTRO} Shell..." | |
| pd sh ${PD} | |
| # wpd -d fedora # wpd is a proot-distro wrapper that i made | |
| sleep 1 | |
| ;; | |
| 3) | |
| clear | |
| center_text "Shutting down Computer..." | |
| sleep 1 | |
| pkill -f termux # Close Termux forced | |
| ;; | |
| *) | |
| clear | |
| center_text "Invalid option, defaulting to ${OPTIONS[0]}..." | |
| sleep 1 | |
| (sleep "$SCRIPT_DELAY" && bash "$SCRIPT" > /dev/null 2>&1) & | |
| run_startup | |
| ;; | |
| esac | |
| clear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment