Created
September 12, 2019 06:52
-
-
Save spacelatte/9397d3ac65bbad6eb0d29bd1f9999b98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export USERNAME=airflow | |
export DBNAME=${USERNAME} | |
export AIRFLOW_HOME=/data | |
cd "${AIRFLOW_HOME}" | |
start() { | |
echo scheduler webserver | xargs -n1 -P9 -- airflow & | |
exit 0 | |
} | |
test -e "${AIRFLOW_HOME}/airflow.cfg" && { | |
start | |
} | |
until test -e /var/lib/pgsql/data/postgresql.conf; do | |
postgresql-setup initdb | |
done | |
echo "listen_addresses = '*'" | tee -a /var/lib/pgsql/data/postgresql.conf | |
echo "host all all 0.0.0.0/0 md5" | tee -a /var/lib/pgsql/data/pg_hba.conf | |
sed -i 's: ident:trust:g' /var/lib/pgsql/data/pg_hba.conf | |
sed -i 's: peer: trust:g' /var/lib/pgsql/data/pg_hba.conf | |
sed -i 's: md5: trust:g' /var/lib/pgsql/data/pg_hba.conf | |
systemctl enable postgresql | |
systemctl start postgresql | |
sleep 5 | |
psql -U postgres -c "create user ${USERNAME};" | |
psql -U postgres -c "create database ${DBNAME};" | |
psql -U postgres -c "grant all privileges on database ${DBNAME} to ${USERNAME};" | |
airflow initdb | |
sed -i 's/executor = .*/executor = LocalExecutor/' ${AIRFLOW_HOME}/airflow.cfg | |
sed -i 's/load_examples = True/load_examples = False/' ${AIRFLOW_HOME}/airflow.cfg | |
sed -i 's/expose_config = False/expose_config = True/' ${AIRFLOW_HOME}/airflow.cfg | |
sed -i 's/dag_run_conf_overrides_params = False/dag_run_conf_overrides_params = True/' ${AIRFLOW_HOME}/airflow.cfg | |
sed -i "s#sql_alchemy_conn = .*#sql_alchemy_conn = postgresql://localhost:5432/${DBNAME}?user=${USERNAME}#" ${AIRFLOW_HOME}/airflow.cfg | |
airflow resetdb -y | |
airflow initdb | |
start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment