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
|
2024-02-07 15:08:40 +05:00
|
|
|
def submitInstallDocker(CommandCP = 0):
|
2019-03-26 16:19:03 +05:00
|
|
|
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
|
|
|
|
2024-04-07 14:17:26 +04:00
|
|
|
command = 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
|
2020-08-03 12:16:20 +05:00
|
|
|
ServerStatusUtil.executioner(command, statusFile)
|
|
|
|
|
|
2024-04-07 14:17:26 +04:00
|
|
|
command = 'sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin --allowerasing -y'
|
2020-05-24 10:17:25 +01:00
|
|
|
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
2019-03-26 16:19:03 +05:00
|
|
|
command = 'sudo yum install -y docker'
|
|
|
|
|
else:
|
2024-02-07 11:25:01 +05:00
|
|
|
command = 'DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose'
|
2019-03-26 16:19:03 +05:00
|
|
|
|
2024-02-07 15:08:40 +05:00
|
|
|
if CommandCP:
|
|
|
|
|
ProcessUtilities.executioner(command, 'root', True)
|
|
|
|
|
else:
|
|
|
|
|
if not ServerStatusUtil.executioner(command, statusFile):
|
|
|
|
|
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath,
|
|
|
|
|
"Failed to install Docker. [404]\n", 1)
|
|
|
|
|
return 0
|
2019-03-26 16:19:03 +05:00
|
|
|
|
|
|
|
|
command = 'sudo systemctl enable docker'
|
2024-02-07 15:08:40 +05:00
|
|
|
|
|
|
|
|
ProcessUtilities.executioner(command, 'root', True)
|
2019-03-26 16:19:03 +05:00
|
|
|
|
|
|
|
|
command = 'sudo systemctl start docker'
|
2024-02-07 15:08:40 +05:00
|
|
|
ProcessUtilities.executioner(command, 'root', True)
|
2019-03-26 16:19:03 +05:00
|
|
|
|
|
|
|
|
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)
|
2024-02-05 14:18:49 +05:00
|
|
|
def main():
|
|
|
|
|
DockerInstall.submitInstallDocker()
|
2019-03-26 16:19:03 +05:00
|
|
|
|
2024-02-05 14:18:49 +05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|