octoprint-install.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "Installing Python3"
  22. $STD apt-get install -y \
  23. python3-pip \
  24. python3-dev \
  25. python3-setuptools \
  26. python3-venv
  27. msg_ok "Installed Python3"
  28. msg_info "Creating user octoprint"
  29. useradd -m -s /bin/bash -p $(openssl passwd -1 octoprint) octoprint
  30. usermod -aG sudo,tty,dialout octoprint
  31. chown -R octoprint:octoprint /opt
  32. msg_ok "Created user octoprint"
  33. msg_info "Installing OctoPrint"
  34. $STD sudo -u octoprint bash << EOF
  35. mkdir /opt/octoprint
  36. cd /opt/octoprint
  37. python3 -m venv .
  38. source bin/activate
  39. pip install --upgrade pip
  40. pip install wheel
  41. pip install octoprint
  42. EOF
  43. msg_ok "Installed OctoPrint"
  44. msg_info "Creating Service"
  45. cat <<EOF >/etc/systemd/system/octoprint.service
  46. [Unit]
  47. Description=The snappy web interface for your 3D printer
  48. After=network-online.target
  49. Wants=network-online.target
  50. [Service]
  51. Environment="LC_ALL=C.UTF-8"
  52. Environment="LANG=C.UTF-8"
  53. Type=exec
  54. User=octoprint
  55. ExecStart=/opt/octoprint/bin/octoprint serve
  56. [Install]
  57. WantedBy=multi-user.target
  58. EOF
  59. systemctl enable -q --now octoprint.service
  60. msg_ok "Created Service"
  61. motd_ssh
  62. customize
  63. msg_info "Cleaning up"
  64. $STD apt-get autoremove
  65. $STD apt-get autoclean
  66. msg_ok "Cleaned"