Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhazulOO7/c9c3b964183321a40d1582cd7dc27691 to your computer and use it in GitHub Desktop.
Save minhazulOO7/c9c3b964183321a40d1582cd7dc27691 to your computer and use it in GitHub Desktop.
A Shell Script to Upgrade CyberPanel

Upgrade CyberPanel using Bash Script

  • NO LONGER MAINTAINED!
  • This script will check for internet availability and then upgrade CyberPanel. Cyberpanel's own upgrade system is too much tedious for many users. That's why made this script.

Script Requirements

How to Use it?

Put the cpupg.sh file to anyhwere you like. E.g., /home/scripts.

  • Open terminal.
  • Give the file execute permission, type/ copy sudo chmod +x /location/cpupg.sh press Enter.
  • For executing the script, type/ copy /location/cpupg.sh press Enter

How it Works?

This is a verbal representation of the script explaining how the script works.

Steps:

  1. Script will start executing and shows [CyberPanel UPG] UPGRADE INITIATED....

  2. Now it will check for LOGGED IN AS ROOT and shows [CyberPanel UPG] CHECKING IF LOGGED IN AS ROOT....

  • If user is root then it will show [CyberPanel UPG] LOGGED IN AS ROOT! and go to next step.
  • If user is not root then it will show [CyberPanel UPG] NOT LOGGED IN AS ROOT!, [CyberPanel UPG] YOU MUST BE LOGGED IN AS ROOT! and exit.
  1. Now it will check for INTERNET AVAILABILITY and shows [CyberPanel UPG] CHECKING FOR INTERNET AVAILABILITY....
  • If internet is available then it will show [CyberPanel UPG] INTERNET IS AVAILABLE! and go to next step.
  • If internet is unavailable then it will show [CyberPanel UPG] INTERNET IS UNAVAILABLE!, [CyberPanel UPG] TRY AGAIN LATER WHEN INTERNET IS AVAILABLE! and exit.
  1. Now it will check for UPGRADE STATUS and shows [CyberPanel UPG] CHECKING FOR UPGRADE STATUS....
  • If upgrade status is enable then it will show [CyberPanel UPG] UPGRADE IS ENABLED! and go to next step.
  • If upgrade status is not enable then it will show [CyberPanel UPG] UPGRADE IS DISABLED! and exit.
  1. Now it will commence CyberPanel upgrade if it get's upgrade status enable from Step 4 then shows the following,
  • [CyberPanel UPG] CHANGING DIRECTORY...
  • [CyberPanel UPG] DELETING PREVIOUS UPGRADE FILE...
  • [CyberPanel UPG] DOWNLOADING LATEST UPGRADE FILE...
  • [CyberPanel UPG] EXECUTING UPGRADE FILE...
  • After the upgrade is finished it will exit.

Notes

  • I have written the instructions based on CentOS 7.6.x.
  • Files name are started with 0, 1 because of orderly manner.
  • I am new to this Scripting Business that's why if I made any mistake please point out any issue!
  • I will update it frequently!
#!/bin/bash
# STATUS
upg_s="enable" # Enable/ disable upgrade. Just edit the value and set it anything else than "enable" to disable upgrade.
# SCRIPT START
echo -e "\n[CyberPanel UPG] UPGRADE INITIATED...\n"
# CHECK IF USER IS ROOT
echo -e "[CyberPanel UPG] CHECKING IF LOGGED IN AS ROOT..."
whoami=$(whoami)
if [[ $whoami == root ]];
then
echo -e "[CyberPanel UPG] LOGGED IN AS ROOT!\n"
else
echo "[CyberPanel UPG] NOT LOGGED IN AS ROOT!"
echo "[CyberPanel UPG] YOU MUST BE LOGGED IN AS ROOT!"
echo -e "[CyberPanel UPG] EXITING...\n"
exit 1
fi
# INTERNET AVAILABILITY
echo "[CyberPanel UPG] CHECKING FOR INTERNET AVAILABILITY..."
internet_check=$(wget -q --spider -t 3 -T 5 https://1.1.1.1/)
internet_check_ev=$?
if [[ $internet_check_ev == 0 ]];
then
echo -e "[CyberPanel UPG] INTERNET IS AVAILABLE!\n"
else
echo "[CyberPanel UPG] INTERNET IS UNAVAILABLE!"
echo "[CyberPanel UPG] TRY AGAIN LATER WHEN INTERNET IS AVAILABLE!"
echo -e "[CyberPanel UPG] EXITING...\n"
exit 1
fi
# UPGRADE STATUS
echo "[CyberPanel UPG] CHECKING FOR UPGRADE STATUS..."
if [[ $upg_s == enable ]];
then
echo -e "[CyberPanel UPG] UPGRADE IS ENABLED!\n"
# CHANGE DIRECTORY
echo -e "[CyberPanel UPG] CHANGING DIRECTORY...\n"
cd=$(cd)
# DELETE PREVIOUS UPGRADE FILE
echo -e "[CyberPanel UPG] DELETING PREVIOUS UPGRADE FILE...\n"
rm=$(rm -f upgrade.py)
# DOWNLOAD LATEST UPGRADE FILE
echo -e "[CyberPanel UPG] DOWNLOADING LATEST UPGRADE FILE...\n"
wget=$(wget -q https://cyberpanel.sh/upgrade.py)
# EXECUTE UPGRADE FILE
echo -e "[CyberPanel UPG] EXECUTING UPGRADE FILE...\n"
upg=$(python upgrade.py)
else
echo "[CyberPanel UPG] UPGRADE IS DISABLED!"
echo -e "[CyberPanel UPG] EXITING...\n"
exit 0
fi
@w3servicesdotnet
Copy link

Working perfectly!!

@minhazulOO7
Copy link
Author

minhazulOO7 commented Jul 17, 2019

@w3servicesdotnet
Working perfectly!!

Thanks! 😇

@minhazulOO7
Copy link
Author

@w3servicesdotnet made some changes. Please download the latest script! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment