merge stable

This commit is contained in:
Usman Nasir
2021-07-09 19:47:22 +05:00
16 changed files with 13976 additions and 10159 deletions

View File

@@ -174,7 +174,12 @@ Retry_Command() {
# shellcheck disable=SC2034
for i in {1..50};
do
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
if [[ "$i" = "50" ]] ; then
echo "command $1 failed for 50 times, exit..."
exit 2
else
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
fi
done
}
@@ -240,7 +245,7 @@ fi
# Reference: https://unix.stackexchange.com/questions/116539/how-to-detect-the-desktop-environment-in-a-bash-script
if [ -z "$XDG_CURRENT_DESKTOP" ]; then
echo "Desktop OS not detected. Proceeding"
echo -e "Desktop OS not detected. Proceeding\n"
else
echo "$XDG_CURRENT_DESKTOP defined appears to be a desktop OS. Bailing as CyberPanel is incompatible."
echo -e "\nCyberPanel is supported on server OS types only. Such as Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x and CloudLinux 7.x...\n"
@@ -263,6 +268,8 @@ elif grep -q -E "Rocky Linux" /etc/os-release ; then
Server_OS="RockyLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10" /etc/os-release ; then
Server_OS="Ubuntu"
elif grep -q -E "Rocky Linux" /etc/os-release ; then
Server_OS="RockyLinux"
else
echo -e "Unable to detect your system..."
echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x, RockyLinux 8.x, CloudLinux 7.x, CloudLinux 8.x...\n"
@@ -575,25 +582,20 @@ echo -e " CyberPanel Installer v$Panel_Version.$Panel_Build
1. Install CyberPanel.
2. Addons and Miscellaneous
3. Exit.
2. Exit.
"
read -r -p " Please enter the number[1-3]: " Input_Number
read -r -p " Please enter the number[1-2]: " Input_Number
echo ""
case "$Input_Number" in
1)
Interactive_Mode_Set_Parameter
;;
2)
Interactive_Mode_Addon
;;
3)
exit
;;
*)
echo -e " Please enter the right number [1-3]\n"
echo -e " Please enter the right number [1-2]\n"
exit
;;
esac
@@ -987,9 +989,10 @@ if [[ "$Server_OS" = "CentOS" ]] ; then
else
apt update -y
DEBIAN_FRONTEND=noninteractive apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
if [[ "$Server_Provider" = "Alibaba Cloud" ]] ; then
if [[ "$Server_Provider" = "Alibaba Cloud" ]] ; then
apt install -y --allow-downgrades libgnutls30=3.6.13-2ubuntu1.3
fi
fi
DEBIAN_FRONTEND=noninteracitve apt install -y dnsutils net-tools htop telnet 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 virtualenv git socat vim unzip zip
Check_Return
@@ -1083,12 +1086,12 @@ if [[ "$Server_OS" = "CentOS" ]] ; then
fi
#CentOS 7 specific change
if [[ "$Server_OS_Version" = "8" ]] ; then
if grep -q -E "Rocky Linux" /etc/os-release ; then
if [[ "$Server_Country" = "CN" ]] ; then
if grep -q -E "Rocky Linux" /etc/os-release ; then
if [[ "$Server_Country" = "CN" ]] ; then
sed -i 's|rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm|curl -o /etc/yum.repos.d/litespeed.repo https://cyberpanel.sh/litespeed/litespeed_cn.repo|g' install.py
else
sed -i 's|rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm|curl -o /etc/yum.repos.d/litespeed.repo https://cyberpanel.sh/litespeed/litespeed.repo|g' install.py
fi
fi
fi
fi
#CentOS 8 specific change
@@ -1114,6 +1117,12 @@ if ! grep -q "pid_max" /etc/rc.local 2>/dev/null ; then
echo "echo 1000000 > /proc/sys/kernel/pid_max
echo 1 > /sys/kernel/mm/ksm/run" >>/etc/rc.local
chmod +x /etc/rc.local
fi
if grep -q "nf_conntrack_max" /etc/sysctl.conf ; then
sysctl -w net.netfilter.nf_conntrack_max=2097152 > /dev/null
sysctl -w net.nf_conntrack_max=2097152 > /dev/null
echo "net.netfilter.nf_conntrack_max=2097152" >> /etc/sysctl.conf
echo "net.nf_conntrack_max=2097152" >> /etc/sysctl.conf
fi
echo "fs.file-max = 65535" >>/etc/sysctl.conf
sysctl -p >/dev/null
@@ -1921,4 +1930,4 @@ Post_Install_Setup_Utility
Post_Install_Tweak
Post_Install_Display_Final_Info
Post_Install_Display_Final_Info

