diff --git a/dis.sh b/dis.sh index 34d679a..af403a0 100644 --- a/dis.sh +++ b/dis.sh @@ -19,24 +19,61 @@ check_root() { fi } +download_discord_file() { + local url="https://discord.com/api/download?platform=linux&format=tar.gz" + local output_file="discord.tar.gz" + + if command -v curl > /dev/null; then + print_color "RED" "Using curl to download the file from https://discord.com..." + curl -L -o "$output_file" "$url" + elif command -v wget > /dev/null; then + print_color "RED" "Using wget to download the file from https://discord.com..." + wget -O "$output_file" "$url" + else + print_color "RED" "Error: Neither curl nor wget is installed." + return 1 + fi + + print_color "GREEN" "Download completed: $output_file" + DISCORD_ARCHIVE="$output_file" +} + get_discord_archive() { - while true; do - if [ -n "$1" ] && [ -f "$1" ]; then - DISCORD_ARCHIVE="$1" - break - else - read -p "Enter the path to the Discord archive (e.g., /path/to/discord.tar.gz): " DISCORD_ARCHIVE - if [ -f "$DISCORD_ARCHIVE" ]; then - break - else - print_color "YELLOW" "File not found. Please try again." - fi - fi + print_color "YELLOW" "Would you like to provide a path to the Discord archive or download it?" + PS3="Please select an option (1-2): " + options=("Provide a file path" "Download Discord.tar.gz") + select opt in "${options[@]}" + do + case "$opt" in + "Provide a file path") + while true; do + if [ -n "$1" ] && [ -f "$1" ]; then + DISCORD_ARCHIVE="$1" + break + else + read -p "Enter the path to the Discord archive (e.g., /path/to/discord.tar.gz): " DISCORD_ARCHIVE + if [ -f "$DISCORD_ARCHIVE" ]; then + break 2 + else + print_color "YELLOW" "File not found. Please try again." + fi + fi + done + ;; + "Download Discord.tar.gz") + download_discord_file + break 2 + ;; + + *) + print_color "RED" "Invalid option $REPLY" + ;; + esac done } install_discord() { - print_color "GREEN" "Starting Discord installation..." + print_color "GREEN" "Starting Discord installation..." # Create temporary and installation directories print_color "YELLOW" "Creating directories..." mkdir -p /opt/discord @@ -46,7 +83,7 @@ install_discord() { tar -xzvf "$DISCORD_ARCHIVE" -C temp_discord || { print_color "RED" "Failed to extract Discord archive."; exit 1; } # Move contents to installation directory print_color "YELLOW" "Moving files to installation directory..." - mv temp_discord/Discord/* /opt/discord/ || { print_color "RED" "Failed to move Discord files."; exit 1; } + mv temp_discord/Discord/* /opt/discord/ || { print_color "RED" "Failed to move Discord files."; rm -rf temp_discord && exit 1; } # Clean up temporary directory rm -rf temp_discord # Create symlink @@ -116,7 +153,7 @@ main() { break ;; "Exit") - print_color "GREEN" "Thank you for using Discord Manager. Goodbye!" + print_color "GREEN" "Thank you for using Discord installer Script. Goodbye!" exit 0 ;; *)