octoprint-install.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies"
  14. $STD apt-get install -y curl
  15. $STD apt-get install -y sudo
  16. $STD apt-get install -y mc
  17. $STD apt-get install -y git
  18. $STD apt-get install -y libyaml-dev
  19. $STD apt-get install -y build-essential
  20. msg_ok "Installed Dependencies"
  21. msg_info "Updating Python3"
  22. $STD apt-get install -y \
  23. python3 \
  24. python3-dev \
  25. python3-pip \
  26. python3-venv
  27. $STD apt-get install -y python3-setuptools
  28. msg_ok "Updated Python3"
  29. msg_info "Creating user octoprint"
  30. useradd -m -s /bin/bash -p $(openssl passwd -1 octoprint) octoprint
  31. usermod -aG sudo,tty,dialout octoprint
  32. chown -R octoprint:octoprint /opt
  33. msg_ok "Created user octoprint"
  34. msg_info "Installing OctoPrint"
  35. $STD sudo -u octoprint bash << EOF
  36. mkdir /opt/octoprint
  37. cd /opt/octoprint
  38. python3 -m venv .
  39. source bin/activate
  40. pip install --upgrade pip
  41. pip install wheel
  42. pip install octoprint
  43. EOF
  44. msg_ok "Installed OctoPrint"
  45. msg_info "Creating Service"
  46. cat <<EOF >/etc/systemd/system/octoprint.service
  47. [Unit]
  48. Description=The snappy web interface for your 3D printer
  49. After=network-online.target
  50. Wants=network-online.target
  51. [Service]
  52. Environment="LC_ALL=C.UTF-8"
  53. Environment="LANG=C.UTF-8"
  54. Type=exec
  55. User=octoprint
  56. ExecStart=/opt/octoprint/bin/octoprint serve
  57. [Install]
  58. WantedBy=multi-user.target
  59. EOF
  60. systemctl enable -q --now octoprint.service
  61. msg_ok "Created Service"
  62. motd_ssh
  63. customize
  64. msg_info "Cleaning up"
  65. $STD apt-get autoremove
  66. $STD apt-get autoclean
  67. msg_ok "Cleaned"