use_example_configs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. [[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x
  16. REPO=$BRANCH
  17. if [[ $# > 0 ]]; then
  18. IFS=: read -r PART1 PART2 <<< "$@"
  19. [[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \
  20. || { UDIR="$PART1" ; }
  21. RDIR="${UDIR// /%20}"
  22. echo "Fetching $UDIR configurations from $REPO..."
  23. EXAMPLES="examples/$RDIR"
  24. else
  25. EXAMPLES="default"
  26. fi
  27. CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}"
  28. restore_configs
  29. cd Marlin
  30. $TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h
  31. $TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h
  32. $TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h
  33. $TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h
  34. rm -f wgot
  35. cd - >/dev/null