diff --git a/cyberpanel.sh b/cyberpanel.sh index a2c972158..8ad5ef0cb 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -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 " diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh new file mode 100644 index 000000000..42207ec38 --- /dev/null +++ b/cyberpanel_upgrade.sh @@ -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 "###################################################################" diff --git a/cyberpanel_utility.sh b/cyberpanel_utility.sh new file mode 100644 index 000000000..dcdcb6c6e --- /dev/null +++ b/cyberpanel_utility.sh @@ -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 diff --git a/filemanager/filemanager.py b/filemanager/filemanager.py index cde03f4dc..c894aa213 100755 --- a/filemanager/filemanager.py +++ b/filemanager/filemanager.py @@ -44,7 +44,9 @@ class FileManager: domainName = self.data['domainName'] website = Websites.objects.get(domain=domainName) - if not self.data['completeStartingPath'].find(self.data['home']) > -1: + pathCheck = '/home/%s' % (domainName) + + if self.data['completeStartingPath'].find(pathCheck) == -1: return self.ajaxPre(0, 'Not allowed to browse this path, going back home!') command = "ls -la --group-directories-first " + self.returnPathEnclosed( @@ -272,6 +274,11 @@ class FileManager: domainName = self.data['domainName'] website = Websites.objects.get(domain=domainName) + pathCheck = '/home/%s' % (domainName) + + if self.data['fileName'].find(pathCheck) == -1: + return self.ajaxPre(0, 'Not allowed.') + command = 'cat ' + self.returnPathEnclosed(self.data['fileName']) finalData['fileContents'] = ProcessUtilities.outputExecutioner(command, website.externalApp) diff --git a/install/install.py b/install/install.py index d05d4b8f6..a1647a30d 100755 --- a/install/install.py +++ b/install/install.py @@ -661,6 +661,9 @@ class preFlightsChecks: command = 'chmod 600 /usr/local/CyberCP/plogical/adminPass.py' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = "find /usr/local/CyberCP/ -name '*.pyc' -delete" + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + def install_unzip(self): self.stdOut("Install unzip") try: diff --git a/install/lscp.tar.gz b/install/lscp.tar.gz index 374600cd0..ab445856d 100644 Binary files a/install/lscp.tar.gz and b/install/lscp.tar.gz differ diff --git a/plogical/acl.py b/plogical/acl.py index 51db810b5..0e4724f23 100755 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -444,22 +444,22 @@ class ACLManager: domainsList = [] if currentACL['admin'] == 1: - domains = Domains.objects.all() + domains = Websites.objects.all() for items in domains: - domainsList.append(items.name) + domainsList.append(items.domain) else: admin = Administrator.objects.get(pk=userID) - domains = admin.domains_set.all() + domains = admin.websites_set.all() for items in domains: - domainsList.append(items.name) + domainsList.append(items.domain) admins = Administrator.objects.filter(owner=admin.pk) for items in admins: - doms = items.domains_set.all() + doms = items.websites_set.all() for dom in doms: - domainsList.append(dom.name) + domainsList.append(dom.domain) return domainsList diff --git a/plogical/backupScheduleLocal.py b/plogical/backupScheduleLocal.py index 80facc113..9c28e1d8b 100755 --- a/plogical/backupScheduleLocal.py +++ b/plogical/backupScheduleLocal.py @@ -22,15 +22,17 @@ class backupScheduleLocal: localBackupPath = '/home/cyberpanel/localBackupPath' now = datetime.now() + @staticmethod def prepare(): try: - backupLogPath = "/usr/local/lscp/logs/local_backup_log." + time.strftime("%m.%d.%Y_%H-%M-%S") + backupRunTime = time.strftime("%m.%d.%Y_%H-%M-%S") + backupLogPath = "/usr/local/lscp/logs/local_backup_log." + backupRunTime writeToFile = open(backupLogPath, "a") backupSchedule.remoteBackupLogging(backupLogPath, "#################################################") - backupSchedule.remoteBackupLogging(backupLogPath," Local Backup log for: " + time.strftime("%m.%d.%Y_%H-%M-%S")) + backupSchedule.remoteBackupLogging(backupLogPath," Local Backup log for: " + backupRunTime) backupSchedule.remoteBackupLogging(backupLogPath, "#################################################\n") backupSchedule.remoteBackupLogging(backupLogPath, "") @@ -43,7 +45,7 @@ class backupScheduleLocal: if os.path.exists(backupScheduleLocal.localBackupPath): backupPath = retValues[1] + ".tar.gz" - localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), time.strftime("%b-%d-%Y")) + localBackupPath = '%s/%s' % (open(backupScheduleLocal.localBackupPath, 'r').read().rstrip('/'), backupRunTime) command = 'mkdir -p %s' % (localBackupPath) ProcessUtilities.normalExecutioner(command) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index c61403fdb..a6eaf4355 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -1662,6 +1662,10 @@ CSRF_COOKIE_SECURE = True command = 'chmod 600 /usr/local/CyberCP/plogical/adminPass.py' Upgrade.executioner(command, 0) + command = "find /usr/local/CyberCP/ -name '*.pyc' -delete" + Upgrade.executioner(command, 0) + + Upgrade.stdOut("Permissions updated.") except BaseException as msg: diff --git a/static/filemanager/js/fileManager.js b/static/filemanager/js/fileManager.js index 067739616..725224dbb 100644 --- a/static/filemanager/js/fileManager.js +++ b/static/filemanager/js/fileManager.js @@ -14,7 +14,6 @@ function getCookie(name) { return cookieValue; } - var fileManager = angular.module('fileManager', ['angularFileUpload']); fileManager.config(['$interpolateProvider', function ($interpolateProvider) { @@ -1483,8 +1482,7 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader, url = "/filemanager/downloadFile"; var downloadURL = $scope.currentPath + "/" + allFilesAndFolders[0]; - var indexPublicHTML = downloadURL.indexOf("public_html") + 11; - $window.location.href = '/preview/' + domainName + downloadURL.slice(indexPublicHTML); + window.location.href = url + '?domainName=' + domainName + '&fileToDownload=' + downloadURL; }; diff --git a/userManagment/views.py b/userManagment/views.py index a43049599..51000a186 100755 --- a/userManagment/views.py +++ b/userManagment/views.py @@ -139,7 +139,10 @@ def submitUserCreation(request): password = data['password'] websitesLimit = data['websitesLimit'] selectedACL = data['selectedACL'] - securityLevel = data['securityLevel'] + try: + securityLevel = data['securityLevel'] + except: + securityLevel = 'HIGH' selectedACL = ACL.objects.get(name=selectedACL) @@ -313,7 +316,10 @@ def saveModifications(request): firstName = data['firstName'] lastName = data['lastName'] email = data['email'] - securityLevel = data['securityLevel'] + try: + securityLevel = data['securityLevel'] + except: + securityLevel = 'HIGH' user = Administrator.objects.get(userName=accountUsername)