Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from Ferks-FK/Update_Code
Browse files Browse the repository at this point in the history
Code Maintenance
  • Loading branch information
Ferks-FK authored Mar 3, 2022
2 parents 6616219 + 679f341 commit c30f302
Show file tree
Hide file tree
Showing 10 changed files with 798 additions and 1,118 deletions.
203 changes: 83 additions & 120 deletions addons/version1.x/Bigger_Console/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# shellcheck disable=SC2002
# shellcheck disable=SC2016
#shellcheck source=/dev/null

set -e
Expand All @@ -13,11 +15,20 @@ set -e
#
########################################################

#### Fixed Variables ####
# Get the latest version before running the script #
get_release() {
curl --silent \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/Ferks-FK/Pterodactyl-AutoAddons/releases/latest |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}

SCRIPT_VERSION="v3.0"
# Fixed Variables #
SCRIPT_VERSION="$(get_release)"
SUPPORT_LINK="https://discord.gg/buDBbSGJmQ"

# Update Variables #
update_variables() {
BIGGER_CONSOLE="$PTERO/resources/scripts/components/server/ServerConsole.tsx"
MORE_BUTTONS="$PTERO/resources/scripts/components/server/MoreButtons.tsx"
Expand All @@ -26,7 +37,7 @@ CONFIG_FILE="$PTERO/config/app.php"
PANEL_VERSION=$(cat "$CONFIG_FILE" | grep -n ^ | grep ^12: | cut -d: -f2 | cut -c18-23 | sed "s/'//g")
}


# Visual Functions #
print_brake() {
for ((n = 0; n < $1; n++)); do
echo -n "#"
Expand All @@ -35,28 +46,33 @@ print_brake() {
}

print_warning() {
COLOR_YELLOW='\033[1;33m'
COLOR_NC='\033[0m'
echo -e "* ${COLOR_YELLOW}WARNING${COLOR_NC}: $1"
echo
echo -e "* ${YELLOW}WARNING${RESET}: $1"
echo ""
}

print_error() {
echo ""
echo -e "* ${RED}ERROR${RESET}: $1"
echo ""
}

print() {
echo ""
echo -e "* ${GREEN}$1${RESET}"
echo ""
}

hyperlink() {
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
}


#### Colors ####

GREEN="\e[0;92m"
YELLOW="\033[1;33m"
red='\033[0;31m'
reset="\e[0m"


#### OS check ####
RED='\033[0;31m'
RESET="\e[0m"

# OS check #
check_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
Expand Down Expand Up @@ -87,14 +103,10 @@ check_distro() {
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
}

#### Find where pterodactyl is installed ####

# Find where pterodactyl is installed #
find_pterodactyl() {
echo
print_brake 47
echo -e "* ${GREEN}Looking for your pterodactyl installation...${reset}"
print_brake 47
echo
print "Looking for your pterodactyl installation..."

sleep 2
if [ -d "/var/www/pterodactyl" ]; then
PTERO_INSTALL=true
Expand All @@ -112,48 +124,23 @@ fi
update_variables
}

#### Verify Compatibility ####

# Verify Compatibility #
compatibility() {
echo
print_brake 57
echo -e "* ${GREEN}Checking if the addon is compatible with your panel...${reset}"
print_brake 57
echo
print "Checking if the addon is compatible with your panel..."

sleep 2
if [ -f "$CONFIG_FILE" ]; then
if [ "$PANEL_VERSION" == "1.6.6" ]; then
echo
print_brake 23
echo -e "* ${GREEN}Compatible Version!${reset}"
print_brake 23
echo
elif [ "$PANEL_VERSION" == "1.7.0" ]; then
echo
print_brake 23
echo -e "* ${GREEN}Compatible Version!${reset}"
print_brake 23
echo
else
echo
print_brake 24
echo -e "* ${red}Incompatible Version!${reset}"
print_brake 24
echo
exit 1
fi
if [ "$PANEL_VERSION" == "1.6.6" ] || [ "$PANEL_VERSION" == "1.7.0" ]; then
print "Compatible Version!"
else
print_error "Incompatible Version!"
exit 1
fi
}


#### Install Dependencies ####

# Install Dependencies #
dependencies() {
echo
print_brake 30
echo -e "* ${GREEN}Installing dependencies...${reset}"
print_brake 30
echo
print "Installing dependencies..."

case "$OS" in
debian | ubuntu)
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - && apt-get install -y nodejs
Expand All @@ -165,20 +152,12 @@ centos)
esac
}


#### Panel Backup ####

# Panel Backup #
backup() {
echo
print_brake 32
echo -e "* ${GREEN}Performing security backup...${reset}"
print_brake 32
if [ -d "$PTERO/PanelBackup[Auto-Addons]" ]; then
echo
print_brake 45
echo -e "* ${GREEN}There is already a backup, skipping step...${reset}"
print_brake 45
echo
print "Performing security backup..."

if [ -d "$PTERO/PanelBackup[Auto-Addons]" ]; then
print "There is already a backup, skipping step..."
else
cd "$PTERO"
if [ -d "$PTERO/node_modules" ]; then
Expand All @@ -193,34 +172,25 @@ print_brake 32
fi
}


