Skip to content

Commit

Permalink
[ALS-5579] Fix osx specific command bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina authored and Luke-Sikina committed Apr 9, 2024
1 parent 264d2f9 commit 82b8471
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
21 changes: 16 additions & 5 deletions initial-configuration/install-dependencies-docker.sh
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions initial-configuration/mysql-docker/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82b8471

Please sign in to comment.