41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import paramiko
|
|
import sys
|
|
import json
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.71", username="root", key_filename=key_path, timeout=10)
|
|
|
|
def run(cmd):
|
|
stdin, stdout, stderr = c.exec_command(cmd)
|
|
return stdout.read().decode('utf-8', errors='ignore').strip()
|
|
|
|
# Fix MSSQL version in config
|
|
with open("c:/Users/Snarf/OneDrive/Desktop/code/SnarfCode/scripts/deploy_opencanary.py", "r") as f:
|
|
text = f.read()
|
|
|
|
# Read config from host, update mssql.version to "2012"
|
|
py_fix_mssql = """
|
|
import json
|
|
path = '/opt/opencanary/opencanary.conf'
|
|
with open(path, 'r') as f:
|
|
cfg = json.load(f)
|
|
cfg['mssql.version'] = '2012'
|
|
with open(path, 'w') as f:
|
|
json.dump(cfg, f, indent=4)
|
|
print('Updated mssql.version to 2012')
|
|
"""
|
|
c.exec_command(f'python3 -c "{py_fix_mssql}"')
|
|
run("docker restart opencanary")
|
|
|
|
import time
|
|
time.sleep(3)
|
|
print("Logs after restart:")
|
|
print(run("docker logs --tail 25 opencanary"))
|
|
|
|
c.close()
|
|
|