pyenv.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.10.8"
  64. pyenv install 3.10.8 &>/dev/null
  65. pyenv global 3.10.8
  66. msg_ok "Installed Python 3.10.8"
  67. read -r -p "Would you like to install Home Assistant Beta? <y/N> " prompt
  68. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  69. HA="Y"
  70. fi
  71. if [[ $HA == "Y" ]]; then
  72. msg_info "Installing Home Assistant Beta"
  73. cat <<EOF >/etc/systemd/system/homeassistant.service
  74. [Unit]
  75. Description=Home Assistant
  76. After=network-online.target
  77. [Service]
  78. Type=simple
  79. WorkingDirectory=/root/.homeassistant
  80. ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
  81. RestartForceExitStatus=100
  82. [Install]
  83. WantedBy=multi-user.target
  84. EOF
  85. mkdir /srv/homeassistant
  86. cd /srv/homeassistant
  87. python3 -m venv .
  88. source bin/activate
  89. python3 -m pip install wheel &>/dev/null
  90. pip3 install --upgrade pip &>/dev/null
  91. pip3 install psycopg2-binary &>/dev/null
  92. pip3 install --pre homeassistant &>/dev/null
  93. systemctl enable homeassistant &>/dev/null
  94. msg_ok "Installed Home Assistant Beta"
  95. echo -e " Go to $(hostname -I | awk '{print $1}'):8123"
  96. hass
  97. fi
  98. read -r -p "Would you like to install ESPHome Beta? <y/N> " prompt
  99. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  100. ESP="Y"
  101. fi
  102. if [[ $ESP == "Y" ]]; then
  103. msg_info "Installing ESPHome Beta"
  104. mkdir /srv/esphome
  105. cd /srv/esphome
  106. python3 -m venv .
  107. source bin/activate
  108. python3 -m pip install wheel &>/dev/null
  109. pip3 install --upgrade pip &>/dev/null
  110. pip3 install --pre esphome &>/dev/null
  111. cat <<EOF >/srv/esphome/start.sh
  112. #!/usr/bin/env bash
  113. # Copyright (c) 2021-2023 tteck
  114. # Author: tteck (tteckster)
  115. # License: MIT
  116. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  117. source /srv/esphome/bin/activate
  118. esphome dashboard /srv/esphome/
  119. EOF
  120. chmod +x start.sh
  121. cat <<EOF >/etc/systemd/system/esphomedashboard.service
  122. [Unit]
  123. Description=ESPHome Dashboard Service
  124. After=network.target
  125. [Service]
  126. Type=simple
  127. User=root
  128. WorkingDirectory=/srv/esphome
  129. ExecStart=/srv/esphome/start.sh
  130. RestartSec=30
  131. Restart=on-failure
  132. [Install]
  133. WantedBy=multi-user.target
  134. EOF
  135. systemctl enable --now esphomedashboard &>/dev/null
  136. msg_ok "Installed ESPHome Beta"
  137. echo -e " Go to $(hostname -I | awk '{print $1}'):6052"
  138. exec $SHELL
  139. fi
  140. read -r -p "Would you like to install Matter-Server (Beta)? <y/N> " prompt
  141. if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  142. MTR="Y"
  143. fi
  144. if [[ $MTR == "Y" ]]; then
  145. msg_info "Installing Matter Server"
  146. apt-get install -y \
  147. libcairo2-dev \
  148. libjpeg62-turbo-dev \
  149. libgirepository1.0-dev \
  150. libpango1.0-dev \
  151. libgif-dev \
  152. g++ &>/dev/null
  153. python3 -m pip install wheel
  154. pip3 install --upgrade pip
  155. pip install python-matter-server[server]
  156. msg_ok "Installed Matter Server"
  157. echo -e "Start server > python -m matter_server.server"
  158. fi
  159. msg_ok "\nFinished\n"
  160. exec $SHELL