Skip to content
Snippets Groups Projects
Commit 0c767f4b authored by Jakub Pelka's avatar Jakub Pelka :cat2:
Browse files

Script

parents
No related branches found
No related tags found
No related merge requests found
libs/*
libs_dl/*
*.jar
\ No newline at end of file
import xml.etree.ElementTree as ET
from pathlib import Path
import urllib.request
import os
import shutil
import zipfile
print("#########")
print("Avocent Console Tool for Mac")
print("Drag and drop the .jnlp file:")
b = input("> ")
print("|" + b + "|")
if "\\" in b:
b = b.replace("\\", "")
if "'" in b:
file = b[1:-1]
else:
file = b
if file[-1] == " ":
file = file[:-1]
file_path = Path(file)
if not file_path.is_file():
print("File not found")
exit(1)
print("")
# Get arguments with credentials
arguments = []
libs = []
arguments_string = ""
tree = ET.parse(file)
root = tree.getroot()
for elem in root:
for subelem in elem:
if subelem.tag == "argument":
arguments.append(subelem.text)
if subelem.tag == "jar":
main_jar = subelem.attrib["href"]
if "os" in elem.attrib:
if elem.attrib["os"] == "Mac\ OS\ X":
for subelem in elem:
libs.append(subelem.attrib["href"])
print("Decoding arguments")
for argument in arguments:
arguments_string = arguments_string + argument + " "
# Get server domain/IP
server = root.attrib["codebase"]
print("Creating directories")
directories = ["libs", "libs_dl"]
for directory in directories:
if os.path.isdir(directory):
shutil.rmtree(directory)
os.mkdir(directory)
print('Beginning file download with {}...'.format(main_jar))
url = server + '/' + main_jar
urllib.request.urlretrieve(url, main_jar)
for lib in libs:
print('Beginning file download with {}...'.format(lib))
url = server + '/' + lib
urllib.request.urlretrieve(url, "libs_dl/" + lib)
with zipfile.ZipFile("libs_dl/" + lib,"r") as zip_ref:
zip_ref.extractall("libs")
print("Patching libraries")
with open("libs/libVMAPI_DLL.jnilib", 'rb') as f:
s=f.read()
f.close()
s=s.replace(b'/usr/lib/libssl.dylib',b'/tmp/libssl.1.1.dylib')
with open("libs/libVMAPI_DLL.jnilib", 'wb') as w:
w.write(s)
w.close()
print("Clearing attributes")
os.system("xattr -r -d com.apple.quarantine libs/*.jnilib")
print("Checking for OpenSSL install")
a = os.popen("brew info openssl@1.1").read()
if "Not installed\n" in a:
os.system("brew install openssl@1.1")
print("OpenSSL found, checking path")
b = os.popen("brew info openssl@1.1 | grep $(brew --cellar openssl@1.1)").read()
openssl_path = b.split("(")[0][:-1]
print("Symlinking OpenSSL libraries")
dylibs = ["libssl", "libcrypto"]
for dylib in dylibs:
if os.path.isfile("/tmp/{}.1.1.dylib".format(dylib)):
os.system("sudo rm /tmp/{}.1.1.dylib".format(dylib))
os.system("sudo ln -s {}/lib/{}.1.1.dylib /tmp/{}.1.1.dylib".format(openssl_path, dylib, dylib))
print("Launching!")
os.system("java -cp {} -Djava.library.path=./libs com.avocent.msd.kvm.Main {}".format(main_jar, arguments_string))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment