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.

52 lines
1.2 KiB

8 months ago
8 months ago
6 months ago
8 months ago
8 months ago
8 months ago
8 months ago
6 months ago
  1. #!/bin/bash
  2. ## CONSTANTS
  3. readonly CURDIR=$PWD
  4. readonly REQUIRED_PKGS=(file git bc vim)
  5. readonly MAIN_TAR_GZ_URL="https://git.artcode.re/miaou/miaou-bash/archive/main.tar.gz"
  6. ## FUNCTIONS
  7. function push_directory {
  8. pushd "$1" || (echo "unable to push directory <$1>" && exit 1)
  9. }
  10. function pop_directory {
  11. popd || (echo "unable to pop from previous directory" && exit 1)
  12. }
  13. function root_required {
  14. [ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1
  15. }
  16. ## MAIN
  17. root_required
  18. if [[ $CURDIR != '/opt/miaou-bash' ]]; then
  19. # download and fullfill /opt/miaou-bash, then run it from folder
  20. if [[ -L /opt/miaou-bash ]]; then
  21. /opt/miaou-bash/install.sh
  22. else
  23. rm -rf /opt/miaou-bash
  24. push_directory "$(mktemp -d)"
  25. curl --no-progress-meter -O $MAIN_TAR_GZ_URL
  26. tar -xzf main.tar.gz
  27. mv miaou-bash /opt/
  28. pop_directory
  29. rm -rf "$TEMP"
  30. push_directory /opt/miaou-bash && ./install.sh
  31. fi
  32. else
  33. MIAOU_BASH_DIR=$CURDIR
  34. export MIAOU_BASH_DIR
  35. source "$MIAOU_BASH_DIR/lib/functions.sh"
  36. "$MIAOU_BASH_DIR/tools/idem_apt_install" "${REQUIRED_PKGS[@]}"
  37. ./init.sh
  38. fi