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.

49 lines
1.0 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. #!/bin/bash
  2. ## CONSTANTS
  3. readonly CURDIR=$PWD
  4. readonly REQUIRED_PKGS=(file git bc)
  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. wget $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. apt-get install -y "${REQUIRED_PKGS[@]}"
  34. ./init.sh
  35. fi