View File

@@ -117,25 +117,26 @@ if grep -q -E "CentOS Linux 7|CentOS Linux 8" /etc/os-release ; then
Server_OS="CentOS"
elif grep -q -E "CloudLinux 7|CloudLinux 8" /etc/os-release ; then
Server_OS="CloudLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04" /etc/os-release ; then
elif grep -q "AlmaLinux-8" /etc/os-release ; then
Server_OS="AlmaLinux"
elif grep -q -E "Ubuntu 18.04|Ubuntu 20.04|Ubuntu 20.10" /etc/os-release ; then
Server_OS="Ubuntu"
else
echo -e "Unable to detect your system..."
echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
Debug_Log2 "CyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, CentOS 7.x, CentOS 8.x and CloudLinux 7.x... [404]"
echo -e "\nCyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, CloudLinux 7.x and AlmaLinux 8.x...\n"
Debug_Log2 "CyberPanel is supported on Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x... [404]"
exit
fi
Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2)
Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | head -c2 | tr -d . )
#to make 20.04 display as 20
echo -e "System: $Server_OS $Server_OS_Version detected...\n"
if [[ $Server_OS = "CloudLinux" ]] ; then
Server_OS_Version=$(grep VERSION_ID /etc/os-release | awk -F[=,] '{print $2}' | tr -d \" | cut -c1-1)
if [[ $Server_OS = "CloudLinux" ]] || [[ "$Server_OS" = "AlmaLinux" ]] ; then
Server_OS="CentOS"
#CloudLinux gives version id like 7.8 , 7.9 , so cut it to show first number only
#then treat it as CentOS system.
#treat CL and Alma as CentOS
fi
if [[ "$Debug" = "On" ]] ; then

View File

@@ -0,0 +1,190 @@
import os
import shutil
import pathlib
import stat
def mkdir_p(path, exist_ok=True):
"""
Creates the directory and paths leading up to it like unix mkdir -p .
Defaults to exist_ok so if it exists were not throwing fatal errors
https://docs.python.org/3.7/library/os.html#os.makedirs
"""
if not os.path.exists(path):
print('creating directory: ' + path)
os.makedirs(path, exist_ok)
def chmod_digit(file_path, perms):
"""
Helper function to chmod like you would in unix without having to preface 0o or converting to octal yourself.
Credits: https://stackoverflow.com/a/60052847/1621381
"""
try:
os.chmod(file_path, int(str(perms), base=8))
except:
print(f'Could not chmod : {file_path} to {perms}')
pass
def touch(filepath: str, exist_ok=True):
"""
Touches a file like unix `touch somefile` would.
"""
try:
pathlib.Path(filepath).touch(exist_ok)
except FileExistsError:
print('Could touch : ' + filepath)
pass
def symlink(src, dst):
"""
Symlink a path to another if the src exists.
"""
try:
if os.access(src, os.R_OK):
os.symlink(src, dst)
except:
print(f'Could not symlink Source: {src} > Destination: {dst}')
pass
def chown(path, user, group=-1):
"""
Chown file/path to user/group provided. Passing -1 to user or group will leave it unchanged.
Useful if just changing user or group vs both.
"""
try:
shutil.chown(path, user, group)
except PermissionError:
print(f'Could not change permissions for: {path} to {user}:{group}')
pass
def recursive_chown(path, owner, group=-1):
"""
Recursively chown a path and contents to owner.
https://docs.python.org/3/library/shutil.html
"""
for dirpath, dirnames, filenames in os.walk(path):
try:
shutil.chown(dirpath, owner, group)
except PermissionError:
print('Could not change permissions for: ' + dirpath + ' to: ' + owner)
pass
for filename in filenames:
try:
shutil.chown(os.path.join(dirpath, filename), owner, group)
except PermissionError:
print('Could not change permissions for: ' + os.path.join(dirpath, filename) + ' to: ' + owner)
pass
def recursive_permissions(path, dir_mode=755, file_mode=644, topdir=True):
"""
Recursively chmod a path and contents to mode.
Defaults to chmod top level directory but can be optionally
toggled off when you want to chmod only contents of like a user's homedir vs homedir itself
https://docs.python.org/3.6/library/os.html#os.walk
"""
# Here we are converting the integers to string and then to octal.
# so this function doesn't need to be called with 0o prefixed for the file and dir mode
dir_mode = int(str(dir_mode), base=8)
file_mode = int(str(file_mode), base=8)
if topdir:
# Set chmod on top level path
try:
os.chmod(path, dir_mode)
except:
print('Could not chmod :' + path + ' to ' + str(dir_mode))
for root, dirs, files in os.walk(path):
for d in dirs:
try:
os.chmod(os.path.join(root, d), dir_mode)
except:
print('Could not chmod :' + os.path.join(root, d) + ' to ' + str(dir_mode))
pass
for f in files:
try:
os.chmod(os.path.join(root, f), file_mode)
except:
print('Could not chmod :' + path + ' to ' + str(file_mode))
pass
# Left intentionally here for reference.
# Set recursive chown for a path
# recursive_chown(my_path, 'root', 'root')
# for changing group recursively without affecting user
# recursive_chown('/usr/local/lscp/cyberpanel/rainloop/data', -1, 'lscpd')
# explicitly set permissions for directories/folders to 0755 and files to 0644
# recursive_permissions(my_path, 755, 644)
# Fix permissions and use default values
# recursive_permissions(my_path)
# =========================================================
# Below is a helper class for getting and working with permissions
# Original credits to : https://github.com/keysemble/perfm
def perm_octal_digit(rwx):
digit = 0
if rwx[0] == 'r':
digit += 4
if rwx[1] == 'w':
digit += 2
if rwx[2] == 'x':
digit += 1
return digit
class FilePerm:
def __init__(self, filepath):
filemode = stat.filemode(os.stat(filepath).st_mode)
permissions = [filemode[-9:][i:i + 3] for i in range(0, len(filemode[-9:]), 3)]
self.filepath = filepath
self.access_dict = dict(zip(['user', 'group', 'other'], [list(perm) for perm in permissions]))
def mode(self):
mode = 0
for shift, digit in enumerate(self.octal()[::-1]):
mode += digit << (shift * 3)
return mode
def digits(self):
"""Get the octal chmod equivalent value 755 in single string"""
return "".join(map(str, self.octal()))
def octal(self):
"""Get the octal value in a list [7, 5, 5]"""
return [perm_octal_digit(p) for p in self.access_dict.values()]
def access_bits(self, access):
if access in self.access_dict.keys():
r, w, x = self.access_dict[access]
return [r == 'r', w == 'w', x == 'x']
def update_bitwise(self, settings):
def perm_list(read=False, write=False, execute=False):
pl = ['-', '-', '-']
if read:
pl[0] = 'r'
if write:
pl[1] = 'w'
if execute:
pl[2] = 'x'
return pl
self.access_dict = dict(
[(access, perm_list(read=r, write=w, execute=x)) for access, [r, w, x] in settings.items()])
os.chmod(self.filepath, self.mode())
# project_directory = os.path.abspath(os.path.dirname(sys.argv[0]))
# home_directory = os.path.expanduser('~')
# print(f'Path: {home_directory} Mode: {FilePerm(home_directory).mode()} Octal: {FilePerm(home_directory).octal()} '
# f'Digits: {FilePerm(home_directory).digits()}')
# Example: Output
# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755

View File

@@ -93,6 +93,8 @@ class InstallCyberPanel:
command = 'tar zxf lsws-6.0-ent-x86_64-linux.tar.gz'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
if str.lower(self.serial) == 'trial':
command = 'wget -q --output-document=lsws-6.0/trial.key http://license.litespeedtech.com/reseller/trial.key'
if self.serial == '1111-2222-3333-4444':
command = 'wget -q --output-document=/root/cyberpanel/install/lsws-6.0/trial.key http://license.litespeedtech.com/reseller/trial.key'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
@@ -101,7 +103,6 @@ class InstallCyberPanel:
writeSerial.writelines(self.serial)
writeSerial.close()
shutil.copy('litespeed/install.sh', 'lsws-6.0/')
shutil.copy('litespeed/functions.sh', 'lsws-6.0/')

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
locale/cn/LC_MESSAGES/django.mo Executable file → Normal file

Binary file not shown.

14139
locale/cn/LC_MESSAGES/django.po Executable file → Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -65,7 +65,7 @@ msgstr "Создать пакет"
#: websiteFunctions/templates/websiteFunctions/createWebsite.html:29
#: websiteFunctions/templates/websiteFunctions/modifyWebsite.html:45
msgid "Select Package"
msgstr "Вибрать пакет"
msgstr "Выбрать пакет"
#: CLManager/templates/CLManager/createPackage.html:40
#: packages/templates/packages/createPackage.html:27

View File

@@ -187,4 +187,4 @@ class FilePerm:
# print(f'Path: {home_directory} Mode: {FilePerm(home_directory).mode()} Octal: {FilePerm(home_directory).octal()} '
# f'Digits: {FilePerm(home_directory).digits()}')
# Example: Output
# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755
# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755

View File

@@ -2729,6 +2729,15 @@ RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
`;
const WWWToNonWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
### End CyberPanel Generated Rules.
`;
const nonWWWToWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
@@ -2748,6 +2757,9 @@ RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
} else if ($scope.rewriteTemplate === "Force NON-WWW -> WWW") {
$scope.rewriteRules = nonWWWToWWW + $scope.rewriteRules;
}
else if ($scope.rewriteTemplate === "Force WWW -> NON-WWW") {
$scope.rewriteRules = WWWToNonWWW + $scope.rewriteRules;
}
};

