forked from usmannasir/cyberpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerInstall.py
executable file
·51 lines (36 loc) · 2.06 KB
/
dockerInstall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/local/CyberCP/bin/python
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)
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo'
ServerStatusUtil.executioner(command, statusFile)
command = 'sudo dnf install -y docker-ce --nobest'
elif ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'sudo yum install -y docker'
else:
command = 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io'
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)
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
DockerInstall.submitInstallDocker()