Skip to content

Commit

Permalink
create docker site missing tables
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 16, 2024
1 parent ba62760 commit b3de5ab
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions plogical/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


class Upgrade:

logPath = "/usr/local/lscp/logs/upgradeLog"
cdn = 'cdn.cyberpanel.sh'
installedOutput = ''
Expand Down Expand Up @@ -1116,7 +1115,6 @@ def applyLoginSystemMigrations():
except:
pass


query = "ALTER TABLE `websiteFunctions_backupsv2` ADD CONSTRAINT `websiteFunctions_bac_website_id_3a777e68_fk_websiteFu` FOREIGN KEY (`website_id`) REFERENCES `websiteFunctions_websites` (`id`);"

try:
Expand Down Expand Up @@ -1145,7 +1143,6 @@ def applyLoginSystemMigrations():
except:
pass


try:
cursor.execute("ALTER TABLE websiteFunctions_websites ADD COLUMN BackupLock INT DEFAULT 0;")
except:
Expand All @@ -1160,7 +1157,6 @@ def applyLoginSystemMigrations():
pass

if Upgrade.FindOperatingSytem() == Ubuntu22:

### If ftp not installed then upgrade will fail so this command should not do exit

command = "sed -i 's/MYSQLCrypt md5/MYSQLCrypt crypt/g' /etc/pure-ftpd/db/mysql.conf"
Expand Down Expand Up @@ -1676,6 +1672,30 @@ def containerMigrations():
except:
pass

query = """CREATE TABLE `websiteFunctions_dockerpackages` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `Name` varchar(100) NOT NULL, `CPUs` integer NOT NULL, `Ram` integer NOT NULL, `Bandwidth` longtext NOT NULL, `DiskSpace` longtext NOT NULL, `config` longtext NOT NULL);"""
try:
cursor.execute(query)
except:
pass

query = """CREATE TABLE `websiteFunctions_dockersites` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `ComposePath` longtext NOT NULL, `SitePath` longtext NOT NULL, `MySQLPath` longtext NOT NULL, `state` integer NOT NULL, `SiteType` integer NOT NULL, `MySQLDBName` varchar(100) NOT NULL, `MySQLDBNUser` varchar(100) NOT NULL, `CPUsMySQL` varchar(100) NOT NULL, `MemoryMySQL` varchar(100) NOT NULL, `port` varchar(100) NOT NULL, `CPUsSite` varchar(100) NOT NULL, `MemorySite` varchar(100) NOT NULL, `SiteName` varchar(255) NOT NULL UNIQUE, `finalURL` longtext NOT NULL, `blogTitle` longtext NOT NULL, `adminUser` varchar(100) NOT NULL, `adminEmail` varchar(100) NOT NULL, `admin_id` integer NOT NULL);"""
try:
cursor.execute(query)
except:
pass

query = """ALTER TABLE `websiteFunctions_packageassignment` ADD CONSTRAINT `websiteFunctions_pac_package_id_420b6aff_fk_websiteFu` FOREIGN KEY (`package_id`) REFERENCES `websiteFunctions_dockerpackages` (`id`);"""
try:
cursor.execute(query)
except:
pass

query = """ALTER TABLE `websiteFunctions_dockersites` ADD CONSTRAINT `websiteFunctions_doc_admin_id_88f5cb6d_fk_websiteFu` FOREIGN KEY (`admin_id`) REFERENCES `websiteFunctions_websites` (`id`);"""
try:
cursor.execute(query)
except:
pass

try:
connection.close()
except:
Expand Down Expand Up @@ -2184,7 +2204,6 @@ def installLSCPD(branch):
if os.path.exists(lscpdPath):
os.remove(lscpdPath)


try:
result = subprocess.run('uname -a', capture_output=True, text=True, shell=True)

Expand Down Expand Up @@ -2264,7 +2283,6 @@ def FixRSPAMDConfig():
WriteToFile.write('enabled = false;\n')
WriteToFile.close()


if os.path.exists(postfixConf):
appendpath = "/etc/postfix/main.cf"

Expand All @@ -2283,7 +2301,6 @@ def FixRSPAMDConfig():
else:
WriteToFile.write(line)


RSPAMDConfContent = '''
### Please do not edit this line, editing this line could break configurations
smtpd_milters = inet:127.0.0.1:8891, inet:127.0.0.1:11332
Expand Down Expand Up @@ -3221,9 +3238,6 @@ def CreateMissingPoolsforFPM():
WriteToFile.write(content)
WriteToFile.close()




@staticmethod
def upgrade(branch):

Expand All @@ -3241,8 +3255,8 @@ def upgrade(branch):
command = 'apt list'
Upgrade.installedOutput = subprocess.check_output(shlex.split(command)).decode()

#command = 'systemctl stop cpssh'
#Upgrade.executioner(command, 'fix csf if there', 0)
# command = 'systemctl stop cpssh'
# Upgrade.executioner(command, 'fix csf if there', 0)

## Add LSPHP7.4 TO LSWS Ent configs

Expand All @@ -3256,7 +3270,6 @@ def upgrade(branch):
# os.remove('/usr/local/lsws/conf/httpd_config.xml')
# shutil.copy('httpd_config.xml', '/usr/local/lsws/conf/httpd_config.xml')


Upgrade.updateRepoURL()

os.chdir("/usr/local")
Expand All @@ -3267,15 +3280,14 @@ def upgrade(branch):

## Current Version


### if this is a soft upgrade from front end do not stop lscpd, as lscpd is controlling the front end

if Upgrade.SoftUpgrade == 0:
command = "systemctl stop lscpd"
Upgrade.executioner(command, 'stop lscpd', 0)

Upgrade.fixSudoers()
#Upgrade.mountTemp()
# Upgrade.mountTemp()
Upgrade.dockerUsers()
Upgrade.setupComposer()

Expand Down Expand Up @@ -3397,7 +3409,6 @@ def upgrade(branch):

Upgrade.stdOut("Upgrade Completed.")


### remove log file path incase its there

if Upgrade.SoftUpgrade:
Expand Down

0 comments on commit b3de5ab

Please sign in to comment.