| 
									
										
										
										
											2021-08-01 14:27:44 -07:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2021-12-01 12:46:28 +05:30
										 |  |  | #  Copyright 2021 Collate | 
					
						
							|  |  |  | #  Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  | #  you may not use this file except in compliance with the License. | 
					
						
							|  |  |  | #  You may obtain a copy of the License at | 
					
						
							|  |  |  | #  http://www.apache.org/licenses/LICENSE-2.0 | 
					
						
							|  |  |  | #  Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  | #  distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  | #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  | #  See the License for the specific language governing permissions and | 
					
						
							|  |  |  | #  limitations under the License. | 
					
						
							| 
									
										
										
										
											2021-08-02 15:08:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-30 23:55:46 +02:00
										 |  |  | DB_HOST=${DB_HOST:-mysql} | 
					
						
							|  |  |  | DB_PORT=${DB_PORT:-3306} | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-30 23:55:46 +02:00
										 |  |  | AIRFLOW_DB=${AIRFLOW_DB:-airflow_db} | 
					
						
							|  |  |  | DB_USER=${DB_USER:-airflow_user} | 
					
						
							|  |  |  | DB_SCHEME=${DB_SCHEME:-mysql+pymysql} | 
					
						
							|  |  |  | DB_PASSWORD=${DB_PASSWORD:-airflow_pass} | 
					
						
							| 
									
										
										
										
											2023-12-06 19:56:19 +05:30
										 |  |  | DB_PROPERTIES=${DB_PROPERTIES:-""} | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | AIRFLOW_ADMIN_USER=${AIRFLOW_ADMIN_USER:-admin} | 
					
						
							|  |  |  | AIRFLOW_ADMIN_PASSWORD=${AIRFLOW_ADMIN_PASSWORD:-admin} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-04 18:09:42 +05:30
										 |  |  | DB_USER_VAR=`echo "${DB_USER}" | python3 -c "import urllib.parse; encoded_user = urllib.parse.quote(input()); print(encoded_user)"` | 
					
						
							|  |  |  | DB_PASSWORD_VAR=`echo "${DB_PASSWORD}" | python3 -c "import urllib.parse; encoded_user = urllib.parse.quote(input()); print(encoded_user)"` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DB_CONN=`echo -n "${DB_SCHEME}://${DB_USER_VAR}:${DB_PASSWORD_VAR}@${DB_HOST}:${DB_PORT}/${AIRFLOW_DB}${DB_PROPERTIES}"` | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-25 14:18:41 +02:00
										 |  |  | # Set the default necessary auth_backend information | 
					
						
							|  |  |  | export AIRFLOW__API__AUTH_BACKEND=${AIRFLOW__API__AUTH_BACKENDS:-"airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session"} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Use the default airflow env var or the one we set from OM properties | 
					
						
							|  |  |  | export AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=${AIRFLOW__DATABASE__SQL_ALCHEMY_CONN:-$DB_CONN} | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-05 21:18:37 +02:00
										 |  |  | airflow db migrate | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-14 20:16:24 +05:30
										 |  |  | airflow users create \
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  |     --username ${AIRFLOW_ADMIN_USER} \
 | 
					
						
							| 
									
										
										
										
											2021-10-14 20:16:24 +05:30
										 |  |  |     --firstname Peter \
 | 
					
						
							|  |  |  |     --lastname Parker \
 | 
					
						
							|  |  |  |     --role Admin \
 | 
					
						
							|  |  |  |     --email spiderman@superhero.org \
 | 
					
						
							| 
									
										
										
										
											2022-03-16 22:54:14 -07:00
										 |  |  |     --password ${AIRFLOW_ADMIN_PASSWORD} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-20 23:37:39 +02:00
										 |  |  | # we need to this in case the container is restarted and the scheduler exited without tidying up its lock file | 
					
						
							|  |  |  | rm -f /opt/airflow/airflow-webserver-monitor.pid | 
					
						
							| 
									
										
										
										
											2022-03-24 19:26:04 +05:30
										 |  |  | airflow webserver --port 8080 -D & | 
					
						
							| 
									
										
										
										
											2022-03-09 03:21:07 +05:30
										 |  |  | airflow scheduler |