|
@@ -1,7 +1,6 @@
|
|
|
import os
|
|
import os
|
|
|
import shutil
|
|
import shutil
|
|
|
import subprocess
|
|
import subprocess
|
|
|
-import tempfile
|
|
|
|
|
|
|
|
|
|
import requests
|
|
import requests
|
|
|
from dotenv import load_dotenv
|
|
from dotenv import load_dotenv
|
|
@@ -22,27 +21,21 @@ def updateSquidStats():
|
|
|
if proxy_url:
|
|
if proxy_url:
|
|
|
proxies = {"http": proxy_url, "https": proxy_url}
|
|
proxies = {"http": proxy_url, "https": proxy_url}
|
|
|
try:
|
|
try:
|
|
|
- with tempfile.NamedTemporaryFile(
|
|
|
|
|
- delete=False, mode="w+b", suffix=".sh"
|
|
|
|
|
- ) as tmp_script:
|
|
|
|
|
- tmp_script_path = tmp_script.name
|
|
|
|
|
- response = requests.get(
|
|
|
|
|
- "https://github.com/kaelthasmanu/SquidStats/releases/download/2.3.1/install.sh",
|
|
|
|
|
- proxies=proxies,
|
|
|
|
|
- timeout=30,
|
|
|
|
|
- )
|
|
|
|
|
- response.raise_for_status()
|
|
|
|
|
- tmp_script.write(response.content)
|
|
|
|
|
- subprocess.run([shutil.which("chmod") or "chmod", "+x", tmp_script_path]) # noqa: S603
|
|
|
|
|
- subprocess.run(
|
|
|
|
|
- [shutil.which("bash") or "bash", tmp_script_path, "--update"], env=env
|
|
|
|
|
- ) # noqa: S603
|
|
|
|
|
- os.unlink(tmp_script_path)
|
|
|
|
|
|
|
+ response = requests.get(
|
|
|
|
|
+ "https://github.com/kaelthasmanu/SquidStats/releases/download/2.3.1/install.sh",
|
|
|
|
|
+ proxies=proxies,
|
|
|
|
|
+ timeout=30,
|
|
|
|
|
+ )
|
|
|
|
|
+ response.raise_for_status()
|
|
|
|
|
+ sh_bin = "/bin/sh" if os.path.exists("/bin/sh") else shutil.which("sh")
|
|
|
|
|
+ if not sh_bin:
|
|
|
|
|
+ logger.error("sh no encontrado en el sistema")
|
|
|
|
|
+ return False
|
|
|
|
|
+ args = [sh_bin, "-s", "--update"]
|
|
|
|
|
+ subprocess.run(args, input=response.content, env=env, check=True) # noqa: S603
|
|
|
return True
|
|
return True
|
|
|
except Exception:
|
|
except Exception:
|
|
|
logger.exception("Error descargando el script de actualización")
|
|
logger.exception("Error descargando el script de actualización")
|
|
|
- if "tmp_script_path" in locals() and os.path.exists(tmp_script_path):
|
|
|
|
|
- os.unlink(tmp_script_path)
|
|
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
except Exception:
|
|
except Exception:
|