script-install-manual-scripts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # This script will add scripts-* to the PATH and the manual to each user's desktop
  3. # Copyright 2021-2023 Bryan C. Roessler
  4. parent="${BASH_SOURCE[0]}"
  5. parent=${parent%/*}
  6. reload=0
  7. [[ -f $parent/script-functions ]] && . "$parent"/script-functions || reload=1
  8. sourcedir="/home/roessler/shared/hartmanlab"
  9. original_dir="$PWD"
  10. if [[ "$original_dir" != "$sourcedir" ]]; then
  11. pushd "$sourcedir" || exit $?
  12. fi
  13. (( reload )) && [[ -f $parent/script-functions ]] && . "$parent"/script-functions
  14. is_root
  15. target=/usr/local/bin
  16. for script in script-*; do
  17. echo "Installing $script to $target"
  18. [[ $script == "script-functions" ]] && install -m 644 "$script" "$target"
  19. cp -u "$script" "$target/"
  20. done
  21. # Install manual link
  22. remove=("manual.pdf" "manual.odt" "Notes.pdf" "Notes.odt"
  23. "README.html" "Link to Manual.desktop" "manual-images"
  24. "manual.html" "manual-images" "Manual.desktop" "manual.desktop")
  25. for homedir in /home/*; do
  26. desktop="$homedir/Desktop"
  27. [[ -d $desktop ]] || continue
  28. echo "Scanning $desktop for old manuals"
  29. for f in "${remove[@]}"; do
  30. [[ -e $desktop/$f || -L $desktop/$f ]] &&
  31. echo "Removing $desktop/$f" &&
  32. rm -f "${desktop:?}/$f"
  33. done
  34. echo "Installing manual to $desktop/manual.desktop"
  35. cat <<-EOF > "$desktop/manual.desktop"
  36. [Desktop Entry]
  37. Encoding=UTF-8
  38. Name=Hartman Lab Server Manual
  39. Type=Link
  40. URL=https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY
  41. Icon=text-html
  42. EOF
  43. done