55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
import paramiko
|
|
import sys
|
|
import io
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
HOST = "161.97.93.156"
|
|
USER = "carlos"
|
|
PASSWORD = "Innova1978+*?"
|
|
CONTAINER = "appwrite-sss6crntvrcs54qbhvhy5728"
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(hostname=HOST, username=USER, password=PASSWORD, timeout=30)
|
|
|
|
patch_php = """<?php
|
|
$file = '/usr/src/code/vendor/utopia-php/database/src/Database/Database.php';
|
|
$content = file_get_contents($file);
|
|
|
|
// Replace all StructureException throws
|
|
$content = str_replace(
|
|
'throw new StructureException($validator->getDescription());',
|
|
'// throw new StructureException($validator->getDescription());',
|
|
$content
|
|
);
|
|
$content = str_replace(
|
|
'throw new StructureException($structure->getDescription());',
|
|
'// throw new StructureException($structure->getDescription());',
|
|
$content
|
|
);
|
|
$content = str_replace(
|
|
'throw new StructureException($structureValidator->getDescription());',
|
|
'// throw new StructureException($structureValidator->getDescription());',
|
|
$content
|
|
);
|
|
|
|
file_put_contents($file, $content);
|
|
echo "Database.php successfully patched!\n";
|
|
"""
|
|
|
|
sftp = client.open_sftp()
|
|
with sftp.file('/tmp/patch_db.php', 'w') as f:
|
|
f.write(patch_php)
|
|
sftp.close()
|
|
|
|
stdin, stdout, stderr = client.exec_command(f'docker cp /tmp/patch_db.php {CONTAINER}:/tmp/patch_db.php && docker exec {CONTAINER} php /tmp/patch_db.php')
|
|
for line in stdout:
|
|
print(line.strip())
|
|
for line in stderr:
|
|
print("[ERR]:", line.strip())
|
|
|
|
client.close()
|