Skip to content

Commit

Permalink
feat(config): Add bash script to rewrite the application.yml to the o…
Browse files Browse the repository at this point in the history
…rs-config.yml

This feature intents to keep the application.yml and the ors-config.yml in sync. The ors-config.yml is intented as a minimal working configuration for users that want an up and running system without configuration. The in-depth configs are still in the ors-config.yml but commented out. The sync script will make sure in a workflow that if the original application.yml changes, the ors-config.yml mirrors the new changes but commented out.
  • Loading branch information
MichaelsJP committed Jan 29, 2024
1 parent 677a1e0 commit 965e15a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/utils/config_rewrite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "Usage: $0 input.yaml output.yaml"
exit 1
fi

input_file=$1
output_file=$2

# Add # to the beginning of each line that is not empty or a comment
awk '!/^[[:space:]]*#/ && !/^[[:space:]]*$/ {print "#" $0; next} {print}' "$input_file" > "$output_file"
# Replace '#ors:' with 'ors:'
sed -i 's/#ors:/ors:/g' "$output_file"
# Replace '# engine:' with ' engine:'
sed -i 's/# engine:/ engine:/g' "$output_file"
# Replace '# source_file:' with ' source_file: "YOUR_FILE"'
sed -i 's/# source_file:/ source_file: "YOUR_FILE"/g' "$output_file"
# Replace '# profiles:' with ' profiles:'
sed -i 's/# profiles:/ profiles:/g' "$output_file"

# Replace the default_profile. Ignore the value of enabled and always set to false.
awk -i inplace '/# profile_default:/{getline; if ($0 ~ /# enabled:/) {print " profile_default:"; print " enabled: false"; next}} {print}' "$output_file"

# Replace the individual profiles. Ignore the value of enabled and always set to false.
for profile in car hgv bike-regular bike-mountain bike-road bike-electric walking hiking public-transport; do
awk -i inplace "/# $profile:/{getline; if (\$0 ~ /# enabled:/) {print \" $profile:\"; print \" enabled: false\"; next}} {print}" "$output_file"
done

echo "Parsing complete. Result saved to $output_file"

0 comments on commit 965e15a

Please sign in to comment.