| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2017-06-20 00:30:06 +03:00
										 |  |  | # Using `+e` so that all checks are run and we get a complete report (even if some checks failed). | 
					
						
							|  |  |  | set +e -u -o pipefail | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Variables | 
					
						
							|  |  |  | exitCode=0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Helpers | 
					
						
							|  |  |  | function reportStatus { | 
					
						
							|  |  |  |   local lastExitCode=$? | 
					
						
							|  |  |  |   echo "$1: $([[ $lastExitCode -eq 0 ]] && echo OK || echo NOT OK)" | 
					
						
							|  |  |  |   [[ $lastExitCode -eq 0 ]] || exitCode=1 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Check services | 
					
						
							|  |  |  | services=( | 
					
						
							|  |  |  |   rsyslog | 
					
						
							|  |  |  |   cron | 
					
						
							|  |  |  |   nginx | 
					
						
							| 
									
										
										
										
											2017-03-02 00:05:59 +02:00
										 |  |  |   pm2-root | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | ) | 
					
						
							|  |  |  | for s in ${services[@]}; do | 
					
						
							|  |  |  |   service $s status > /dev/null | 
					
						
							|  |  |  |   reportStatus "Service '$s'" | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Check servers | 
					
						
							|  |  |  | origins=( | 
					
						
							|  |  |  |   http://$AIO_UPLOAD_HOSTNAME:$AIO_UPLOAD_PORT | 
					
						
							|  |  |  |   http://$AIO_NGINX_HOSTNAME:$AIO_NGINX_PORT_HTTP | 
					
						
							|  |  |  |   https://$AIO_NGINX_HOSTNAME:$AIO_NGINX_PORT_HTTPS | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | for o in ${origins[@]}; do | 
					
						
							|  |  |  |   curl --fail --silent $o/health-check > /dev/null | 
					
						
							|  |  |  |   reportStatus "Server '$o'" | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-27 11:38:22 +02:00
										 |  |  | # Check resolution of external URLs | 
					
						
							|  |  |  | origins=( | 
					
						
							|  |  |  |   https://google.com | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | for o in ${origins[@]}; do | 
					
						
							|  |  |  |   curl --fail --silent $o > /dev/null | 
					
						
							|  |  |  |   reportStatus "External URL '$o'" | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | # Exit | 
					
						
							|  |  |  | exit $exitCode |