Add docker command to upgrade all containers
This commit is contained in:
		
							
								
								
									
										44
									
								
								.bin/docker-upgrade-all-containers
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								.bin/docker-upgrade-all-containers
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,44 @@ | |||||||
|  | #!/usr/bin/env bash | ||||||
|  |  | ||||||
|  | ## Mise à jour des container docker | ||||||
|  |  | ||||||
|  | readonly DOCKER_FOLDER="/srv/" | ||||||
|  |  | ||||||
|  | function ok() | ||||||
|  | { | ||||||
|  |     echo -e "\e[32mdone\e[0m" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function failed() | ||||||
|  | { | ||||||
|  |     echo -e "\e[31mfailed\e[0m" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function main() { | ||||||
|  | 	local container_list=$(find "${DOCKER_FOLDER}" -mindepth 1 -maxdepth 1 -type d ! -iname "archives" ! -iname "images" ! -iname "lost+found") | ||||||
|  | 	local container_updated=() | ||||||
|  |  | ||||||
|  | 	for container_path in ${container_list}; do | ||||||
|  | 		cd "${container_path}" | ||||||
|  | 		if [ -f docker-compose.yml ]; then | ||||||
|  | 			printf "Updating ${container_path} : \n" \ | ||||||
|  | 			&& docker-compose pull \ | ||||||
|  | 	 		&& docker-compose build --pull \ | ||||||
|  | 			&& container_updated+=(${container_path}) \ | ||||||
|  | 			&& ok \ | ||||||
|  | 			|| failed | ||||||
|  | 		fi | ||||||
|  | 		cd - &>/dev/null | ||||||
|  | 	done | ||||||
|  |  | ||||||
|  | 	for container_path in ${container_updated[*]}; do | ||||||
|  | 		cd "${container_path}" | ||||||
|  | 		docker-compose down \ | ||||||
|  | 		&& docker-compose stop \ | ||||||
|  | 		&& docker-compose up -d | ||||||
|  | 		cd - &>/dev/null | ||||||
|  | 	done | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | main | ||||||
| @@ -0,0 +1,3 @@ | |||||||
|  | function docker-upgrade-all-containers | ||||||
|  | 	bash "$HOME/.bin/docker-upgrade-all-containers" | ||||||
|  | end | ||||||
		Reference in New Issue
	
	Block a user