2019-12-10 23:04:24 +05:00
|
|
|
#!/usr/local/CyberCP/bin/python
|
2019-03-26 16:19:03 +05:00
|
|
|
import sys
|
|
|
|
|
sys.path.append('/usr/local/CyberCP')
|
|
|
|
|
import plogical.CyberCPLogFileWriter as logging
|
|
|
|
|
from serverStatus.serverStatusUtil import ServerStatusUtil
|
|
|
|
|
from plogical.processUtilities import ProcessUtilities
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DockerInstall:
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def submitInstallDocker():
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
|
|
|
|
|
|
|
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Starting Docker Installation..\n", 1)
|
|
|
|
|
|
2020-05-24 10:17:25 +01:00
|
|
|
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
2020-08-03 12:16:20 +05:00
|
|
|
|
|
|
|
|
command = 'dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo'
|
|
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
2020-05-24 10:17:25 +01:00
|
|
|
command = 'sudo dnf install -y docker-ce --nobest'
|
|
|
|
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
2019-03-26 16:19:03 +05:00
|
|
|
command = 'sudo yum install -y docker'
|
|
|
|
|
else:
|
2024-02-03 15:05:07 +05:00
|
|
|
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose'
|
2019-03-26 16:19:03 +05:00
|
|
|
|
|
|
|
|
if not ServerStatusUtil.executioner(command, statusFile):
|
|
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Failed to install Docker. [404]\n", 1)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
command = 'sudo systemctl enable docker'
|
|
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
|
|
|
|
command = 'sudo systemctl start docker'
|
|
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
|
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Docker successfully installed.[200]\n", 1)
|
|
|
|
|
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
2019-12-10 15:09:10 +05:00
|
|
|
except BaseException as msg:
|
2019-03-26 16:19:03 +05:00
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
|
|
|
|
|
|
|
|
|
DockerInstall.submitInstallDocker()
|