use_example_configs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. #
  3. # use_example_configs [repo:]configpath
  4. #
  5. # Examples:
  6. # use_example_configs
  7. # use_example_configs Creality/CR-10/CrealityV1
  8. # use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1
  9. #
  10. # If a configpath has spaces (or quotes) escape them or enquote the path
  11. #
  12. which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot'
  13. which wget >/dev/null && TOOL='wget -q -O wgot'
  14. CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
  15. REPO=bugfix-2.0.x
  16. if [[ $# > 0 ]]; then
  17. IFS=: read -r PART1 PART2 <<< "$@"
  18. [[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \
  19. || { UDIR="$PART1" ; }
  20. RDIR="${UDIR// /%20}"
  21. echo "Fetching $UDIR configurations from $REPO..."
  22. EXAMPLES="examples/$RDIR"
  23. else
  24. EXAMPLES="default"
  25. fi
  26. CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}"
  27. restore_configs
  28. cd Marlin
  29. $TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
  30. $TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
  31. $TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
  32. $TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
  33. rm -f wgot
  34. cd - >/dev/null