Skip to content

Commit

Permalink
Merge pull request #965 from plexguide/tweaks1
Browse files Browse the repository at this point in the history
Tweaks1
  • Loading branch information
Admin9705 authored Sep 26, 2024
2 parents 80c032f + 34e6a5d commit 3c0f13b
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 59 deletions.
2 changes: 1 addition & 1 deletion mods/scripts/apps/config_menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ validate_or_create_path() {
# Function to check Docker container status
check_deployment_status() {
docker ps --filter "name=^/${app_name}$" --format "{{.Names}}" | grep -q "^${app_name}$" && \
echo -e "${GREEN}[Deployed]${NC}" || echo -e "${RED}[Not Deployed]${NC}"
echo -e "${GREEN}${BOLD}[Deployed]${NC}" || echo -e "${RED}${BOLD}[Not Deployed]${NC}"
}

# Function to prompt and change the port number
Expand Down
19 changes: 2 additions & 17 deletions mods/scripts/apps/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ appsourcing() {
fi
}

# Function to source configuration from the config file
#configsource() {
# if [[ "$config_type" == "personal" ]]; then
# config_path="/pg/personal_configs/${app_name}.cfg"
# else
# config_path="/pg/config/${app_name}.cfg"
# fi
#
# if [ -f "$config_path" ]; then
# source "$config_path"
# else
# echo "Config file for ${app_name} not found at ${config_path}."
# exit 1
# fi
#}

# Function: Deploys / Redploys App
redeploy_app() {
# Check if lspci is installed; detect NVIDIA graphics cards
Expand Down Expand Up @@ -147,6 +131,7 @@ while true; do
echo "Operation exited."
break
else
echo "" && echo "Invalid choice. Please try again." && echo ""
echo ""
read -p "${RED}Invalid Choice. Press [ENTER] to continue${NC}"
fi
done
7 changes: 4 additions & 3 deletions mods/scripts/apps/interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
NC="\033[0m" # No color
BOLD="\033[1m"

# Source the defaults script
source /pg/scripts/apps/defaults.sh
Expand Down Expand Up @@ -39,13 +40,13 @@ check_deployment_status() {
local container_status=$(docker ps --filter "name=^/${app_name}$" --format "{{.Names}}")

if [[ "$container_status" == "$app_name" ]]; then
echo -e "${GREEN}[Deployed]${NC} $app_name - Port: $port_number/$port_status"
echo -e "${GREEN}${BOLD}[Deployed]${NC} $app_name - Port: $port_number/$port_status"
else
# App is not deployed, show potential port status if deployed
if [[ "$port_status" == "Closed" ]]; then
echo -e "${RED}[Not Deployed]${NC} $app_name - Port Closed if Deployed"
echo -e "${RED}${BOLD}[Not Deployed]${NC} $app_name - Port Closed if Deployed"
else
echo -e "${RED}[Not Deployed]${NC} $app_name - Port Open if Deployed"
echo -e "${RED}${BOLD}[Not Deployed]${NC} $app_name - Port Open if Deployed"
fi
fi
}
Expand Down
20 changes: 9 additions & 11 deletions mods/scripts/apps/running.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ GREEN="\033[0;32m"
RED="\033[0;31m"
BLUE="\033[0;34m"
ORANGE="\033[0;33m"
CYAN="\033[0;36m"
NC="\033[0m" # No color
BOLD="\033[1m"

# Clear the screen at the start
clear
Expand Down Expand Up @@ -84,43 +86,39 @@ running_function() {
# Get the list of running Docker apps that match .app files
APP_LIST=($(list_running_docker_apps))

# Exits interface if there are no apps running
if [[ ${#APP_LIST[@]} -eq 0 ]]; then
clear
echo -e "${RED}Cannot View/Edit Apps as None Exist.${NC}"
echo "" # Blank line for separation
read -p "$(echo -e "${RED}Press Enter to continue...${NC}")"
exit 0
fi

echo -e "${RED}PG: Running Apps [View | Edit]${NC}"
echo -e "${CYAN}${BOLD}PG Running Apps${NC}"
echo "" # Blank line for separation

# Display the list of running Docker apps that match the selected type
display_running_apps "${APP_LIST[@]}"

echo "════════════════════════════════════════════════════════════════════════════════"
# Prompt the user to enter an app name or exit
read -p "$(echo -e "Type [${GREEN}App${NC}] to View/Edit or [${RED}Exit${NC}]: ")" app_choice
read -p "$(echo -e "Type [${RED}${BOLD}App${NC}] to View/Edit or [${GREEN}${BOLD}Z${NC}] to exit > ")" app_choice

# Convert the user input to lowercase for case-insensitive matching
app_choice=$(echo "$app_choice" | tr '[:upper:]' '[:lower:]')

# Check if the user wants to exit
if [[ "$app_choice" == "exit" ]]; then
if [[ "$app_choice" == "z" ]]; then
exit 0
fi

# Check if the app exists in the list of running Docker apps (case-insensitive)
if echo "${APP_LIST[@]}" | grep -i -w "$app_choice" >/dev/null; then
# Manage the selected app by calling the apps_interface script
manage_app "$app_choice"
exit 0
else
echo "Invalid choice. Please try again."
read -p "Press Enter to continue..."
echo ""
read -p "${RED}Invalid Choice. Press [ENTER] to continue${NC}"
fi
done
}

# Call the main running function
running_function
running_function
8 changes: 5 additions & 3 deletions mods/scripts/apps/stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ RED="\033[0;31m"
BLUE="\033[0;34m"
ORANGE="\033[0;33m"
NC="\033[0m" # No color
BOLD="\033[1m"
CYAN="\033[0;36m"

# Clear the screen at the start
clear
Expand Down Expand Up @@ -123,7 +125,7 @@ deployment_function() {

APP_LIST=($(list_available_apps))

echo -e "${RED}PG: Deployable Apps${NC}"
echo -e "${CYAN}${BOLD}PG Deployable Apps${NC}"
echo ""

if [[ ${#APP_LIST[@]} -eq 0 ]]; then
Expand All @@ -133,7 +135,7 @@ deployment_function() {
fi

echo "════════════════════════════════════════════════════════════════════════════════"
read -p "$(echo -e "Type [${RED}App${NC}] to Deploy or [${GREEN}Z${NC}] to Exit: ")" app_choice
read -p "$(echo -e "Type [${RED}${BOLD}App${NC}] to Deploy or [${GREEN}${BOLD}Z${NC}] to Exit > ")" app_choice

app_choice=$(echo "$app_choice" | tr '[:upper:]' '[:lower:]')

Expand All @@ -155,4 +157,4 @@ if [[ "$deployment_type" == "personal" || "$deployment_type" == "official" ]]; t
else
echo -e "${RED}Invalid deployment type specified. Use 'personal' or 'official'.${NC}"
exit 1
fi
fi
9 changes: 7 additions & 2 deletions mods/scripts/apps/starter_menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ main_menu() {

# Conditionally display other menu options only if appstore_version is not "None"
if [[ "$appstore_version" != "None" ]]; then
printf " B) Official: Manage [%d]\n" "$APP_COUNT"
# Only display option B) if there are official apps deployed (APP_COUNT > 0)
if [[ "$APP_COUNT" -gt 0 ]]; then
printf " B) Official: Manage [%d]\n" "$APP_COUNT"
fi

printf " C) Official: Deploy\n"
echo "" # Space for separation

Expand All @@ -160,7 +164,7 @@ main_menu() {
echo "" # Space between options and input prompt
echo -e "${WHITE}────────────────────────────────────────────────────${NC}"
# Display the prompt with colors and capture user input
echo -e "Make a Choice or [${GREEN}Z${NC}] to Exit >${NC} \c"
echo -e "Make a Choice or [${GREEN}${BOLD}Z${NC}] to Exit >${NC} \c"
read -r choice

case $choice in
Expand Down Expand Up @@ -216,5 +220,6 @@ main_menu() {
done
}


# Call the main menu function
main_menu
82 changes: 60 additions & 22 deletions mods/scripts/apps/version.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

# ANSI color codes for formatting
RED="\033[0;31m"
GREEN="\033[0;32m"
ORANGE="\033[0;33m"
BLUE="\033[0;34m"
# ANSI color codes for bold formatting
RED="\033[1;31m"
GREEN="\033[1;32m"
ORANGE="\033[1;33m" # Gold/Yellow
WHITE="\033[1;37m"
HOT_PINK="\033[1;35m" # Bold hot pink
NC="\033[0m" # No color

# Function to check and install unzip if not present
Expand Down Expand Up @@ -33,22 +34,26 @@ get_current_version() {
fi
}

# Function to display releases
# Function to display releases with Alpha in red, the first release in gold/yellow, and the rest in white
display_releases() {
local current_version="$1"
releases="$2"
echo -e "Apps Version Selector - [${GREEN}${current_version}${NC}]"
echo "NOTE: Visit https://github.com/plexguide/Apps/releases for Information"
echo ""

# Display Alpha option in bold red
echo -n -e "${RED}Alpha${NC} "
line_length=0

# Print the first release in gold/yellow and the rest in white
first_release=true
for release in $releases; do
if (( line_length + ${#release} + 1 > 80 )); then
echo ""
line_length=0
if $first_release; then
echo -n -e "${ORANGE}$release${NC} "
first_release=false
else
echo -n -e "${WHITE}$release${NC} "
fi
echo -n -e "${ORANGE}$release${NC} "
line_length=$((line_length + ${#release} + 1))
done
echo "" # New line after displaying all releases
}
Expand Down Expand Up @@ -158,6 +163,18 @@ update_config_version() {
echo "App Store version has been set to $selected_version in $config_file"
}

# Function to generate a random 4-digit PIN with no repeating digits
generate_random_pin() {
local pin=""
while [[ ${#pin} -lt 4 ]]; do
local digit=$((RANDOM % 10))
if [[ ! "$pin" =~ $digit ]]; then
pin+="$digit"
fi
done
echo "$pin"
}

# Main logic
while true; do
clear
Expand All @@ -173,32 +190,53 @@ while true; do
echo ""

# Prompt user with the updated question, using echo for colors
echo -e "Which Version to Install? (Type ${GREEN}[Z]${NC} to Exit): "
read -r selected_version
echo "════════════════════════════════════════════════════════════════════════════════"
read -p "$(echo -e "Type [${RED}${BOLD}Version${NC}] to download or [${GREEN}${BOLD}Z${NC}] to exit > ")" selected_version
echo ""

# Handle the user's input, including the exit option
if [[ "${selected_version,,}" == "z" ]]; then
echo "Installation canceled."
exit 0
elif [[ "${selected_version,,}" == "alpha" ]]; then
# Same PIN process for Alpha
echo "Alpha version selected."
handle_alpha_version # Call the function to handle the Alpha version
echo -e "\nAlpha version setup complete. [Press ENTER] to continue..."
read -r
exit 0
random_proceed_pin=$(generate_random_pin)
random_cancel_pin=$(generate_random_pin)

while true; do
echo ""
echo -e "To proceed, enter this PIN [${HOT_PINK}${random_proceed_pin}${NC}]"
echo -e "To cancel, enter this PIN [${GREEN}${random_cancel_pin}${NC}]"
read -p "Enter PIN > " response
if [[ "$response" == "$random_proceed_pin" ]]; then
handle_alpha_version # Proceed with Alpha version setup
echo -e "\nAlpha version setup complete. [Press ENTER] to continue..."
read -r
exit 0
elif [[ "$response" == "$random_cancel_pin" ]]; then
echo "Installation canceled."
exit 0
else
echo "Invalid input. Please try again."
fi
done
elif echo "$releases" | grep -q "^${selected_version}$"; then
echo "Valid version selected: $selected_version"
else
echo "Invalid version. Please select a valid version from the list."
continue
fi

random_pin=$(printf "%04d" $((RANDOM % 10000)))
random_proceed_pin=$(generate_random_pin)
random_cancel_pin=$(generate_random_pin)

while true; do
echo ""
read -p "$(echo -e "Type [${RED}${random_pin}${NC}] to proceed or [${GREEN}Z${NC}] to cancel: ")" response
if [[ "$response" == "$random_pin" ]]; then
echo -e "To proceed, enter this PIN [${HOT_PINK}${random_proceed_pin}${NC}]"
echo -e "To cancel, enter this PIN [${GREEN}${random_cancel_pin}${NC}]"
read -p "Enter PIN > " response
if [[ "$response" == "$random_proceed_pin" ]]; then
check_and_install_unzip
if download_and_extract "$selected_version"; then
update_config_version "$selected_version"
Expand All @@ -208,7 +246,7 @@ while true; do
else
echo "Error during download or extraction."
fi
elif [[ "${response,,}" == "z" ]]; then
elif [[ "$response" == "$random_cancel_pin" ]]; then
echo "Installation canceled."
exit 0
else
Expand Down

0 comments on commit 3c0f13b

Please sign in to comment.