Files
ProxmoxVE/ct/esphome.sh
T

103 lines
3.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 tteck
2023-03-22 20:48:20 -04:00
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://esphome.io/
2023-03-22 20:48:20 -04:00
APP="ESPHome"
var_tags="${var_tags:-automation}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-1024}"
2025-09-12 20:49:25 +02:00
var_disk="${var_disk:-10}"
var_os="${var_os:-debian}"
2026-01-07 17:01:56 +01:00
var_version="${var_version:-13}"
2026-06-12 00:16:15 +10:00
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
2023-03-22 20:48:20 -04:00
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /etc/systemd/system/esphome-device-builder.service && ! -f /etc/systemd/system/esphomeDashboard.service ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
ensure_dependencies libusb-1.0-0
2025-10-10 11:15:44 +02:00
msg_info "Stopping Service"
systemctl stop esphome-device-builder 2>/dev/null || true
systemctl stop esphomeDashboard 2>/dev/null || true
2025-10-10 11:15:44 +02:00
msg_ok "Stopped Service"
VENV_PATH="/opt/esphome/.venv"
ESPHOME_BIN="${VENV_PATH}/bin/esphome"
export PYTHON_VERSION="3.12"
if [[ ! -d "$VENV_PATH" || ! -x "$ESPHOME_BIN" ]]; then
PYTHON_VERSION="3.12" setup_uv
msg_info "Migrating to uv/venv"
rm -rf "$VENV_PATH"
mkdir -p /opt/esphome
cd /opt/esphome
$STD uv venv --clear "$VENV_PATH"
$STD "$VENV_PATH/bin/python" -m ensurepip --upgrade
$STD "$VENV_PATH/bin/python" -m pip install --upgrade pip
$STD "$VENV_PATH/bin/python" -m pip install esphome esphome-device-builder esptool
msg_ok "Migrated to uv/venv"
else
msg_info "Updating ESPHome Device Builder"
PYTHON_VERSION="3.12" setup_uv
$STD "$VENV_PATH/bin/python" -m pip install --upgrade esphome esphome-device-builder esptool
msg_ok "Updated ESPHome Device Builder"
fi
msg_info "Migrating to ESPHome Device Builder service"
if [[ -f /etc/systemd/system/esphomeDashboard.service ]]; then
systemctl disable -q esphomeDashboard 2>/dev/null || true
rm -f /etc/systemd/system/esphomeDashboard.service
fi
cat <<EOF >/etc/systemd/system/esphome-device-builder.service
[Unit]
Description=ESPHome Device Builder
After=network.target
[Service]
ExecStart=${VENV_PATH}/bin/esphome-device-builder /root/config/
Restart=always
User=root
2023-03-22 20:48:20 -04:00
[Install]
WantedBy=multi-user.target
EOF
$STD systemctl daemon-reload
$STD systemctl enable esphome-device-builder
msg_ok "Migrated to ESPHome Device Builder service"
2023-03-22 20:48:20 -04:00
2025-07-04 11:36:15 +02:00
msg_info "Linking esphome to /usr/local/bin"
rm -f /usr/local/bin/esphome
ln -s /opt/esphome/.venv/bin/esphome /usr/local/bin/esphome
msg_ok "Linked esphome binary"
2025-10-10 11:15:44 +02:00
msg_info "Starting Service"
systemctl start esphome-device-builder
2025-10-10 11:15:44 +02:00
msg_ok "Started Service"
msg_ok "Updated successfully!"
exit
2023-03-22 20:48:20 -04:00
}
start
build_container
description
2026-01-06 22:57:40 +01:00
msg_ok "Completed successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Access it using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:6052${CL}"