View File

@@ -2729,6 +2729,16 @@ RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
`;
const WWWToNonWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
### End CyberPanel Generated Rules.
`;
const nonWWWToWWW = `### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
@@ -2748,6 +2758,9 @@ RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
} else if ($scope.rewriteTemplate === "Force NON-WWW -> WWW") {
$scope.rewriteRules = nonWWWToWWW + $scope.rewriteRules;
}
else if ($scope.rewriteTemplate === "Force WWW -> NON-WWW") {
$scope.rewriteRules = WWWToNonWWW + $scope.rewriteRules;
}
};

View File

@@ -59,12 +59,12 @@
<h2 style="display: inline; color: #414C59;" ng-bind="web.domain"></h2>
</a>
<a target="_self" href="/filemanager/{$ web.domain $}" title="Open File Manager"> --
File Manager</a>
{% trans "File Manager" %}</a>
</div>
<div class="col-md-2 content-box-header" style="text-transform: none;">
<a href="/websites/{$ web.domain $}" target="_self" title="Manage Website">
<i class="p fa fa-external-link btn-icon">&emsp;</i>
<span>Manage</span>
<span>{% trans "Manage" %}</span>
</a>
</div>
</div>
@@ -83,7 +83,7 @@
<i class="p fa fa-lock btn-icon text-muted" data-toggle="tooltip" data-placement="right"
title="SSL">&emsp;</i>
<span><a ng-click="issueSSL(web.domain)" href=""
style="text-transform: none">Issue SSL</a></span>
style="text-transform: none">{% trans "Issue SSL" %}</a></span>
</div>
</div>
<div class="col-md-12">

View File

@@ -690,6 +690,7 @@
<select ng-change="applyRewriteTemplate()" ng-model="rewriteTemplate"
class="form-control">
<option>Force HTTP -> HTTPS</option>
<option>Force WWW -> NON-WWW</option>
<option>Force NON-WWW -> WWW</option>
</select>
</div>
@@ -1077,4 +1078,4 @@
{% endblock %}
{% endblock %}