#### Download Files ####

# Download Files #
download_files() {
echo
print_brake 25
echo -e "* ${GREEN}Downloading files...${reset}"
print_brake 25
echo
print "Downloading files..."

cd "$PTERO"
mkdir -p temp
cd temp
curl -sSLo Bigger_Console.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoAddons/${SCRIPT_VERSION}/addons/version1.x/Bigger_Console/Bigger_Console.tar.gz
curl -sSLo Bigger_Console.tar.gz https://raw.githubusercontent.com/Ferks-FK/Pterodactyl-AutoAddons/"${SCRIPT_VERSION}"/addons/version1.x/Bigger_Console/Bigger_Console.tar.gz
tar -xzvf Bigger_Console.tar.gz
cd Bigger_Console
cp -rf -- * "$PTERO"
cd "$PTERO"
rm -r temp
}


#### Check if it is already installed ####

# Check if it is already installed #
verify_installation() {
if grep '<div css={tw`rounded bg-yellow-500 p-3`}>' "$BIGGER_CONSOLE" &>/dev/null; then
print_brake 61
echo -e "* ${red}This addon is already installed in your panel, aborting...${reset}"
print_brake 61
print_error "This addon is already installed in your panel, aborting..."
exit 1
else
dependencies
Expand All @@ -231,40 +201,29 @@ if grep '<div css={tw`rounded bg-yellow-500 p-3`}>' "$BIGGER_CONSOLE" &>/dev/nul
fi
}

#### Check if another conflicting addon is installed ####

# Check if another conflicting addon is installed #
check_conflict() {
echo
print_brake 66
echo -e "* ${GREEN}Checking if a similar/conflicting addon is already installed...${reset}"
print_brake 66
echo
print "Checking if a similar/conflicting addon is already installed..."

sleep 2
if [ -f "$MORE_BUTTONS" ]; then
echo
print_brake 70
echo -e "* ${red}The addon ${YELLOW}More Buttons ${red}is already installed, aborting...${reset}"
print_brake 70
echo -e "* ${RED}The addon ${YELLOW}More Buttons ${RED}is already installed, aborting...${RESET}"
echo
exit 1
elif [ -f "$MC_PASTE" ]; then
echo
print_brake 55
echo -e "* ${red}The addon ${YELLOW}MC Paste ${red}is already installed, aborting...${reset}"
print_brake 55
echo -e "* ${RED}The addon ${YELLOW}MC Paste ${RED}is already installed, aborting...${RESET}"
echo
exit 1
fi
}

#### Panel Production ####

# Panel Production #
production() {
echo
print_brake 25
echo -e "* ${GREEN}Producing panel...${reset}"
print_brake 25
echo
print "Producing panel..."
print_warning "This process takes a few minutes, please do not cancel it."

if [ -d "$PTERO/node_modules" ]; then
cd "$PTERO"
yarn build:production
Expand All @@ -276,36 +235,40 @@ if [ -d "$PTERO/node_modules" ]; then
fi
}


bye() {
print_brake 50
echo
echo -e "${GREEN}* The addon ${YELLOW}Bigger Console${GREEN} was successfully installed."
echo -e "* A security backup of your panel has been created."
echo -e "* Thank you for using this script."
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${reset}"
echo -e "* Support group: ${YELLOW}$(hyperlink "$SUPPORT_LINK")${RESET}"
echo
print_brake 50
}


#### Exec Script ####
# Exec Script #
check_distro
find_pterodactyl
if [ "$PTERO_INSTALL" == true ]; then
echo
print_brake 66
echo -e "* ${GREEN}Installation of the panel found, continuing the installation...${reset}"
print_brake 66
echo
print "Installation of the panel found, continuing the installation..."

compatibility
check_conflict
verify_installation
elif [ "$PTERO_INSTALL" == false ]; then
echo
print_brake 66
echo -e "* ${red}The installation of your panel could not be located, aborting...${reset}"
print_brake 66
echo
exit 1
print_warning "The installation of your panel could not be located."
echo -e "* ${GREEN}EXAMPLE${RESET}: ${YELLOW}/var/www/mypanel${RESET}"
echo -ne "* Enter the pterodactyl installation directory manually: "
read -r MANUAL_DIR
if [ -d "$MANUAL_DIR" ]; then
print "Directory has been found!"
PTERO="$MANUAL_DIR"
update_variables
compatibility
check_conflict
verify_installation
else
print_error "The directory you entered does not exist."
find_pterodactyl
fi
fi
Loading

0 comments on commit c30f302

Please sign in to comment.