pyenv.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. set -e
  7. YW=$(echo "\033[33m")
  8. RD=$(echo "\033[01;31m")
  9. BL=$(echo "\033[36m")
  10. GN=$(echo "\033[1;92m")
  11. CL=$(echo "\033[m")
  12. CM="${GN}✓${CL}"
  13. CROSS="${RD}✗${CL}"
  14. BFR="\\r\\033[K"
  15. HOLD="-"
  16. function msg_info() {
  17. local msg="$1"
  18. echo -ne " ${HOLD} ${YW}${msg}..."
  19. }
  20. function msg_ok() {
  21. local msg="$1"
  22. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  23. }
  24. function msg_error() {
  25. local msg="$1"
  26. echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
  27. }
  28. if command -v pveversion >/dev/null 2>&1; then msg_error "Can't Install on Proxmox "; exit; fi
  29. msg_info "Installing pyenv"
  30. apt-get install -y \
  31. make \
  32. build-essential \
  33. libjpeg-dev \
  34. libpcap-dev \
  35. libssl-dev \
  36. zlib1g-dev \
  37. libbz2-dev \
  38. libreadline-dev \
  39. libsqlite3-dev \
  40. autoconf \
  41. git \
  42. curl \
  43. sudo \
  44. llvm \
  45. libncursesw5-dev \
  46. xz-utils \
  47. tk-dev \
  48. libxml2-dev \
  49. libxmlsec1-dev \
  50. libffi-dev \
  51. libopenjp2-7 \
  52. libtiff5 \
  53. libturbojpeg0-dev \
  54. liblzma-dev &>/dev/null
  55. git clone https://github.com/pyenv/pyenv.git ~/.pyenv &>/dev/null
  56. set +e
  57. echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  58. echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  59. echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc
  60. msg_ok "Installed pyenv"
  61. . ~/.bashrc
  62. set -e
  63. msg_info "Installing Python 3.11.1"
  64. pyenv install 3.11.1 &>/dev/null
  65. pyenv global 3.11.1
  66. msg_ok "Installed Python 3.11.1"
  67. read -r -p "Would you like to install Home Assistant Beta? <y/N> " prompt
  68. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  69. msg_info "Installing Home Assistant Beta"
  70. cat <<EOF >/etc/systemd/system/homeassistant.service
  71. [Unit]
  72. Description=Home Assistant
  73. After=network-online.target
  74. [Service]
  75. Type=simple
  76. WorkingDirectory=/root/.homeassistant
  77. ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
  78. RestartForceExitStatus=100
  79. [Install]
  80. WantedBy=multi-user.target
  81. EOF
  82. mkdir /srv/homeassistant
  83. cd /srv/homeassistant
  84. python3 -m venv .
  85. source bin/activate
  86. python3 -m pip install wheel &>/dev/null
  87. pip3 install --upgrade pip &>/dev/null
  88. pip3 install psycopg2-binary &>/dev/null
  89. pip3 install --pre homeassistant &>/dev/null
  90. systemctl enable homeassistant &>/dev/null
  91. msg_ok "Installed Home Assistant Beta"
  92. echo -e " Go to $(hostname -I | awk '{print $1}'):8123"
  93. hass
  94. fi
  95. read -r -p "Would you like to install ESPHome Beta? <y/N> " prompt
  96. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  97. msg_info "Installing ESPHome Beta"
  98. mkdir /srv/esphome
  99. cd /srv/esphome
  100. python3 -m venv .
  101. source bin/activate
  102. python3 -m pip install wheel &>/dev/null
  103. pip3 install --upgrade pip &>/dev/null
  104. pip3 install --pre esphome &>/dev/null
  105. cat <<EOF >/srv/esphome/start.sh
  106. #!/usr/bin/env bash
  107. # Copyright (c) 2021-2023 tteck
  108. # Author: tteck (tteckster)
  109. # License: MIT
  110. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  111. source /srv/esphome/bin/activate
  112. esphome dashboard /srv/esphome/
  113. EOF
  114. chmod +x start.sh
  115. cat <<EOF >/etc/systemd/system/esphomedashboard.service
  116. [Unit]
  117. Description=ESPHome Dashboard Service
  118. After=network.target
  119. [Service]
  120. Type=simple
  121. User=root
  122. WorkingDirectory=/srv/esphome
  123. ExecStart=/srv/esphome/start.sh
  124. RestartSec=30
  125. Restart=on-failure
  126. [Install]
  127. WantedBy=multi-user.target
  128. EOF
  129. systemctl enable --now esphomedashboard &>/dev/null
  130. msg_ok "Installed ESPHome Beta"
  131. echo -e " Go to $(hostname -I | awk '{print $1}'):6052"
  132. exec $SHELL
  133. fi
  134. read -r -p "Would you like to install Matter-Server (Beta)? <y/N> " prompt
  135. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  136. msg_info "Installing Matter Server"
  137. apt-get install -y \
  138. libcairo2-dev \
  139. libjpeg62-turbo-dev \
  140. libgirepository1.0-dev \
  141. libpango1.0-dev \
  142. libgif-dev \
  143. g++ &>/dev/null
  144. python3 -m pip install wheel
  145. pip3 install --upgrade pip
  146. pip install python-matter-server[server]
  147. msg_ok "Installed Matter Server"
  148. echo -e "Start server > python -m matter_server.server"
  149. fi
  150. msg_ok "\nFinished\n"
  151. exec $SHELL