remove repos during upgrade

This commit is contained in:
Usman Nasir
2020-04-11 11:31:13 +05:00
parent c528695b33
commit d00ed2fda7
4 changed files with 85 additions and 136 deletions

View File

@@ -1079,7 +1079,7 @@ if [[ $DEV == "ON" ]] ; then
cd /usr/local/
virtualenv -p /usr/bin/python3 CyberPanel
source /usr/local/CyberPanel/bin/activate
wget -O /usr/local/cyberpanel-pip.zip https://cyberpanelrepo.b-cdn.net//cyberpanel-pip.zip
wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip
check_return
unzip /usr/local/cyberpanel-pip.zip -d /usr/local
check_return

View File

@@ -11,6 +11,23 @@ GIT_URL="github.com/usmannasir/cyberpanel"
GIT_CONTENT_URL="raw.githubusercontent.com/usmannasir/cyberpanel"
SERVER_COUNTRY="unknow"
SERVER_COUNTRY=$(curl --silent --max-time 5 https://cyberpanel.sh/?country)
### Update and remove not needed repos
curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo
rm -f /etc/yum.repos.d/ius-archive.repo
rm -f /etc/yum.repos.d/copart-restic-epel-7.repo
rm -f /etc/yum.repos.d/dovecot.repo
rm -f /etc/yum.repos.d/epel.repo
rm -f /etc/yum.repos.d/epel-testing.repo
rm -f /etc/yum.repos.d/frank.repo
rm -f /etc/yum.repos.d/ius.repo
rm -f /etc/yum.repos.d/ius-testing.repo
rm -f /etc/yum.repos.d/MariaDB.repo
rm -f /etc/yum.repos.d/lux.repo
##
if [[ ${#SERVER_COUNTRY} == "2" ]] || [[ ${#SERVER_COUNTRY} == "6" ]] ; then
echo -e "\nChecking server..."
else

View File

@@ -1,5 +1,5 @@
[CyberPanel]
name=CyberPanel
baseurl=https://cyberpanelrepo.b-cdn.net/
gpgkey=https://cyberpanelrepo.b-cdn.net/RPM-GPG-KEY-cyberpanel
baseurl=https://rep.cyberpanel.net/
gpgkey=https://rep.cyberpanel.net/RPM-GPG-KEY-cyberpanel
gpgcheck=1

View File

@@ -19,6 +19,8 @@ BUILD = 1
class Upgrade:
logPath = "/usr/local/lscp/logs/upgradeLog"
cdn = 'cdn.cyberpanel.sh'
installedOutput = ''
CentOSPath = '/etc/redhat-release'
@staticmethod
def stdOut(message, do_exit=0):
@@ -123,7 +125,6 @@ class Upgrade:
except BaseException as msg:
Upgrade.stdOut(str(msg) + " [mountTemp]", 0)
@staticmethod
def dockerUsers():
### Docker User/group
@@ -408,25 +409,6 @@ class Upgrade:
Upgrade.stdOut(str(msg) + ' [downloadLink]')
os._exit(0)
@staticmethod
def fileManager():
## Copy File manager files
command = "rm -rf /usr/local/lsws/Example/html/FileManager"
Upgrade.executioner(command, 'Remove old Filemanager', 0)
if os.path.exists('/usr/local/lsws/bin/openlitespeed'):
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws/Example/html"
Upgrade.executioner(command, 'Setup new Filemanager', 0)
else:
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws"
Upgrade.executioner(command, 'Setup new Filemanager', 0)
##
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
Upgrade.executioner(command, 'Filemanager permissions change', 0)
@staticmethod
def setupCLI():
try:
@@ -1275,27 +1257,11 @@ class Upgrade:
except:
pass
@staticmethod
def installGit():
try:
if os.path.exists("/etc/lsb-release"):
command = 'apt -y install git'
Upgrade.executioner(command, 'installGit', 0)
else:
command = 'sudo yum install git -y'
Upgrade.executioner(command, 'installGit', 0)
except BaseException as msg:
pass
@staticmethod
def downloadAndUpgrade(versionNumbring, branch):
try:
## Download latest version.
Upgrade.installGit()
## Backup settings file.
Upgrade.stdOut("Backing up settings file.")
@@ -1722,18 +1688,22 @@ CSRF_COOKIE_SECURE = True
@staticmethod
def installPHP73():
try:
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
Upgrade.executioner(command, 'Install PHP 73, 0')
command = 'yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
'lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
'lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath'
if Upgrade.installedOutput.find('lsphp73') == -1:
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
Upgrade.executioner(command, 'Install PHP 73, 0')
if Upgrade.installedOutput.find('lsphp74') == -1:
command = 'yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
'lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
'lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath'
Upgrade.executioner(command, 'Install PHP 74, 0')
Upgrade.executioner(command, 'Install PHP 74, 0')
except:
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
@@ -1755,11 +1725,6 @@ CSRF_COOKIE_SECURE = True
command = "mkdir -p /usr/local/lscp/cyberpanel/logs"
Upgrade.executioner(command, 0)
@staticmethod
def upgradePDNS():
command = "yum install epel-release && curl -o /etc/yum.repos.d/powerdns-auth-42.repo https://repo.powerdns.com/repo-files/centos-auth-42.repo && yum --enablerepo=epel install pdns"
subprocess.call(command, shell=True)
@staticmethod
def upgradeDovecot():
try:
@@ -1767,40 +1732,28 @@ CSRF_COOKIE_SECURE = True
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
path = '/etc/yum.repos.d/dovecot.repo'
content = """[dovecot-2.3-latest]
name=Dovecot 2.3 CentOS $releasever - $basearch
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
gpgcheck=1
enabled=1"""
writeToFile = open(path, 'w')
writeToFile.write(content)
writeToFile.close()
command = "yum makecache -y"
Upgrade.executioner(command, 0)
if Upgrade.installedOutput.find('2:2.3.10-2') == -1:
command = "yum makecache -y"
Upgrade.executioner(command, 0)
command = "yum update -y"
Upgrade.executioner(command, 0)
command = "yum update -y"
Upgrade.executioner(command, 0)
## Remove Default Password Scheme
## Remove Default Password Scheme
path = '/etc/dovecot/dovecot-sql.conf.ext'
path = '/etc/dovecot/dovecot-sql.conf.ext'
data = open(path, 'r').readlines()
data = open(path, 'r').readlines()
updatePasswords = 1
writeToFile = open(path, 'w')
for items in data:
if items.find('default_pass_scheme') > -1:
continue
else:
writeToFile.writelines(items)
writeToFile = open(path, 'w')
for items in data:
if items.find('default_pass_scheme') > -1:
updatePasswords = 0
continue
else:
writeToFile.writelines(items)
writeToFile.close()
writeToFile.close()
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
@@ -1819,68 +1772,44 @@ enabled=1"""
Upgrade.executioner(command, 0)
### Postfix Upgrade
try:
shutil.copy('/etc/postfix/master.cf', '/etc/master.cf')
except:
pass
if Upgrade.installedOutput.find('2:3.4.7-1.gf.el7') == -1:
try:
shutil.copy('/etc/postfix/master.cf', '/etc/master.cf')
except:
pass
try:
shutil.copy('/etc/postfix/main.cf', '/etc/main.cf')
except:
pass
try:
shutil.copy('/etc/postfix/main.cf', '/etc/main.cf')
except:
pass
gf = '/etc/yum.repos.d/gf.repo'
gfContent = """[gf]
name=Ghettoforge packages that won't overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
[gf-plus]
name=Ghettoforge packages that will overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/plus/$basearch/mirrorlist
# Please read http://ghettoforge.org/index.php/Usage *before* enabling this repository!
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
"""
writeToFile = open(gf, 'w')
writeToFile.write(gfContent)
writeToFile.close()
command = 'yum remove postfix -y'
Upgrade.executioner(command, 0)
command = 'yum remove postfix -y'
Upgrade.executioner(command, 0)
command = 'yum clean all'
Upgrade.executioner(command, 0)
command = 'rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm'
Upgrade.executioner(command, 0)
command = 'yum makecache fast'
Upgrade.executioner(command, 0)
command = 'yum clean all'
Upgrade.executioner(command, 0)
command = 'yum install --enablerepo=CyberPanel -y postfix3 postfix3-mysql'
Upgrade.executioner(command, 0)
command = 'yum makecache fast'
Upgrade.executioner(command, 0)
try:
shutil.move('/etc/master.cf', '/etc/postfix/master.cf')
except:
pass
try:
shutil.move('/etc/main.cf', '/etc/postfix/main.cf')
except:
pass
command = 'yum install -y postfix3 postfix3-mysql'
Upgrade.executioner(command, 0)
try:
shutil.move('/etc/master.cf', '/etc/postfix/master.cf')
except:
pass
try:
shutil.move('/etc/main.cf', '/etc/postfix/main.cf')
except:
pass
command = 'systemctl restart postfix'
Upgrade.executioner(command, 0)
command = 'systemctl restart postfix'
Upgrade.executioner(command, 0)
else:
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
@@ -1987,9 +1916,9 @@ failovermethod=priority
CentOSPath = '/etc/redhat-release'
if os.path.exists(CentOSPath):
command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
if Upgrade.installedOutput.find('restic') == -1:
command = 'yum install restic -y'
Upgrade.executioner(command, 'Install Restic')
else:
command = 'apt-get update -y'
Upgrade.executioner(command, 'Install Restic')
@@ -1997,7 +1926,6 @@ failovermethod=priority
command = 'apt-get install restic -y'
Upgrade.executioner(command, 'Install Restic')
@staticmethod
def UpdateMaxSSLCons():
command = "sed -i 's|<maxConnections>2000</maxConnections>|<maxConnections>10000</maxConnections>|g' /usr/local/lsws/conf/httpd_config.xml"
@@ -2134,6 +2062,10 @@ vmail
# Upgrade.stdOut("Upgrades are currently disabled")
# return 0
if os.path.exists(Upgrade.CentOSPath):
command = 'yum list installed'
Upgrade.installedOutput = subprocess.call(shlex.split(command))
command = 'systemctl stop cpssh'
Upgrade.executioner(command, 'fix csf if there', 0)