script-install-manual-scripts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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-2024 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. target=/usr/local/bin
  15. for script in script-*; do
  16. echo "Linking $script to $target"
  17. [[ $script == "script-functions" ]] && install -m 644 "$script" "$target"
  18. sudo ln -s "$script" "$target/"
  19. done
  20. # Install manual link
  21. remove=("manual.pdf" "manual.odt" "Notes.pdf" "Notes.odt"
  22. "README.html" "Link to Manual.desktop" "manual-images"
  23. "manual.html" "manual-images" "Manual.desktop" "manual.desktop")
  24. for homedir in /home/*; do
  25. desktop="$homedir/Desktop"
  26. [[ -d $desktop ]] || continue
  27. echo "Scanning $desktop for old manuals"
  28. for f in "${remove[@]}"; do
  29. [[ -e $desktop/$f || -L $desktop/$f ]] &&
  30. echo "Removing $desktop/$f" &&
  31. rm -f "${desktop:?}/$f"
  32. done
  33. echo "Installing manual to $desktop/manual.desktop"
  34. cat <<-EOF > "$desktop/manual.desktop"
  35. [Desktop Entry]
  36. Encoding=UTF-8
  37. Name=Hartman Lab Server Manual
  38. Type=Link
  39. URL=https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY
  40. Icon=text-html
  41. EOF
  42. done