MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

10 months ago
  1. #!/bin/bash
  2. REPO_TYPE=$1
  3. REPO_NAME=$2
  4. DESTINATION=${3:-.}
  5. function usage {
  6. local BASECMD=$(basename "$0")
  7. echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]'
  8. echo 'example:'
  9. echo -e '\t# REPO_TYPE=github'
  10. echo -e "\t$BASECMD github Dolibarr/dolibarr\n"
  11. echo -e '\t# REPO_TYPE=artcode'
  12. echo -e "\t$BASECMD artcode miaou/miaou-gnome\n"
  13. echo -e '\t# With destination'
  14. echo -e "\t$BASECMD artcode libre/libre-gnome /tmp # folder"
  15. echo -e "\t$BASECMD artcode libre/libre-gnome /tmp/release.tgz # file"
  16. exit -1
  17. }
  18. function get_github {
  19. local BASE="https://github.com"
  20. local release=$( wget_semver $REPO_TYPE $REPO_NAME )
  21. local url="$BASE/${REPO_NAME}/archive/refs/tags/${release}.tar.gz"
  22. if [[ -d $DESTINATION ]]; then
  23. DESTINATION="$DESTINATION/$(echo $REPO_NAME | cut -d '/' -f2 )-${release}.tgz"
  24. fi
  25. >&2 wget $url -O $DESTINATION
  26. echo $DESTINATION
  27. }
  28. [[ $# -lt 2 ]] && usage
  29. case $REPO_TYPE in
  30. github )
  31. get_github
  32. ;;
  33. * )
  34. echo "repository type <${REPO_TYPE}> not yet supported!" && exit 1
  35. ;;
  36. esac