Instantly share code, notes, and snippets.
Created
August 12, 2024 19:22
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save Mintedshrimp/42d0e3f0347737dfdcb110b957ac120f to your computer and use it in GitHub Desktop.
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 | |
# Define color codes | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
BLUE='\033[0;34m' | |
CYAN='\033[0;36m' | |
RESET='\033[0m' # Reset to default color | |
# Clear the terminal | |
clear | |
# Display the menu | |
printf "${CYAN}╭─░▒▓ PROOT MENU ▓▒░${RESET}\n" | |
printf "${CYAN}│${RESET}\n" | |
printf "${CYAN}│ 1. Install Custom Proot${RESET}\n" | |
printf "${CYAN}│ 2. Login Proot Distro${RESET}\n" | |
printf "${CYAN}│ 3. Remove Distro${RESET}\n" | |
printf "${CYAN}│ 4. Exit${RESET}\n" | |
printf "${CYAN}│${RESET}\n" | |
printf "${CYAN}╰─${RESET}\n" | |
# Prompt for user choice | |
read -p "🔍 Enter your choice (1-4): " choice | |
case $choice in | |
1) | |
printf "${YELLOW}🔧 Installing custom Proot...${RESET}\n" | |
mkdir -p ~/.proot | |
# Check if wget-proot.sh is already installed | |
if [ -f ~/.proot/wget-proot.sh ]; then | |
printf "${GREEN}📜 wget-proot.sh is already installed.${RESET}\n" | |
printf "${YELLOW}🔄 Running wget-proot.sh...${RESET}\n" | |
bash ~/.proot/wget-proot.sh | |
else | |
# Download the custom Proot installer script | |
printf "${YELLOW}📥 Downloading wget-proot.sh...${RESET}\n" | |
curl -s https://raw.githubusercontent.com/23xvx/Termux-Proot-Custom-Installer/main/wget-proot.sh -o ~/.proot/wget-proot.sh | |
bash ~/.proot/wget-proot.sh | |
fi | |
# Move the latest .sh file to .proot | |
latest_sh_file=$(ls -t ~/*.sh 2>/dev/null | head -n 1) | |
if [ -n "$latest_sh_file" ]; then | |
mv -f "$latest_sh_file" ~/.proot/ | |
printf "${GREEN}✅ Moved $latest_sh_file to ~/.proot directory.${RESET}\n" | |
else | |
printf "${YELLOW}⚠️ No .sh files found in the home directory to move.${RESET}\n" | |
fi | |
# Move the latest directory to .proot | |
latest_dir=$(ls -dt ~/[^.]* 2>/dev/null | head -n 1) | |
if [ -n "$latest_dir" ]; then | |
mv -f "$latest_dir" ~/.proot/ | |
printf "${GREEN}✅ Moved $latest_dir to ~/.proot directory.${RESET}\n" | |
else | |
printf "${YELLOW}⚠️ No directories found in the home directory to move.${RESET}\n" | |
fi | |
printf "${CYAN}📜 The custom Proot installer script is stored in ~/.proot directory.${RESET}\n" | |
;; | |
2) | |
printf "${YELLOW}🔑 Logging in to Proot distro...${RESET}\n" | |
cd ~/.proot || { printf "${RED}Directory not found${RESET}\n"; exit 1; } | |
printf "${BLUE}📁 Available files in ~/.proot:${RESET}\n" | |
# List files in the .proot directory | |
PS3="Please select a file to execute: " | |
select file in *; do | |
if [[ -n "$file" ]]; then | |
printf "${GREEN}▶️ Executing $file...${RESET}\n" | |
bash "$file" | |
break | |
else | |
printf "${RED}❌ Invalid selection. Please try again.${RESET}\n" | |
fi | |
done | |
;; | |
3) | |
printf "${YELLOW}🗑️ Removing Proot distro...${RESET}\n" | |
printf "${BLUE}Where do you want to list files for removal?${RESET}\n" | |
printf "${CYAN}1. From ~/.proot${RESET}\n" | |
printf "${CYAN}2. From ~${RESET}\n" | |
read -p "🔍 Enter your choice (1-2): " remove_choice | |
case $remove_choice in | |
1) | |
cd ~/.proot || { printf "${RED}Directory not found${RESET}\n"; exit 1; } | |
printf "${BLUE}📁 Available files in ~/.proot for removal:${RESET}\n" | |
ls | |
PS3="Please select a file or directory to remove: " | |
select file in *; do | |
if [[ -n "$file" ]]; then | |
printf "${YELLOW}🛑 Are you sure you want to remove $file? (y/n)${RESET}\n" | |
read -p "🔄 Your choice: " confirm | |
if [[ "$confirm" == "y" ]]; then | |
rm -rf "$file" | |
printf "${GREEN}✅ $file has been removed.${RESET}\n" | |
else | |
printf "${RED}❌ Removal canceled.${RESET}\n" | |
fi | |
break | |
else | |
printf "${RED}❌ Invalid selection. Please try again.${RESET}\n" | |
fi | |
done | |
;; | |
2) | |
cd ~ || { printf "${RED}Directory not found${RESET}\n"; exit 1; } | |
printf "${BLUE}📁 Available files in ~ for removal:${RESET}\n" | |
ls | |
PS3="Please select a file or directory to remove: " | |
select file in *; do | |
if [[ -n "$file" ]]; then | |
printf "${YELLOW}🛑 Are you sure you want to remove $file? (y/n)${RESET}\n" | |
read -p "🔄 Your choice: " confirm | |
if [[ "$confirm" == "y" ]]; then | |
rm -rf "$file" | |
printf "${GREEN}✅ $file has been removed.${RESET}\n" | |
else | |
printf "${RED}❌ Removal canceled.${RESET}\n" | |
fi | |
break | |
else | |
printf "${RED}❌ Invalid selection. Please try again.${RESET}\n" | |
fi | |
done | |
;; | |
*) | |
printf "${RED}❌ Invalid choice. Please try again.${RESET}\n" | |
;; | |
esac | |
;; | |
4) | |
printf "${CYAN}👋 Exiting Proot menu...${RESET}\n" | |
exit 0 | |
;; | |
*) | |
printf "${RED}❌ Invalid choice. Please try again.${RESET}\n" | |
;; | |
esac | |
echo | |
read -p "🔄 Press Enter to continue..." | |
clear | |
exec bash "$0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment