diff --git a/initial-configuration/install-dependencies-docker.sh b/initial-configuration/install-dependencies-docker.sh index 096f3853..5622e111 100755 --- a/initial-configuration/install-dependencies-docker.sh +++ b/initial-configuration/install-dependencies-docker.sh @@ -1,7 +1,18 @@ #!/usr/bin/env bash -CWD=`pwd` +sed_inplace() { + if [ "$(uname)" = "Darwin" ]; then + sed -i '' "$@" + else + sed -i "$@" + fi +} + +CWD=$(pwd) +# this makes tr work on OSX +export LC_CTYPE=C +export LC_ALL=C # $1 is the path to the docker-config dir $2 is the path to the rc rc_file function set_docker_config_dir { @@ -24,7 +35,7 @@ function set_docker_config_dir { # If the config dir exists, we still want to clean up old settings for it export DOCKER_CONFIG_DIR=$1 # delete any old config lines in bash config file - grep 'DOCKER_CONFIG_DIR' "$rc_file" && sed -i '/DOCKER_CONFIG_DIR/d' "$rc_file" + grep 'DOCKER_CONFIG_DIR' "$rc_file" && sed_inplace '/DOCKER_CONFIG_DIR/d' "$rc_file" echo "export DOCKER_CONFIG_DIR=$docker_config_dir" >> "$rc_file" fi } @@ -154,12 +165,12 @@ mkdir -p /var/log/httpd-docker-logs/ssl_mutex export APP_ID=`uuidgen | tr '[:upper:]' '[:lower:]'` export APP_ID_HEX=`echo $APP_ID | awk '{ print toupper($0) }'|sed 's/-//g'` -sed -i "s/__STACK_SPECIFIC_APPLICATION_ID__/$APP_ID/g" $DOCKER_CONFIG_DIR/httpd/picsureui_settings.json -sed -i "s/__STACK_SPECIFIC_APPLICATION_ID__/$APP_ID/g" $DOCKER_CONFIG_DIR/wildfly/standalone.xml +sed_inplace "s/__STACK_SPECIFIC_APPLICATION_ID__/$APP_ID/g" $DOCKER_CONFIG_DIR/httpd/picsureui_settings.json +sed_inplace "s/__STACK_SPECIFIC_APPLICATION_ID__/$APP_ID/g" $DOCKER_CONFIG_DIR/wildfly/standalone.xml export RESOURCE_ID=`uuidgen | tr '[:upper:]' '[:lower:]'` export RESOURCE_ID_HEX=`echo $RESOURCE_ID | awk '{ print toupper($0) }'|sed 's/-//g'` -sed -i "s/__STACK_SPECIFIC_RESOURCE_UUID__/$RESOURCE_ID/g" $DOCKER_CONFIG_DIR/httpd/picsureui_settings.json +sed_inplace "s/__STACK_SPECIFIC_RESOURCE_UUID__/$RESOURCE_ID/g" $DOCKER_CONFIG_DIR/httpd/picsureui_settings.json echo $APP_ID > $DOCKER_CONFIG_DIR/APP_ID_RAW echo $APP_ID_HEX > $DOCKER_CONFIG_DIR/APP_ID_HEX diff --git a/initial-configuration/mysql-docker/setup.sh b/initial-configuration/mysql-docker/setup.sh index 8475d97e..e06f169e 100755 --- a/initial-configuration/mysql-docker/setup.sh +++ b/initial-configuration/mysql-docker/setup.sh @@ -50,22 +50,22 @@ if [ -z "$(docker ps --format '{{.Names}}' | grep picsure-db)" ]; then docker exec -t picsure-db mysql -u root -p$(cat ../pass.tmp) -e "CREATE USER 'airflow'@'%' IDENTIFIED BY '$(cat airflow.tmp)';"; docker exec -t picsure-db mysql -u root -p$(cat ../pass.tmp) -e "GRANT ALL PRIVILEGES ON auth.* TO 'airflow'@'%';FLUSH PRIVILEGES;"; docker exec -t picsure-db mysql -u root -p$(cat ../pass.tmp) -e "GRANT ALL PRIVILEGES ON picsure.* TO 'airflow'@'%';FLUSH PRIVILEGES;"; - sed -i s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/auth/flyway-auth.conf - sed -i s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/auth/sql.properties - sed -i s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/picsure/flyway-picsure.conf - sed -i s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/picsure/sql.properties + sed_inplace s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/auth/flyway-auth.conf + sed_inplace s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/auth/sql.properties + sed_inplace s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/picsure/flyway-picsure.conf + sed_inplace s/__AIRFLOW_MYSQL_PASSWORD__/`cat airflow.tmp`/g $DOCKER_CONFIG_DIR/flyway/picsure/sql.properties rm -f airflow.tmp echo "` < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-24}`" > picsure.tmp docker exec -t picsure-db mysql -u root -p`cat ../pass.tmp` -e "CREATE USER 'picsure'@'%' IDENTIFIED BY '`cat picsure.tmp`';"; docker exec -t picsure-db mysql -u root -p`cat ../pass.tmp` -e "GRANT ALL PRIVILEGES ON picsure.* to 'picsure'@'%';FLUSH PRIVILEGES"; - sed -i s/__PIC_SURE_MYSQL_PASSWORD__/`cat picsure.tmp`/g $DOCKER_CONFIG_DIR/wildfly/standalone.xml + sed_inplace s/__PIC_SURE_MYSQL_PASSWORD__/`cat picsure.tmp`/g $DOCKER_CONFIG_DIR/wildfly/standalone.xml rm -f picsure.tmp echo "` < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-24}`" > auth.tmp docker exec -t picsure-db mysql -u root -p`cat ../pass.tmp` -e "CREATE USER 'auth'@'%' IDENTIFIED BY '`cat auth.tmp`';"; docker exec -t picsure-db mysql -u root -p`cat ../pass.tmp` -e "GRANT ALL PRIVILEGES ON auth.* to 'auth'@'%';FLUSH PRIVILEGES;"; - sed -i s/__AUTH_MYSQL_PASSWORD__/`cat auth.tmp`/g $DOCKER_CONFIG_DIR/wildfly/standalone.xml + sed_inplace s/__AUTH_MYSQL_PASSWORD__/`cat auth.tmp`/g $DOCKER_CONFIG_DIR/wildfly/standalone.xml rm -f auth.tmp cd $CWD