script-functions 763 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. # Common functions for the lab scripts
  3. # Copyright Bryan C. Roessler
  4. # Don't run this script directly
  5. [[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
  6. ### VARS ###
  7. export INSTALL_DIR=/usr/local/bin
  8. ### FUNCTIONS ###
  9. prompt() { read -r -p "Enter $1: " "$1"; }
  10. ask_ok() {
  11. declare response
  12. (( YES_SWITCH )) && return 0
  13. read -r -p "$* [y/N]: " response
  14. [[ ${response,,} =~ ^(yes|y)$ ]]
  15. }
  16. is_root() {
  17. [[ $EUID -gt 0 ]] && echo "Script must be run with sudo" && exit 1
  18. }
  19. copy_manual() {
  20. cat <<-EOF > "$1/manual.desktop"
  21. [Desktop Entry]
  22. Encoding=UTF-8
  23. Name=Hartman Lab Server Manual
  24. Type=Link
  25. URL=https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY
  26. Icon=text-html
  27. EOF
  28. }