pyenv.sh 3.9 KB

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