-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremote_docker_compose.py
More file actions
159 lines (156 loc) · 4.7 KB
/
Copy pathremote_docker_compose.py
File metadata and controls
159 lines (156 loc) · 4.7 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import os
import subprocess as sp
import time
import remote_start
import remote_main_menu
########################################## DOCKER COMPOSE #############################################
def remote_docker_compose():
os.system("clear")
while True:
remote_start.remote_start()
os.system("tput setaf 10")
print('''
[1] INSTALL DOCKER COMPOSE
[2] MAKE A NEW FILE
[3] SEE COMPOSE FILE
[4] RUN PREMADE CONTAINER
[0] BACK
[99] EXIT
''')
os.system("tput setaf 15")
i=int(input("ENTER CHOICE : "))
if i==1:
os.system(f'ssh {remote_main_menu.remoteIP} curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && ssh {remote_main_menu.remoteIP} chmod +x /usr/local/bin/docker-compose')
elif i==2:
inp=input("ENTER THE FOLDER NAME : ")
os.system(f"ssh {remote_main_menu.remoteIP} mkdir /root/{inp}")
os.system(f"ssh {remote_main_menu.remoteIP} touch /root/{inp}/docker-compose.yml")
elif i==3:
inp=input("ENTER THE FILE PATH : ")
os.system(f"ssh {remote_main_menu.remoteIP} gedit {inp}/docker-compose.yml")
elif i==4:
while True:
remote_start.remote_start()
os.system("tput setaf 10 && echo -e '[1] WORDPRESS CONTAINER\n[2] OWNCLOUD CONTAINER\n[3] NGINX SERVER\n[4] PHP\n\n[0] BACK\n[99] EXIT' && tput setaf 15")
inp=int(input("\nCHOICE : "))
if inp == 1:
inp1=input("ENTER THE PATH TO SAVE : ")
os.system(f"echo -e '''\
version: \"3\"\n\
services:\n\
dbos:\n\
image: mysql:5.7\n\
environment:\n\
MYSQL_ROOT_PASSWORD: nfsmw\n\
MYSQL_USER: milind\n\
MYSQL_PASSWORD: nfsmw\n\
MYSQL_DATABASE: mydb\n\
volumes:\n\
- mysql_storage_new:/var/lib/mysql\n\
restart: always\n\
\n\
wpos:\n\
image: wordpress:5.1.1-php7.3-apache\n\
restart: always\n\
environment:\n\
WORDPRESS_DB_HOST: dbos\n\
WORDPRESS_DB_USER: milind\n\
WORDPRESS_DB_PASSWORD: redhat\n\
WORDPRESS_DB_NAME: mydb\n\
volumes:\n\
- wp_storage_new:/var/www/html\n\
ports:\n\
- 8081:80\n\
depends_on:\n\
- dbos\n\
\n\
volumes:\n\
wp_storage_new:\n\
mysql_storage_new:''' | ssh {remote_main_menu.remoteIP} -T 'cat > {inp1}/docker-compose.yml' && ssh -t {remote_main_menu.remoteIP} 'cd {inp1};docker-compose up'")
elif inp==2:
inp1=input("ENTER THE PATH TO SAVE : ")
os.system(f"echo -e '''\
version: \"3\"\n\
services:\n\
dbos:\n\
image: mysql:5.7\n\
environment:\n\
MYSQL_ROOT_PASSWORD: nfsmw\n\
MYSQL_USER: milind\n\
MYSQL_PASSWORD: nfsmw\n\
MYSQL_DATABASE: mydb\n\
volumes:\n\
- mysql_storage_new:/var/lib/mysql\n\
restart: always\n\
owncloud:\n\
image: owncloud\n\
restart: always\n\
volumes:\n\
- owncloud_server:/var/www/html\n\
ports:\n\
- 8080:80\n\
depends_on:\n\
- dbos\n\
volumes:\n\
owncloud_server:\n\
mysql_storage_new:''' | ssh {remote_main_menu.remoteIP} -T 'cat > {inp1}/docker-compose.yml' && ssh -t {remote_main_menu.remoteIP} 'cd {inp1};docker-compose up'")
elif inp==3:
inp1=input("ENTER THE PATH TO SAVE : ")
os.system(f"echo -e '''\
version: \"3\"\n\
services:\n\
server:\n\
image: nginx\n\
ports:\n\
- 8000:80\n\
volumes:\n\
- nginx_storage_new:/var/www/html\n\
restart: always\n\
volumes:\n\
nginx_storage_new:''' | ssh {remote_main_menu.remoteIP} -T 'cat > {inp1}/docker-compose.yml' && ssh -t {remote_main_menu.remoteIP} 'cd {inp1};docker-compose up'")
elif inp==4:
inp1=input("ENTER THE PATH TO SAVE : ")
os.system(f"echo -e '''\
version: \"3\"\n\
services:\n\
php:\n\
image: mysql:5.7\n\
build:\n\
expose:\n\
- 9000\n\
volumes:\n\
- ./php/www:/var/www/html\n\
restart: always\n\
apache:\n\
image: web:v1\n\
args:\n\
- PHP_SOCKET: php:9000\n\
volumes:\n\
- ./php/www:/var/www/html\n\
ports:\n\
- 80:80\n\
- 443:443\n\
links:\n\
-php''' | ssh {remote_main_menu.remoteIP} -T 'cat > {inp1}/docker-compose.yml' && ssh -t {remote_main_menu.remoteIP} 'cd {inp1};docker-compose up'")
elif inp==0:
remote_docker_compose()
elif inp==99:
os.system("reset")
exit()
else:
os.system("tput setaf 9 && echo -e 'OPTION NOT SUPPORTED !!!' && tput setaf 15")
time.sleep(1)
os.system("tput setaf 4")
inp=input("enter to continue.......")
os.system("tput setaf 15 && clear")
elif i==0:
remote_main_menu.items()
elif i==99:
os.system("reset")
exit()
else:
os.system("tput setaf 9 && echo -e 'OPTION NOT SUPPORTED !!!' && tput setaf 15")
time.sleep(1)
os.system("tput setaf 4")
inp=input("enter to continue.......")
os.system("tput setaf 15 && clear")