Skip to content

Commit

Permalink
Enhance the Setup Shell Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
markaspot committed Dec 8, 2023
1 parent 03c8ef1 commit 2b2d5e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
16 changes: 11 additions & 5 deletions scripts/georeport-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ echo "--------------------------------------------------------------------------


for i in $(seq 1 50); do
RANDOM_1=$(awk -v min=-1 -v max=1 'BEGIN{srand(); print min+rand()*(max-min)}')
RANDOM_2=$(awk -v min=-1 -v max=1 'BEGIN{srand(); print min+rand()*(max-min)}')
# Generate a random angle in radians between 0 and 2*pi
RANDOM_ANGLE=$(awk -v seed="$RANDOM$((i * 10))" 'BEGIN {srand(seed); print rand() * 2 * 3.141592653589793;}')

# Generate a random radius within the circle
RANDOM_RADIUS=$(awk -v seed="$RANDOM$((i * 10))" -v max="$RADIUS_IN_DEGREES" 'BEGIN {srand(seed); print sqrt(rand()) * max;}')

LATITUDE=$(awk -v center_lat="$CENTER_LAT" -v radius="$RADIUS_IN_DEGREES" -v random_1="$RANDOM_1" 'BEGIN {print center_lat + (radius * random_1)}')
LONGITUDE=$(awk -v center_lng="$CENTER_LNG" -v radius="$RADIUS_IN_DEGREES" -v random_2="$RANDOM_2" 'BEGIN {print center_lng + (radius * random_2)}')
# Calculate the latitude and longitude offsets
LATITUDE_OFFSET=$(awk -v radius="$RANDOM_RADIUS" -v angle="$RANDOM_ANGLE" 'BEGIN {print radius * sin(angle);}')
LONGITUDE_OFFSET=$(awk -v radius="$RANDOM_RADIUS" -v angle="$RANDOM_ANGLE" 'BEGIN {print radius * cos(angle);}')

# Calculate the actual latitude and longitude
LATITUDE=$(awk -v center_lat="$CENTER_LAT" -v offset="$LATITUDE_OFFSET" 'BEGIN {print center_lat + offset;}')
LONGITUDE=$(awk -v center_lng="$CENTER_LNG" -v offset="$LONGITUDE_OFFSET" 'BEGIN {print center_lng + offset;}')

RANDOM_SERVICE_CODE=$(printf "%s\n" "$SERVICES" | awk 'BEGIN {srand();}{a[NR]=$0}END{print a[int(rand()*NR)+1]}')
EMAIL="test_$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c10)@example.com"
Expand Down Expand Up @@ -81,4 +87,4 @@ for i in $(seq 1 50); do
printf "%-10s %-30s %-15s %-15s %-12s %-15s %-8s\n" "$i" "$EMAIL" "$LATITUDE" "$LONGITUDE" "$REQUEST_TIME" "$RESPONSE" "$RANDOM_SERVICE_CODE"
done

echo "------------------------------------------------------------------------------------------------------------------"
echo "------------------------------------------------------------------------------------------------------------------"
11 changes: 6 additions & 5 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
fi

printf "\e[32mInstall all libraries with composer..\e[0m\n"
composer install --no-dev

composer install

if [ "$ENVIRONMENT" != "prod" ]; then
printf "\e[32mNo Prod deployment. Installing Drupal with the Mark-a-Spot Distribution...\e[0m\n"

# Define the path to the Drupal settings file
SETTINGS_FILE="/app/data/web/sites/default/settings.php"
Expand Down Expand Up @@ -49,12 +53,9 @@ fi
sed -i "s|# \$settings\['config_sync_directory'\] = '/directory/outside/webroot';|\$settings['config_sync_directory'] = '../config/sync';|" "$SETTINGS_FILE"


echo "Custom configuration added to $SETTINGS_FILE"
printf "\e[32mCustom configuration added to $SETTINGS_FILE"



if [ "$ENVIRONMENT" != "prod" ]; then
printf "\e[32mNo Prod deployment. Installing Drupal with the Mark-a-Spot Distribution...\e[0m\n"
printf "\e[36mDropping all tables in the database...\e[0m\n"
drush sql-drop -y
printf "\e[36mExecuting the Markaspot:install command...\e[0m\n"
Expand Down

0 comments on commit 2b2d5e9

Please sign in to comment.