rabin 1 year ago
parent
commit
b4ea285baa

+ 6 - 1
install

@@ -20,7 +20,12 @@ fi
 mkdir -p /etc/docker
 tee /etc/docker/daemon.json <<-'EOF'
 {
-  "registry-mirrors": ["https://b2qcb7w2.mirror.aliyuncs.com"]
+  "registry-mirrors": [
+        "https://docker.mirrors.ustc.edu.cn",
+        "https://registry.docker-cn.com",
+        "http://hub-mirror.c.163.com",
+        "https://mirror.ccs.tencentyun.com"
+    ]
   ,"insecure-registries" : ["docker.dever.cc"]
 }
 EOF

+ 24 - 4
src/core.py

@@ -146,7 +146,7 @@ class Config(object):
 		core = Core.path + path + 'core.conf'
 		if File.exists(core):
 			config = configparser.ConfigParser()
-			config.read(core)
+			config.read(core, encoding='utf-8')
 			result = {}
 			for item in config.sections():
 				result[item] = self.readOption(config, item)
@@ -165,7 +165,7 @@ class Config(object):
 		filename = Core.path + path + 'conf/' + Args.name + '.conf'
 		if File.exists(filename):
 			config = configparser.ConfigParser()
-			config.read(filename)
+			config.read(filename, encoding='utf-8')
 			result = {}
 			result['server'] = []
 			result['config'] = {}
@@ -427,11 +427,23 @@ class Core(object):
 	@classmethod
 	def shell(self, command, sub=False, bg=False):
 		shell = self.path + 'src/shell/' + command.replace('.', '/', 1)
+		print(command)
 		return self.popen(shell, sub, bg)
 	@staticmethod
 	def popen(command, sub=False, bg=False):
 		string = command
-		if bg == True:
+		if Core.platform() == False:
+			if 'chmod' in command or 'ln -' in command:
+				return False
+			if 'shell' in command:
+				temp = command.split(' ')
+				command = temp[0] + '.bat ' + temp[1]
+			if 'grep' in command and '| wc -l' in command:
+				command = command.replace('grep', 'find /C')
+				command = command.replace('| wc -l', '')
+			if 'grep' in command:
+				command = command.replace('grep', 'findstr')
+		elif bg == True:
 			command = command + ' 1>/dev/null 2>&1 &'
 		if sub == False:
 			process = os.popen(command)
@@ -484,4 +496,12 @@ class Core(object):
 		s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  
 		inet = fcntl.ioctl(s.fileno(), 0x8915, struct.pack('256s', ifname[:15]))  
 		ret = socket.inet_ntoa(inet[20:24])
-		return ret
+		return ret
+
+	@staticmethod
+	def platform():
+		import platform
+		if platform.system().lower() == 'windows' :
+			return False;
+		else :
+			return True;

+ 3 - 0
src/dever.bat

@@ -0,0 +1,3 @@
+@echo off
+
+python %DEVERPATH%dever.py %*

+ 3 - 0
src/dm.bat

@@ -0,0 +1,3 @@
+@echo off
+
+python %DEVERPATH%dm.py %*

+ 1 - 1
src/main.py

@@ -12,7 +12,7 @@ class Main(object):
 
 	@classmethod
 	def init(self, use = 'docker'):
-		Core.path = File.path().replace('/src/', '/')
+		Core.path = File.path().replace('src/', '')
 		Args.init()
 		method = ('use', 'set', 'val', 'up', 'commit', 'path', 'shell', 'master', 'ip')
 		if Args.action in method:

+ 3 - 0
src/shell/container/drop.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker ps -a|awk '{print %1}'|xargs docker rm -f 

+ 3 - 0
src/shell/container/exec.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker %*

+ 3 - 0
src/shell/container/inspect.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker inspect %1

+ 3 - 0
src/shell/container/logs.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker logs %1

+ 3 - 0
src/shell/container/restart.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker restart --time=5 %1

+ 5 - 0
src/shell/container/rm.bat

@@ -0,0 +1,5 @@
+@echo off
+set -e
+
+docker stop %1
+docker rm -f %1

+ 3 - 0
src/shell/container/run.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker run %*

+ 7 - 0
src/shell/container/show.bat

@@ -0,0 +1,7 @@
+@echo off
+
+if  "%1" == "" (
+	docker ps -a
+) else (
+	docker ps -a | findstr "%1"
+)

+ 3 - 0
src/shell/container/stop.bat

@@ -0,0 +1,3 @@
+@echo off
+
+docker stop -t 5 %1

+ 5 - 0
src/shell/docker/login.bat

@@ -0,0 +1,5 @@
+@echo off
+
+set /p username=请输入username:
+set /p password=请输入password:
+docker login %1 -u %username -p %password

+ 3 - 0
src/shell/docker/name.bat

@@ -0,0 +1,3 @@
+@echo off
+  
+docker ps --format '{{.Names}}' --filter name=%1

+ 2 - 0
src/shell/docker/network.bat

@@ -0,0 +1,2 @@
+@echo off
+docker network create %*

+ 5 - 0
src/shell/image/build.bat

@@ -0,0 +1,5 @@
+#!/usr/bin/env sh
+set -e
+
+docker build --no-cache -t $1 $2
+docker images $1

+ 8 - 0
src/shell/image/drop.bat

@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+set -e
+
+if [ -n "$1" ];then
+	docker images|grep $1|awk '{print $1}'|xargs docker rmi -f
+else
+	docker images|awk '{print $3}'|xargs docker rmi -f
+fi

+ 4 - 0
src/shell/image/pull.bat

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+set -e
+
+docker pull $1

+ 10 - 0
src/shell/image/push.bat

@@ -0,0 +1,10 @@
+#!/usr/bin/env sh
+set -e
+
+if [ -n "$2" ];then
+	docker tag $1 $2
+	docker push $2
+	docker rmi -f $2
+else
+	docker push $1
+fi

+ 4 - 0
src/shell/image/rm.bat

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+set -e
+
+docker images|grep none|awk '{print $3}'|xargs docker rmi -f 

+ 4 - 0
src/shell/image/show.bat

@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+set -e
+
+docker images

+ 5 - 4
src/tool/docker.py

@@ -501,7 +501,7 @@ class Container(object):
 			
 	@staticmethod
 	def check(name):
-		result = int(Core.popen('docker ps -a | grep '+name+' | wc -l'))
+		result = int(Core.popen('docker ps -a | grep "'+name+'" | wc -l'))
 		if result != 0:
 			return 1
 		else:
@@ -514,11 +514,12 @@ class Container(object):
 			else:
 				name = 'bridge'
 			driver = '--driver=' + name
-			result = int(Core.popen('docker network ls | grep ' + config['network'] + ' | wc -l'))
+			result = int(Core.popen('docker network ls | grep "' + config['network'] + '" | wc -l'))
 			if result == 0:
 				if 'subnet' in config:
 					driver = driver + ' --subnet=' + config['subnet']
-				Core.shell('docker.network ' + driver + ' ' + config['network'], True)
+				#Core.shell('docker.network ' + driver + ' ' + config['network'], True)
+				Core.popen('docker network create ' + driver + ' ' + config['network'])
 	@staticmethod
 	def save(tar, name, backup):
 		if File.exists(tar) == True:
@@ -567,7 +568,7 @@ class Image(object):
 			Core.shell('docker.tag ' + name + ' ' + private, True)
 	@staticmethod
 	def check(name):
-		result = int(Core.popen('docker images | grep '+name+' | wc -l'))
+		result = int(Core.popen('docker images | grep "'+name+'" | wc -l'))
 		if result != 0:
 			return 1
 		else: