03-oct: migracion juanjo - rutas dinamicas (.py/.ps1/.ts) + changelog (apps, OmniRoute 3.8.51, UFW 5001)

This commit is contained in:
Juanjo Minguez
2026-10-03 22:24:12 +02:00
parent 3f20313f6d
commit a75211cd05
17 changed files with 104 additions and 41 deletions

View File

@@ -9,12 +9,12 @@ Start-Transcript -Path $log -Force | Out-Null
Write-Output "=== BOOTSTRAP AUTOLOGON $(Get-Date -Format s) ==="
Write-Output "Usuario: $env:USERDOMAIN\$env:USERNAME"
$infra = 'C:\Users\juanm\Documents\Github\INFRAESTRUCTURA'
$bib = 'C:\Users\juanm\Documents\Github\biblioteca_negocio_prolongo'
$infra = Join-Path $env:USERPROFILE 'Documents\Github\INFRAESTRUCTURA'
$bib = Join-Path $env:USERPROFILE 'Documents\Github\biblioteca_negocio_prolongo'
$pwsh = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe'
# 1) Git: identidad + safe.directory (los repos son de otro usuario) + helper
git config --global user.name "juanminsanz"
git config --global user.name "Juanjo Minguez"
git config --global user.email "desarrollo@faccsa.es"
git config --global --add safe.directory '*'
git config --global credential.helper manager

View File

@@ -2,7 +2,7 @@ import requests
import os
from dotenv import load_dotenv
load_dotenv(r'C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env')
load_dotenv(os.path.expanduser('~/Documents/GitHub/biblioteca_negocio_prolongo/.env'))
url = os.getenv('HOMEASSISTANT_URL')
token = os.getenv('HOMEASSISTANT_TOKEN')

View File

@@ -15,7 +15,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar .env
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def main():

View File

@@ -20,7 +20,7 @@ def check_homeassistant():
"""Verifica si Home Assistant esta corriendo en el VPS"""
try:
result = subprocess.run(
["ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
["ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
"docker ps | grep homeassistant | grep -q Up && echo OK || echo NOK"],
capture_output=True,
@@ -49,7 +49,7 @@ Add-Type -AssemblyName System.Windows.Forms
try:
subprocess.run([
"python",
r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\scripts\aviso_sonoro.py",
os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/scripts/aviso_sonoro.py"),
"ok"
])
except Exception:

View File

@@ -6,7 +6,7 @@ import urllib.request
from dotenv import load_dotenv
# Cargar variables de entorno locales (.env de biblioteca_negocio_prolongo)
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
# Permitir importar modulos del repo de negocio (ha_alexa).

View File

@@ -23,7 +23,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar variables de entorno locales (.env de biblioteca_negocio_prolongo)
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def cerrar_ventanas():
@@ -101,7 +101,7 @@ p100.turnOff()"""
# Comando SSH en dos saltos: local -> VPS -> RPi
cmd = [
"ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
"ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
f"ssh -i /root/.ssh/pi_deploy -p 2222 -o StrictHostKeyChecking=no pi@127.0.0.1 'python3 -c \"{tapo_script}\"'"
]

View File

@@ -23,7 +23,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar variables de entorno locales (.env de biblioteca_negocio_prolongo)
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def cerrar_ventanas():
@@ -101,14 +101,14 @@ p100.turnOff()"""
# Paso 1: Crear script en VPS
cmd1 = [
"ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
"ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
f"echo '{script_content}' > /tmp/tapo_off.py"
]
# Paso 2: Copiar a RPi y ejecutar
cmd2 = [
"ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
"ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
"scp -i /root/.ssh/pi_deploy -P 2222 -o StrictHostKeyChecking=no /tmp/tapo_off.py pi@127.0.0.1:/tmp/ && ssh -i /root/.ssh/pi_deploy -p 2222 -o StrictHostKeyChecking=no pi@127.0.0.1 'python3 /tmp/tapo_off.py'"
]

View File

@@ -23,7 +23,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar variables de entorno locales (.env de biblioteca_negocio_prolongo)
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def cerrar_ventanas():
@@ -90,7 +90,7 @@ p100.turnOff()"""
# Comando SSH en dos saltos: local -> VPS -> RPi
cmd = [
"ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
"ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
f"ssh -i /root/.ssh/pi_deploy -p 2222 -o StrictHostKeyChecking=no pi@127.0.0.1 'python3 -c \"{tapo_script}\"'"
]

View File

@@ -24,7 +24,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar variables de entorno locales (.env de biblioteca_negocio_prolongo)
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
# Permitir importar modulos del repo de negocio (ha_alexa).
@@ -78,7 +78,7 @@ p100.turnOff()"""
# Comando SSH en dos saltos: local -> VPS -> RPi
cmd = [
"ssh", "-i", r"C:\Users\juanm\Documents\GitHub\contabo",
"ssh", "-i", os.path.expanduser("~/Documents/GitHub/contabo"),
"root@185.187.169.109",
f"ssh -i /root/.ssh/pi_deploy -p 2222 -o StrictHostKeyChecking=no pi@127.0.0.1 'python3 -c \"{tapo_script}\"'"
]

View File

@@ -12,7 +12,7 @@ from flask import Flask, request, jsonify
from dotenv import load_dotenv
# Cargar .env
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
app = Flask(__name__)

View File

@@ -20,7 +20,7 @@ from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Application, CommandHandler, CallbackQueryHandler, ContextTypes
# Cargar .env
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
# Configuración

View File

@@ -17,7 +17,7 @@ if sys.platform == 'win32':
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer, 'strict')
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def enviar_comando_voz(echo_entity, comando):

View File

@@ -20,7 +20,7 @@ if sys.platform == 'win32':
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.buffer, 'strict')
# Cargar .env
dotenv_path = r"C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env"
dotenv_path = os.path.expanduser("~/Documents/GitHub/biblioteca_negocio_prolongo/.env")
load_dotenv(dotenv_path)
def main():