mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-19 22:12:05 +01:00
Merge pull request #217 from usmannasir/qtwrkdev
pre-flight preparation for utility script
This commit is contained in:
@@ -38,6 +38,23 @@ else
|
||||
fi
|
||||
}
|
||||
|
||||
install_utility() {
|
||||
if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then
|
||||
wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh
|
||||
chmod +x 700 /usr/bin/cyberpanel_utility
|
||||
fi
|
||||
|
||||
if ! cat /root/.bashrc | grep -q cyberpanel_utility ; then
|
||||
echo -e "\n\ncyberpanel() {
|
||||
if [[ $1 == "utility" ]] ; then
|
||||
/usr/bin/cyberpanel_utility ${@:2:99}
|
||||
else
|
||||
/usr/bin/cyberpanel "$@"
|
||||
fi
|
||||
}" >> /root/.bashrc
|
||||
source /root/.bashrc
|
||||
fi
|
||||
}
|
||||
|
||||
watchdog_setup() {
|
||||
if [[ $WATCHDOG == "ON" ]] ; then
|
||||
@@ -1205,8 +1222,8 @@ if [[ $VERSION = "OLS" ]] ; then
|
||||
# tar xzvf openlitespeed-$OLS_LATEST.tgz
|
||||
# cd openlitespeed
|
||||
# ./install.sh
|
||||
/usr/local/lsws/bin/lswsctrl stop
|
||||
/usr/local/lsws/bin/lswsctrl start
|
||||
systemctl stop lsws
|
||||
systemctl start lsws
|
||||
# rm -f openlitespeed-$OLS_LATEST.tgz
|
||||
# rm -rf openlitespeed
|
||||
# cd ..
|
||||
@@ -1230,6 +1247,8 @@ webadmin_passwd
|
||||
|
||||
watchdog_setup
|
||||
|
||||
#install_utility
|
||||
|
||||
clear
|
||||
echo "###################################################################"
|
||||
echo " CyberPanel Successfully Installed "
|
||||
|
||||
133
cyberpanel_upgrade.sh
Normal file
133
cyberpanel_upgrade.sh
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
SERVER_OS='Undefined'
|
||||
OUTPUT=$(cat /etc/*release)
|
||||
|
||||
check_return() {
|
||||
#check previous command result , 0 = ok , non-0 = something wrong.
|
||||
if [[ $? -eq "0" ]] ; then
|
||||
:
|
||||
else
|
||||
echo -e "\ncommand failed, exiting..."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "\nChecking OS..."
|
||||
OUTPUT=$(cat /etc/*release)
|
||||
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
|
||||
echo -e "\nDetecting CentOS 7.X...\n"
|
||||
SERVER_OS="CentOS7"
|
||||
yum clean all
|
||||
yum update -y
|
||||
elif echo $OUTPUT | grep -q "CloudLinux 7" ; then
|
||||
echo -e "\nDetecting CloudLinux 7.X...\n"
|
||||
SERVER_OS="CentOS7"
|
||||
yum clean all
|
||||
yum update -y
|
||||
elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
|
||||
echo -e "\nDetecting CentOS 8.X...\n"
|
||||
SERVER_OS="CentOS8"
|
||||
yum clean all
|
||||
yum update -y
|
||||
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||
echo -e "\nDetecting Ubuntu 18.04...\n"
|
||||
SERVER_OS="Ubuntu"
|
||||
else
|
||||
cat /etc/*release
|
||||
echo -e "\nUnable to detect your OS...\n"
|
||||
echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $SERVER_OS = "CentOS7" ] ; then
|
||||
yum -y install yum-utils
|
||||
yum -y groupinstall development
|
||||
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
|
||||
yum -y install python36u python36u-pip python36u-devel
|
||||
elif [ $SERVER_OS = "CentOS8" ] ; then
|
||||
yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar
|
||||
dnf --enablerepo=PowerTools install gpgme-devel -y
|
||||
dnf install python3 -y
|
||||
else
|
||||
apt update -y
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y
|
||||
DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y python3-venv
|
||||
fi
|
||||
|
||||
if [ $SERVER_OS = "Ubuntu" ] ; then
|
||||
pip3 install virtualenv
|
||||
check_return
|
||||
else
|
||||
pip3.6 install virtualenv
|
||||
check_return
|
||||
fi
|
||||
|
||||
rm -rf /usr/local/CyberPanel
|
||||
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
||||
check_return
|
||||
rm -rf requirments.txt
|
||||
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
check_return
|
||||
|
||||
if [ $SERVER_OS = "Ubuntu" ] ; then
|
||||
. /usr/local/CyberPanel/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed -r requirments.txt
|
||||
check_return
|
||||
else
|
||||
source /usr/local/CyberPanel/bin/activate
|
||||
check_return
|
||||
pip3.6 install --ignore-installed -r requirments.txt
|
||||
check_return
|
||||
fi
|
||||
|
||||
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
||||
check_return
|
||||
rm -rf upgrade.py
|
||||
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/plogical/upgrade.py
|
||||
/usr/local/CyberPanel/bin/python upgrade.py stable
|
||||
check_return
|
||||
##
|
||||
|
||||
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
|
||||
check_return
|
||||
wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt
|
||||
|
||||
if [ $SERVER_OS = "Ubuntu" ] ; then
|
||||
. /usr/local/CyberCP/bin/activate
|
||||
check_return
|
||||
pip3 install --ignore-installed -r requirments.txt
|
||||
check_return
|
||||
else
|
||||
source /usr/local/CyberCP/bin/activate
|
||||
check_return
|
||||
pip3.6 install --ignore-installed -r requirments.txt
|
||||
check_return
|
||||
fi
|
||||
|
||||
|
||||
##
|
||||
|
||||
rm -f wsgi-lsapi-1.4.tgz
|
||||
rm -rf wsgi-lsapi-1.4
|
||||
wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz
|
||||
tar xf wsgi-lsapi-1.4.tgz
|
||||
cd wsgi-lsapi-1.4
|
||||
/usr/local/CyberPanel/bin/python ./configure.py
|
||||
make
|
||||
|
||||
cp lswsgi /usr/local/CyberCP/bin/
|
||||
|
||||
chmod 700 /usr/bin/adminPass
|
||||
|
||||
##
|
||||
systemctl restart lscpd
|
||||
|
||||
echo "###################################################################"
|
||||
echo " CyberPanel Upgraded "
|
||||
echo "###################################################################"
|
||||
213
cyberpanel_utility.sh
Normal file
213
cyberpanel_utility.sh
Normal file
@@ -0,0 +1,213 @@
|
||||
#!/bin/bash
|
||||
#CyberPanel utility script
|
||||
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
SUDO_TEST=$(set)
|
||||
BRANCH_NAME="stable"
|
||||
|
||||
|
||||
set_watchdog() {
|
||||
echo -e "\nPlease choose:"
|
||||
echo -e "\n1. Install WatchDog."
|
||||
echo -e "\n2. Start or Check WatchDog."
|
||||
echo -e "\n3. Kill WatchDog."
|
||||
echo -e "\n4. Back to Main Menu."
|
||||
echo -e "\n"
|
||||
printf "%s" "Please enter number [1-4]: "
|
||||
read TMP_YN
|
||||
|
||||
if [[ $TMP_YN == "1" ]] ; then
|
||||
if [[ ! -f /etc/cyberpanel/watchdog.sh ]] ; then
|
||||
echo -e "\nWatchDog no found..."
|
||||
wget -O /etc/cyberpanel/watchdog.sh https://cyberpanel.sh/misc/watchdog.sh
|
||||
chmod +x /etc/cyberpanel/watchdog.sh
|
||||
ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog
|
||||
echo -e "\nWatchDos has been installed..."
|
||||
set_watchdog
|
||||
else
|
||||
echo -e "\nWatchDos is already installed..."
|
||||
set_watchdog
|
||||
fi
|
||||
elif [[ $TMP_YN == "2" ]] ; then
|
||||
if [[ -f /etc/cyberpanel/watchdog.sh ]] ; then
|
||||
watchdog status
|
||||
exit
|
||||
else
|
||||
echo -e "\nYou don't have WatchDog installed, please install it first..."
|
||||
set_watchdog
|
||||
fi
|
||||
elif [[ $TMP_YN == "3" ]] ; then
|
||||
if [[ -f /etc/cyberpanel/watchdog.sh ]] ; then
|
||||
echo -e "\n"
|
||||
watchdog kill
|
||||
exit
|
||||
else
|
||||
echo -e "\nYou don't have WatchDog installed, please install it first..."
|
||||
set_watchdog
|
||||
fi
|
||||
elif [[ $TMP_YN == "4" ]] ; then
|
||||
main_page
|
||||
else
|
||||
echo -e "\nPlease enter correct number..."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
check_return() {
|
||||
#check previous command result , 0 = ok , non-0 = something wrong.
|
||||
if [[ $? -eq "0" ]] ; then
|
||||
:
|
||||
else
|
||||
echo -e "\ncommand failed, exiting..."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
self_check() {
|
||||
echo -e "\nChecking Cyberpanel Utility update..."
|
||||
SUM=$(md5sum /usr/bin/cyberpanel_utility)
|
||||
SUM1=${SUM:0:32}
|
||||
#get md5sum of local file
|
||||
|
||||
rm -f /tmp/cyberpanel_utility.sh
|
||||
wget -q -O /tmp/cyberpanel_utility.sh https://cyberpanel.sh/misc/cyberpanel_utility.sh
|
||||
|
||||
|
||||
SUM=$(md5sum /tmp/cyberpanel_utility.sh)
|
||||
SUM2=${SUM:0:32}
|
||||
#get md5sum of remote file.
|
||||
|
||||
if [[ $SUM1 == $SUM2 ]] ; then
|
||||
echo -e "\nCyberPanel Utility Script is up to date...\n"
|
||||
else
|
||||
local_string=$(head -2 /usr/bin/cyberpanel_utility)
|
||||
remote_string=$(head -2 /tmp/cyberpanel_utility.sh)
|
||||
#check file content before replacing itself in case failed to download the file.
|
||||
if [[ $local_string == $remote_string ]] ; then
|
||||
echo -e "\nUpdating CyberPanel Utility Script..."
|
||||
rm -f /usr/bin/cyberpanel_utility
|
||||
mv /tmp/cyberpanel_utility.sh /usr/bin/cyberpanel_utility
|
||||
chmod 700 /usr/bin/cyberpanel_utility
|
||||
echo -e "\nCyberPanel Utility update compelted..."
|
||||
echo -e "\nPlease execute it again..."
|
||||
exit
|
||||
else
|
||||
echo -e "\nFailed to fetch server file..."
|
||||
echo -e "\nKeep using local script..."
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f /tmp/cyberpanel_utility.sh
|
||||
|
||||
}
|
||||
|
||||
cyberpanel_upgrade() {
|
||||
echo -e "CyberPanel upgrading..."
|
||||
rm -f /usr/local/cyberpanel_upgrade.sh
|
||||
wget -O /usr/local/cyberpanel_upgrade.sh -q https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/cyberpanel_upgrade.sh
|
||||
chmod +x /usr/local/cyberpanel_upgrade.sh
|
||||
/usr/local/cyberpanel_upgrade.sh
|
||||
rm -f /usr/local/cyberpanel_upgrade.sh
|
||||
exit
|
||||
}
|
||||
|
||||
get_faq() {
|
||||
echo -e "\nFetching information...\n"
|
||||
curl https://cyberpanel.sh/misc/faq.txt
|
||||
exit
|
||||
}
|
||||
|
||||
addons() {
|
||||
echo -e "place holder"
|
||||
}
|
||||
|
||||
main_page() {
|
||||
echo -e " CyberPanel Utility Tools \e[31m(beta)\e[39m
|
||||
|
||||
1. Upgrade CyberPanel.
|
||||
|
||||
2. Addons.
|
||||
|
||||
3. WatchDog \e[31m(beta)\e[39m
|
||||
|
||||
4. Frequently Asked Question (FAQ)
|
||||
|
||||
5. Exit.
|
||||
|
||||
"
|
||||
read -p " Please enter the number[1-5]: " num
|
||||
echo ""
|
||||
case "$num" in
|
||||
1)
|
||||
cyberpanel_upgrade
|
||||
;;
|
||||
2)
|
||||
addons
|
||||
;;
|
||||
3)
|
||||
set_watchdog
|
||||
;;
|
||||
4)
|
||||
get_faq
|
||||
;;
|
||||
5)
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo -e " Please enter the right number [1-5]\n"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
panel_check(){
|
||||
if [[ ! -f /etc/cyberpanel/machineIP ]] ; then
|
||||
echo -e "\nCan not detect CyberPanel..."
|
||||
echo -e "\nExit..."
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
sudo_check() {
|
||||
echo -e "\nChecking root privileges..."
|
||||
if echo $SUDO_TEST | grep SUDO > /dev/null ; then
|
||||
echo -e "\nYou are using SUDO , please run as root user..."
|
||||
echo -e "If you don't have direct access to root user, please run \e[31msudo su -\e[39m command and then run installation command again."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ $(id -u) != 0 ]] > /dev/null; then
|
||||
echo -e "\nYou must use root user to use CyberPanel Utility..."
|
||||
exit
|
||||
else
|
||||
echo -e "\nYou are runing as root..."
|
||||
fi
|
||||
}
|
||||
|
||||
show_help() {
|
||||
echo -e "\nCyberPanel Utility Script"
|
||||
echo -e "\nYou can use argument --upgrade to run CyberPanel upgrade without interaction for automated job."
|
||||
echo -e "\nExample: cyberpanel utility --upgrade"
|
||||
exit
|
||||
}
|
||||
|
||||
panel_check
|
||||
|
||||
sudo_check
|
||||
|
||||
self_check
|
||||
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
main_page
|
||||
else
|
||||
if [[ $1 == "upgrade" ]] || [[ $1 == "-u" ]] || [[ $1 == "--update" ]] || [[ $1 == "--upgrade" ]] || [[ $1 == "update" ]]; then
|
||||
cyberpanel_upgrade
|
||||
fi
|
||||
if [[ $1 == "help" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]] ; then
|
||||
show_help
|
||||
exit
|
||||
fi
|
||||
echo -e "\nUnrecognized argument..."
|
||||
exit
|
||||
fi
|
||||
Reference in New Issue
Block a user