-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.py
More file actions
37 lines (30 loc) · 1.07 KB
/
Copy pathinstall.py
File metadata and controls
37 lines (30 loc) · 1.07 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
import os
import subprocess
import threading
import time
def show_progress():
spinstr = '|/-\\'
idx = 0
while True:
print(f' [{spinstr[idx % len(spinstr)]}]', end='\r')
idx += 1
time.sleep(0.1)
def install_docker():
subprocess.run('curl -fsSL https://get.docker.com | sh', shell=True, check=True)
def configure_docker():
os.makedirs('/etc/docker', exist_ok=True)
with open('/etc/docker/daemon.json', 'w') as f:
f.write('{\n'
' "insecure-registries": ["https://docker.arvancloud.ir"],\n'
' "registry-mirrors": ["https://docker.arvancloud.ir"]\n'
'}')
subprocess.run(['docker', 'logout'], check=True)
subprocess.run(['systemctl', 'daemon-reload'], check=True)
subprocess.run(['systemctl', 'restart', 'docker'], check=True)
if __name__ == "__main__":
progress_thread = threading.Thread(target=show_progress)
progress_thread.daemon = True
progress_thread.start()
install_docker()
configure_docker()
print("All tasks completed successfully.")