├── README.md └── install.sh /README.md: -------------------------------------------------------------------------------- 1 | # OnlyOffice-Unlimited 2 | Script generating a valid license for OnlyOffice DocumentServer 3 | 4 | # What is going on in this script 5 | ## Key generation 6 | At the beginning, the script will generate a RSA SHA1 key pair and generate a signature for the custom license file. 7 | After this step, it will append the signature as a key to the licence JSON dictionary and save it. 8 | We then also save the public key, which we will use in OO to verify our license. 9 | 10 | ## Patching 11 | OnlyOffice changed the way they ship their Docker images and are now using "compiled" binaries of NodeJS code. This script will search the binary file for OnlyOffice's PEM certificate and replace it with the one generated earlier. The script automatically starts OnlyOffice DocumentServer after the operation 12 | 13 | # How to use 14 | Change the entrypoint of your docker-compose file to : 15 | 16 | `entrypoint: bash -c "wget https://raw.githubusercontent.com/Zegorax/OnlyOffice-Unlimited/master/install.sh && bash install.sh"` 17 | 18 | # Conclusion 19 | You now have a working OnlyOffice license generator 20 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FILE=OO_PubKey 4 | if test -f "$FILE"; then 5 | echo Patch has already been applied. Starting DocumentServer... 6 | else 7 | apt-get update && apt-get install -y python3.6-dev 8 | wget https://bootstrap.pypa.io/get-pip.py 9 | python3.6 get-pip.py 10 | pip install pycrypto 11 | rm -f /var/www/onlyoffice/Data/license.lic 12 | 13 | cat < index.py 14 | from Crypto.Hash import SHA, SHA256 15 | from Crypto.Signature import PKCS1_v1_5 16 | from Crypto.PublicKey import RSA 17 | from shutil import copyfile 18 | import json 19 | import codecs 20 | 21 | hexlify = codecs.getencoder('hex') 22 | 23 | licenseFile = { 24 | "branding": False, 25 | "connections": 9999, 26 | "customization": False, 27 | "end_date": "2099-01-01T23:59:59.000Z", 28 | "light": "False", 29 | "mode": "", 30 | "portal_count": "0", 31 | "process": 2, 32 | "ssbranding": False, 33 | "test": "False", 34 | "trial": "False", 35 | "user_quota": "0", 36 | "users_count": 9999, 37 | "users_expire": 99999, 38 | "whiteLabel": False, 39 | "customer_id": "customerID", 40 | "start_date": "2020-01-01T00:00:00.000Z", 41 | "users": [], 42 | "version": 2 43 | } 44 | 45 | jsonLicenseFile = codecs.encode(json.dumps(licenseFile, separators=(',', ':')), encoding='utf-8') 46 | 47 | privKey = RSA.generate(1024) 48 | publKey = privKey.publickey().exportKey('PEM') 49 | 50 | digest = SHA.new(jsonLicenseFile) 51 | signer = PKCS1_v1_5.new(privKey) 52 | signature = signer.sign(digest) 53 | 54 | finalSignature = signature.hex() 55 | 56 | licenseFile['signature'] = finalSignature 57 | 58 | f = open("OO_License", "w+") 59 | f.write(json.dumps(licenseFile)) 60 | f.close 61 | 62 | f = open("OO_PubKey", "w+") 63 | f.write(publKey.decode('utf-8')) 64 | f.close() 65 | 66 | print("The license file has been saved to OO_License. Here's the content :") 67 | print(json.dumps(licenseFile)) 68 | print("It will be placed automatically in the Data directory of OnlyOffice") 69 | 70 | copyfile("OO_License", "/var/www/onlyoffice/Data/license.lic") 71 | 72 | print("Patching docservice and convert...") 73 | 74 | basePath = "/var/www/onlyoffice/documentserver/server/" 75 | files = ["DocService/docservice", "FileConverter/converter"] 76 | 77 | for file in files: 78 | f = open(basePath+file, 'rb') 79 | data = f.read() 80 | f.close() 81 | 82 | replacedData = data.replace(b"-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRhGF7X4A0ZVlEg594WmODVVUI\niiPQs04aLmvfg8SborHss5gQXu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicg\nXwi80H1aLPf6lEPPLvN29EhQNjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6\nPFQbP9/rByxdxEoAIQIDAQAB\n-----END PUBLIC KEY-----", bytes(publKey)) 83 | 84 | f = open(basePath+file, 'wb') 85 | f.write(replacedData) 86 | f.close() 87 | 88 | EOF 89 | 90 | python3.6 index.py 91 | 92 | echo Patching docservice and convert... 93 | 94 | echo Done! Running Document Server... 95 | fi 96 | 97 | /app/ds/run-document-server.sh 98 | --------------------------------------------------------------------------------