diff --git a/.DS_Store b/.DS_Store index 7aa1d3f5d..76aef38aa 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/cyberpanel.sh b/cyberpanel.sh index 8ad5ef0cb..83f2f0c21 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -41,25 +41,32 @@ 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 +chmod 700 /usr/bin/cyberpanel_utility fi -if ! cat /root/.bashrc | grep -q cyberpanel_utility ; then +#<< --COMMENTOUT-- +BASH_PATH="/root/.bashrc" +if ! cat $BASH_PATH | grep -q cyberpanel_utility ; then echo -e "\n\ncyberpanel() { -if [[ $1 == "utility" ]] ; then -/usr/bin/cyberpanel_utility ${@:2:99} +if [[ \$1 == \"utility\" ]] ; then +/usr/bin/cyberpanel_utility \${@:2:99} +elif [[ \$1 == \"help\" ]] ; then +/usr/bin/cyberpanel_utility --help +elif [[ \$1 == \"upgrade\" ]] || [[ \$1 == \"update\" ]] ; then +/usr/bin/cyberpanel_utility --upgrade else -/usr/bin/cyberpanel "$@" +/usr/bin/cyberpanel \"\$@\" fi -}" >> /root/.bashrc -source /root/.bashrc +}" >> $BASH_PATH fi +#--COMMENTOUT-- + } watchdog_setup() { if [[ $WATCHDOG == "ON" ]] ; then wget -O /etc/cyberpanel/watchdog.sh https://$DOWNLOAD_SERVER/misc/watchdog.sh -chmod +x /etc/cyberpanel/watchdog.sh +chmod 700 /etc/cyberpanel/watchdog.sh ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog pid=$(ps aux | grep "watchdog lsws" | grep -v grep | awk '{print $2}') if [[ "$pid" == "" ]] ; then @@ -387,6 +394,13 @@ fi system_tweak() { + +server_name=$(hostname) + +echo "127.0.0.1 $server_name +$(cat /etc/hosts)" > /etc/hosts +#this should address on "sudo: unable to resolve host ..." on Ubuntu , it's not issue but annoying. + if [[ $SERVER_OS == "CentOS" ]] ; then setenforce 0 sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config @@ -1247,7 +1261,7 @@ webadmin_passwd watchdog_setup -#install_utility +install_utility clear echo "###################################################################" diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 42207ec38..af932faf1 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -1,8 +1,35 @@ #!/bin/bash +#CyberPanel Upgrade script +export LC_CTYPE=en_US.UTF-8 +SUDO_TEST=$(set) SERVER_OS='Undefined' OUTPUT=$(cat /etc/*release) +install_utility() { +if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then +wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh +chmod 700 /usr/bin/cyberpanel_utility +fi +} + +check_root() { +echo -e "\nChecking root privileges...\n" +if echo $SUDO_TEST | grep SUDO > /dev/null ; then + echo -e "\nYou are using SUDO , please run as root user...\n" + echo -e "If you don't have direct access to root user, please run \e[31msudo su -\e[39m command and then run upgrade command again." + exit +fi + +if [[ $(id -u) != 0 ]] > /dev/null; then + echo -e "\nYou must use root user to upgrade CyberPanel...\n" + exit +else + echo -e "\nYou are runing as root...\n" +fi +} + + check_return() { #check previous command result , 0 = ok , non-0 = something wrong. if [[ $? -eq "0" ]] ; then @@ -13,6 +40,8 @@ else fi } +check_root + echo -e "\nChecking OS..." OUTPUT=$(cat /etc/*release) if echo $OUTPUT | grep -q "CentOS Linux 7" ; then @@ -125,6 +154,15 @@ cp lswsgi /usr/local/CyberCP/bin/ chmod 700 /usr/bin/adminPass +if [[ -f /etc/pure-ftpd/pure-ftpd.conf ]] ; then +sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf +fi + + +#install_utility + + + ## systemctl restart lscpd diff --git a/cyberpanel_utility.sh b/cyberpanel_utility.sh index dcdcb6c6e..c9e0e98bf 100644 --- a/cyberpanel_utility.sh +++ b/cyberpanel_utility.sh @@ -5,6 +5,29 @@ export LC_CTYPE=en_US.UTF-8 SUDO_TEST=$(set) BRANCH_NAME="stable" +check_OS() { +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="CentOS" +elif echo $OUTPUT | grep -q "CloudLinux 7" ; then + echo -e "\nDetecting CloudLinux 7.X...\n" + SERVER_OS="CentOS" +elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then + echo -e "\nDetecting CentOS 8.X...\n" + SERVER_OS="CentOS" + CENTOS_8="True" +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 +} set_watchdog() { echo -e "\nPlease choose:" @@ -20,7 +43,7 @@ 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 + chmod 700 /etc/cyberpanel/watchdog.sh ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog echo -e "\nWatchDos has been installed..." set_watchdog @@ -102,23 +125,172 @@ rm -f /tmp/cyberpanel_utility.sh } cyberpanel_upgrade() { +echo -e "CyberPanel Upgrade will start in 10 seconds" +echo -e "If you want to cancel, please press CTRL + C to cancel it" +sleep 10 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 +chmod 700 /usr/local/cyberpanel_upgrade.sh /usr/local/cyberpanel_upgrade.sh rm -f /usr/local/cyberpanel_upgrade.sh exit } -get_faq() { +show_help() { echo -e "\nFetching information...\n" -curl https://cyberpanel.sh/misc/faq.txt +curl --silent https://cyberpanel.sh/misc/faq.sh | sudo -u nobody bash exit } addons() { -echo -e "place holder" + echo -e "\nPlease choose:" + echo -e "\n1. Install Memcached extension for PHP." + echo -e "\n2. Install Memcached server." + echo -e "\n3. Install Redis extension for PHP." + echo -e "\n4. Install Redis server." + echo -e "\n5. Back to Main Menu.\n" + printf "%s" "Please enter number [1-5]: " + read TMP_YN + + if [[ $TMP_YN == "1" ]] ; then + install_php_memcached + elif [[ $TMP_YN == "2" ]] ; then + install_memcached + elif [[ $TMP_YN == "3" ]]; then + install_php_redis + elif [[ $TMP_YN == "4" ]] ; then + install_redis + elif [[ $TMP_YN == "5" ]] ; then + main_page + else + echo -e " Please enter the right number [1-5]\n" + exit + fi +} + +install_php_redis() { + if [[ $SERVER_OS == "CentOS" ]] ; then + yum install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis lsphp56-redis lsphp55-redis lsphp54-redis + fi + if [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-redis lsphp73-redis lsphp72-redis lsphp71-redis lsphp70-redis + fi + echo -e "\nRedis extension for PHP has been installed..." + exit +} + +install_redis() { + if [[ -f /usr/bin/redis-cli ]] ; then + echo -e "\nRedis is already installed..." + fi + if [[ ! -f /usr/bin/redis-cli ]] && [[ $SERVER_OS == "CentOS" ]] ; then + yum install -y redis + fi + if [[ ! -f /usr/bin/redis-cli ]] && [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y redis + fi + if ifconfig -a | grep inet6 ; then + echo -e "\n IPv6 detected..." + else + if [[ $SERVER_OS == "Ubuntu" ]] ; then + sed -i 's|bind 127.0.0.1 ::1|bind 127.0.0.1|g' /etc/redis/redis.conf + #remove ipv6 binding to prevent Redis fail to start. + fi + echo -e "\n no IPv6 detected..." + fi + + if systemctl is-active --quiet redis ; then + systemctl status redis + else + systemctl enable redis + systemctl start redis + systemctl status redis + fi +} + +install_memcached() { +echo -e "\n Would you like to install Memcached or LiteSpeed Mmecached ?" +echo -e "\n 1. LiteSpeed Memcached" +echo -e "\n 2. Memcached" +echo -e "\n 3. Back to Main Menu\n" +printf "%s" "Please enter number [1-3]: " +read TMP_YN + + if [[ $TMP_YN == "1" ]] ; then + if systemctl is-active --quiet memcached ; then + echo -e "\nIt seems Memcached server is already running..." + systemctl status memcached + exit + fi + if [[ -f /usr/local/lsmcd/bin/lsmcd ]] ; then + echo -e "\nLiteSpeed Memcached is already installed..." + else + if [[ $SERVER_OS == "CentOS" ]] ; then + yum groupinstall "Development Tools" -y + yum install autoconf automake zlib-devel openssl-devel expat-devel pcre-devel libmemcached-devel cyrus-sasl* -y + elif [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install build-essential zlib1g-dev libexpat1-dev openssl libssl-dev libsasl2-dev libpcre3-dev git -y + fi + wget https://cdn.cyberpanel.sh/litespeed/lsmcd.tar.gz + tar xzvf lsmcd.tar.gz + DIR=$(pwd) + cd $DIR/lsmcd + ./fixtimestamp.sh + ./configure CFLAGS=" -O3" CXXFLAGS=" -O3" + make + make install + cd $DIR + fi + if systemctl is-active --quiet lsmcd ; then + systemctl status lsmcd + else + systemctl enable lsmcd + systemctl start lsmcd + systemctl status lsmcd + fi + + elif [[ $TMP_YN == "2" ]] ; then + if systemctl is-active --quiet lsmcd ; then + echo -e "\nIt seems LiteSpeed Memcached server is already running..." + systemctl status lsmcd + exit + fi + if [[ -f /usr/bin/memcached ]] ; then + echo -e "\nMemcached is already installed..." + fi + if [[ ! -f /usr/bin/memcached ]] && [[ $SERVER_OS == "CentOS" ]] ; then + yum install memcached -y + sed -i 's|OPTIONS=""|OPTIONS="-l 127.0.0.1 -U 0"|g' /etc/sysconfig/memcached + #this will disbale UDP and bind to 127.0.0.1 to prevent UDP amplification attack + fi + if [[ ! -f /usr/bin/memcached ]] && [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install memcached -y + fi + if systemctl is-active --quiet memcached ; then + systemctl status memcached + else + systemctl enable memcached + systemctl start memcached + systemctl status memcached + fi + elif [[ $TMP_YN == "3" ]] ; then + main_page + else + echo -e " Please enter the right number [1-3]\n" + exit + fi +} + +install_php_memcached() { + if [[ $SERVER_OS == "CentOS" ]] ; then + yum install -y lsphp74-memcached lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached lsphp56-pecl-memcached lsphp55-pecl-memcached lsphp54-pecl-memcached + fi + if [[ $SERVER_OS == "Ubuntu" ]] ; then + DEBIAN_FRONTEND=noninteractive apt install -y lsphp74-memcached lsphp73-memcached lsphp72-memcached lsphp71-memcached lsphp70-memcached + fi + echo -e "\nMemcached extension for PHP has been installed..." + exit } main_page() { @@ -148,7 +320,7 @@ case "$num" in set_watchdog ;; 4) - get_faq + show_help ;; 5) exit @@ -184,17 +356,13 @@ sudo_check() { 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 +check_OS + self_check diff --git a/faq.sh b/faq.sh new file mode 100644 index 000000000..414ea980d --- /dev/null +++ b/faq.sh @@ -0,0 +1,77 @@ +#!/bin/bash + + +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' +PURPLE='\033[0;35m' +NC='\033[0m' # No Color + +#${RED}text${NC} +#${GREEN} ${BLUE} + + +echo -e "Frequently Asked Question + +${PURPLE}1.${NC} How to reset CyberPanel admin password? + +execute command ${RED}adminPass YOUR_NEW_PASSWORD${NC} + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}2.${NC} How to reset LiteSpeed WebAdmin Console user/password ? + +execute command ${RED}/usr/local/lsws/admin/misc/admpass.sh${NC} + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}3.${NC} How to access LiteSpeed webadmin console ? + +Please check this post: ${GREEN}https://forums.cyberpanel.net/discussion/87/tutorial-how-to-setup-and-login-to-openlitespeed-webadmin-console/p1${NC} + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}4.${NC} What is MariaDB root password ? + +execute command ${RED}cat /etc/cyberpanel/mysqlPassword${NC} will show you the root password + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}5.${NC} Can I change MariaDB root passwod ? + +Yes , but after you changed , please make sure you have updated the password in following 2 files as well + +${RED}/etc/cyberpanel/mysqlPassword${NC} + +${RED}/usr/local/CyberCP/CyberCP/settings.py${NC} + +otherwise CyberPanel will not have access to database. + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}6.${NC} How to raise upload limit for cyberpanel's phpMyAdmin and File Manager? + +edit file ${RED}/usr/local/lsws/lsphp73/etc/php.ini${NC} for CentOS + +${RED}/usr/local/lsws/lsphp73/etc/php/7.3/litespeed/php.ini${NC} for Ubbuntu + +find 2 configurations: + +${RED}post_max_size${NC} and ${RED}upload_max_filesize${NC} , change from to higher number, e.g. ${RED}100M${NC} (don't miss the M) + +and then run ${RED}pkill lsphp${NC} to kill all current php process for new configuration to take effect. + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}7.${NC} How to add more IPs to my website(s) ? + +For OpenLiteSpeed, please check this post: ${GREEN}https://forums.cyberpanel.net/discussion/126/tutorial-how-to-add-2nd-ip-for-websites/p1${NC} + +For LiteSpeed Enterprise, please check this post: ${GREEN}https://forums.cyberpanel.net/discussion/3745/tutorial-how-to-add-2nd-ip-for-litespeed-enterprise/p1${NC} + +${BLUE}------------------------------------------------------------${NC} + +${PURPLE}8.${NC} How to remove 8090 port in CyberPanel URL ? + +Please check this post ${GREEN}https://blog.cyberpanel.net/2018/12/25/how-to-remove-port-8090-from-cyberpanel/${NC} +" diff --git a/preUpgrade.sh b/preUpgrade.sh index 0d73357e5..205d6cac6 100644 --- a/preUpgrade.sh +++ b/preUpgrade.sh @@ -1,109 +1,5 @@ #!/bin/sh - -SERVER_OS='Undefined' -OUTPUT=$(cat /etc/*release) -BRANCH_NAME=$1 - -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 -else - pip3.6 install virtualenv -fi - -rm -rf /usr/local/CyberPanel -virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel -rm -rf requirments.txt -wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt -. /usr/local/CyberPanel/bin/activate - -if [ $SERVER_OS = "Ubuntu" ] ; then - . /usr/local/CyberPanel/bin/activate - pip3 install --ignore-installed -r requirments.txt -else - source /usr/local/CyberPanel/bin/activate - pip3.6 install --ignore-installed -r requirments.txt -fi - -virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel -rm -rf upgrade.py -wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/plogical/upgrade.py -/usr/local/CyberPanel/bin/python upgrade.py $BRANCH_NAME - -## - -virtualenv -p /usr/bin/python3 /usr/local/CyberCP -wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/requirments.txt - -if [ $SERVER_OS = "Ubuntu" ] ; then - . /usr/local/CyberCP/bin/activate - pip3 install --ignore-installed -r requirments.txt -else - source /usr/local/CyberCP/bin/activate - pip3.6 install --ignore-installed -r requirments.txt -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 "###################################################################" +rm -f /usr/local/cyberpanel_upgrade.sh +wget -O /usr/local/cyberpanel_upgrade.sh https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/cyberpanel_upgrade.sh 2>/dev/null +chmod 700 /usr/local/cyberpanel_upgrade.sh +/usr/local/cyberpanel_upgrade.sh