onedrive update

This commit is contained in:
kadma
2025-03-16 16:10:08 -05:00
committed by GitHub
parent 730ae6124a
commit 867fdd776c
13 changed files with 98 additions and 91 deletions

View File

@@ -1,21 +1,10 @@
FROM ubuntu FROM python:3.9-slim
WORKDIR /app WORKDIR /app
RUN apt update && apt upgrade -y && apt autoremove -y && apt install python3 python3-pip -y && apt install git nano wget curl -y COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install schedule COPY script.py .
COPY . . CMD ["python", "script.py"]
ENV IP_PING="http://127.0.0.1:8080/call"
ENV TOKEN="token"
ENV PASSWORD_WEB="pass"
ENV SUPERCOMANDO='curl -X POST -H "Content-Type: application/json" -d '{"password": "$PASSWORD_WEB" ,"refresh_token": "$TOKEN"}' "$IP_PING"'
RUN chmod +x run.sh
ENTRYPOINT ./run.sh

View File

@@ -1,6 +1,3 @@
## actualmente da error ## Actualizado, puede contener errores
#### manual
```sh
apt update && apt install wget -y && bash -c "$(wget -qLO - https://raw.githubusercontent.com/kadma/pruebasdocker/main/onedrive/cron/script.sh)"
```

View File

@@ -1,21 +0,0 @@
import os
import schedule
import time
import subprocess
def ejecutar_comando():
comando = os.environ.get('SUPERCOMANDO', default=None)
if comando is not None:
subprocess.run(comando, shell=True)
else:
print("La variable de entorno no tiene un valor definido.")
schedule.every(1).minutes.do(ejecutar_comando)
while True:
# Ejecuta las tareas pendientes
schedule.run_pending()
# Espera 1 segundo antes de volver a verificar
time.sleep(1)

View File

@@ -1,21 +0,0 @@
import os
import schedule
import time
import subprocess
def ejecutar_comando():
comando = os.environ.get('SUPERCOMANDO', default=None)
if comando is not None:
subprocess.run(comando, shell=True)
else:
print("La variable de entorno no tiene un valor definido.")
schedule.every(7).hours.do(ejecutar_comando)
while True:
# Ejecuta las tareas pendientes
schedule.run_pending()
# Espera 1 segundo antes de volver a verificar
time.sleep(1)

View File

@@ -0,0 +1,12 @@
---
services:
odcron:
build: .
container_name: odcron
environment:
- IP=host:8080 # Cambia esto por la IP y puerto deseado
- PASSWORD=pass # Cambia esto por la contraseña deseada
- REFRESH_TOKEN=tokenit # Cambia esto por el token deseado
restart: unless-stopped
hostname: odcron
network_mode: bridge

View File

@@ -0,0 +1,2 @@
requests
schedule

View File

@@ -1 +0,0 @@
python3 cron7h.py

View File

@@ -1,4 +1,46 @@
apt update && apt upgrade -y && apt autoremove -y && apt install python3 python3-pip -y && apt install git nano curl -y import requests
pip3 install schedule import schedule
wget -b -P /app/ https://raw.githubusercontent.com/kadma/pruebasdocker/main/onedrive/cron/cron1m.py import time
wget -b -P /app/ https://raw.githubusercontent.com/kadma/pruebasdocker/main/onedrive/cron/cron7h.py import logging
import os
# Configuración del logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# Leer variables de entorno
IP = os.getenv("IP", "127.0.0.0:8080") # IP y puerto por defecto
PASSWORD = os.getenv("PASSWORD", "pass") # Password por defecto
REFRESH_TOKEN = os.getenv("REFRESH_TOKEN", "tokenit") # Token por defecto
# Construir la URL correctamente
URL = f"http://{IP}/call" # Incluye el protocolo y la ruta
HEADERS = {"Content-Type": "application/json"}
DATA = {"password": PASSWORD, "refresh_token": REFRESH_TOKEN}
def perform_curl():
try:
# Realiza la solicitud POST
response = requests.post(URL, headers=HEADERS, json=DATA)
response.raise_for_status() # Lanza una excepción si la respuesta no es exitosa
logging.info(f"Success: {response.status_code} - {response.text[:100]}...") # Muestra solo los primeros 100 caracteres
except requests.exceptions.RequestException as e:
logging.error(f"Error: {e}")
def initial_test():
logging.info("Running initial test...")
perform_curl()
def main():
# Ejecuta la prueba inicial
initial_test()
# Programa la ejecución cada minuto
schedule.every(1).minutes.do(perform_curl)
# Bucle para mantener el script en ejecución
while True:
schedule.run_pending()
time.sleep(1)
if __name__ == "__main__":
main()

View File

@@ -1,25 +1,26 @@
FROM ubuntu # Usar una imagen base más ligera y específica
FROM python:3.9-slim
# Establecer el directorio de trabajo
WORKDIR /app WORKDIR /app
RUN apt update && apt upgrade -y && apt autoremove -y && apt install python3 python3-pip -y && apt install git nano wget -y # Instalar dependencias del sistema y limpiar caché en un solo RUN
RUN apt-get update && \
apt-get install -y --no-install-recommends git wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Clonar el repositorio
RUN git clone https://github.com/TheCaduceus/Microsoft-E5-Auto-Renewal /app RUN git clone https://github.com/TheCaduceus/Microsoft-E5-Auto-Renewal /app
RUN pip install -r requirements.txt # Instalar dependencias de Python
RUN pip install --no-cache-dir -r requirements.txt
# Copiar el resto de los archivos
COPY . . COPY . .
ENV E5_CLIENT_ID="id" # Exponer el puerto
ENV E5_CLIENT_SECRET="secret"
ENV E5_REFRESH_TOKEN="token"
ENV WEB_APP_PASSWORD="pass"
EXPOSE 8080 EXPOSE 8080
RUN chmod +x run.sh # Establecer el comando de entrada
CMD ["python", "main.py"]
ENTRYPOINT ./run.sh

View File

@@ -1,6 +1,2 @@
## sin actualizar ## sin actualizar
#### manual
```sh
apt update && apt install wget -y && bash -c "$(wget -qLO - https://raw.githubusercontent.com/kadma/pruebasdocker/main/onedrive/engine/script.sh)"
```

View File

@@ -0,0 +1,16 @@
---
services:
odengin:
build: .
container_name: odengin
environment:
- E5_CLIENT_ID=id
- E5_CLIENT_SECRET=secret
- E5_REFRESH_TOKEN=tokenit
- WEB_APP_PASSWORD=123
- E5_WEB_APP_PASSWORD=123
ports:
- 8089:8080
restart: unless-stopped
hostname: odengin
network_mode: bridge

View File

@@ -1 +0,0 @@
python3 main.py

View File

@@ -1,4 +0,0 @@
apt update && apt upgrade -y && apt autoremove -y && apt install python3 python3-pip -y && apt install git nano curl -y
git clone https://github.com/TheCaduceus/Microsoft-E5-Auto-Renewal /app
pip3 install -r /app/requirements.txt
python3 /app/main.py