aded scripts
This commit is contained in:
		
							
								
								
									
										14
									
								
								deploy.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								deploy.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					#!/bin/bash -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for f in $*; do
 | 
				
			||||||
 | 
					    f=${f%.yaml}
 | 
				
			||||||
 | 
					    if ! test -e ${f}.yaml; then
 | 
				
			||||||
 | 
						echo "ERROR: no file ${f}.yaml" 1>&2
 | 
				
			||||||
 | 
						exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    echo "... deploying $f"
 | 
				
			||||||
 | 
					    for d in $(sed -n 's/^ *source: *//p' ${f}.yaml); do
 | 
				
			||||||
 | 
					        test -e $d || mkdir -p $d
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    docker stack deploy --compose-file ${f}.yaml ${f}
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
							
								
								
									
										48
									
								
								update.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										48
									
								
								update.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					limit=''
 | 
				
			||||||
 | 
					while test $# -gt 0; do
 | 
				
			||||||
 | 
					    case "$1" in
 | 
				
			||||||
 | 
						(-h|--help) cat <<EOF
 | 
				
			||||||
 | 
					$0 [OPTIONS] NAMES…
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OPTIONS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -h, --help           show this help
 | 
				
			||||||
 | 
					  -s, --limit service  limit update to given service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					NAMES…
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  list of stack names to update
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DESCRIPTION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  updates the docker images of all services in the given stacks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
							    exit;;
 | 
				
			||||||
 | 
						(-l|--limit) shift; limit=$1;;
 | 
				
			||||||
 | 
						(*) break;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					    if test $# -lt 1; then
 | 
				
			||||||
 | 
						echo "error: missing argument, try $0 --help" 1>&2
 | 
				
			||||||
 | 
						exit 1
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					    shift
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for f in $*; do
 | 
				
			||||||
 | 
					    name=${f%.yaml}
 | 
				
			||||||
 | 
					    file=${name}.yaml
 | 
				
			||||||
 | 
					    echo "upgrading ${name}"
 | 
				
			||||||
 | 
					    IFS="
 | 
				
			||||||
 | 
					"
 | 
				
			||||||
 | 
					    for param in $(sed -n '/^ *\([^:]\+\): *$/{s//'"${name}"'_\1/;h};/^ *image: */{s///;G;s/\n/ /p}' $file); do
 | 
				
			||||||
 | 
						IFS=" "
 | 
				
			||||||
 | 
						if [ -z "$limit" ] || [[ "${param}" =~ " ${name}_${limit}" ]]; then
 | 
				
			||||||
 | 
						    echo "....update $param: docker service update -d --image $param"
 | 
				
			||||||
 | 
						    docker service update -d --image $param
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Reference in New Issue
	
	Block a user