| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-21 18:48:31 +02:00
										 |  |  | if ! [ -f "docker-compose.yaml" ]; then | 
					
						
							|  |  |  |   echo -e "
 | 
					
						
							|  |  |  |   \033[1;31mMissing docker-compose.yaml\033[0m | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   You are currently in \033[0;36m$(pwd)\033[0m | 
					
						
							|  |  |  |   Run this script from the root of prind to gather all necessary data. | 
					
						
							|  |  |  |   >  cd prind | 
					
						
							|  |  |  |   >  ./scripts/get-info.sh | 
					
						
							|  |  |  |   "
 | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  | echo -e "
 | 
					
						
							|  |  |  | This Script will generate an archive containing the following data: | 
					
						
							|  |  |  |   - docker system info | 
					
						
							|  |  |  |   - docker compose version | 
					
						
							| 
									
										
										
										
											2022-09-21 18:48:31 +02:00
										 |  |  |   - docker system storage metrics | 
					
						
							|  |  |  |   - docker images available | 
					
						
							|  |  |  |   - host storage usage metrics | 
					
						
							|  |  |  |   - list of currently connected devices | 
					
						
							|  |  |  |   - Containers of this stack | 
					
						
							| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  |   - Image Names and versions of currently running containers of this stack | 
					
						
							|  |  |  |   - klippy.log and moonraker.log | 
					
						
							|  |  |  |   - a full copy of this directory | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \033[1;31mWarning!\033[0m | 
					
						
							|  |  |  | The generated files might contain sensitive data like api keys. | 
					
						
							|  |  |  | Be sure to remove all data you do not wish to share before uploading the archive to the issuetracker. | 
					
						
							|  |  |  | Press [Enter] to continue or [Ctrl+C] to abort. | 
					
						
							|  |  |  | "
 | 
					
						
							|  |  |  | read | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tmpdir=$(mktemp -d --suffix=-prind) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function log { | 
					
						
							|  |  |  |   echo -e "\033[0;36m\n## ${1} \033[0m" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ( | 
					
						
							|  |  |  |   log "System Info" | 
					
						
							|  |  |  |   docker system info | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   log "Compose Version" | 
					
						
							|  |  |  |   docker compose version | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-21 18:48:31 +02:00
										 |  |  |   log "System df" | 
					
						
							|  |  |  |   docker system df | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   log "Docker Images" | 
					
						
							|  |  |  |   docker image ls | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   log "Disk Space" | 
					
						
							|  |  |  |   df -h | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   log "Connected devices" | 
					
						
							|  |  |  |   ls -l /dev | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  |   log "Image Versions of running containers" | 
					
						
							|  |  |  |   for i in $(docker compose ps --services); do | 
					
						
							| 
									
										
										
										
											2022-09-21 18:48:31 +02:00
										 |  |  |     container=$(docker compose ps -aq ${i}) | 
					
						
							| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  |     echo "${i}: $(docker inspect --format '{{ index .Config.Image }}' ${container}) $(docker inspect --format '{{ index .Config.Labels "org.prind.image.version"}}' ${container})" | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-21 18:48:31 +02:00
										 |  |  |   log "All Containers" | 
					
						
							|  |  |  |   docker compose ps -a | 
					
						
							| 
									
										
										
										
											2022-07-09 14:21:17 +02:00
										 |  |  | ) | tee ${tmpdir}/runtime-info.txt | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | log "Retrieving Klipper/Moonraker Logfiles" | 
					
						
							|  |  |  | docker compose cp klipper:/opt/log ${tmpdir} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | log "Copying current configs" | 
					
						
							|  |  |  | cp -a $(pwd) $tmpdir | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | log "Generating Archive" | 
					
						
							|  |  |  | tar --exclude-vcs -cvf prind-info-$(date +%d%m%Y-%H%M%S).tar.gz ${tmpdir} |