script-deploy-manual 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # This script installs the Hartman Lab Server Manual to each user's desktop
  3. # Usage: script-deploy-manual USERNAME|--all
  4. # Copyright 2021-2025 Bryan C. Roessler
  5. # Licensed under the Apache License, Version 2.0
  6. script-deploy-manual() {
  7. local user_arg="$1"
  8. local manual_url="https://docs.google.com/document/d/1K_KwAlv8Zljmy-enwmhT6gMTFutlAFglixvpLGBx0VY"
  9. local remove=("manual.pdf" "manual.odt" "Notes.pdf" "Notes.odt" \
  10. "README.html" "Link to Manual.desktop" "manual-images" \
  11. "manual.html" "Manual.desktop" "manual.desktop")
  12. local users=()
  13. if [[ "$user_arg" == "--all" ]]; then
  14. for d in /home/*; do [[ -d $d ]] && users+=("${d##*/}"); done
  15. else
  16. users+=("$user_arg")
  17. fi
  18. for user in "${users[@]}"; do
  19. desktop="/home/$user/Desktop"
  20. [[ -d $desktop ]] || continue
  21. echo "Scanning $desktop for old manuals"
  22. for f in "${remove[@]}"; do
  23. if [[ -e $desktop/$f || -L $desktop/$f ]]; then
  24. echo "Removing $desktop/$f"
  25. rm -f "${desktop:?}/$f"
  26. fi
  27. done
  28. echo "Installing manual to $desktop/manual.desktop"
  29. cat <<-EOF > "$desktop/manual.desktop"
  30. [Desktop Entry]
  31. Encoding=UTF-8
  32. Name=Hartman Lab Server Manual
  33. Type=Link
  34. URL=$manual_url
  35. Icon=text-html
  36. EOF
  37. done
  38. }
  39. # Allow script to be safely sourced
  40. if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
  41. script-deploy-manual "$@"
  42. exit $?
  43. fi