mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 06:34:45 -04:00
Switched sqlite parameter to point to file instead of dir
This commit is contained in:
parent
5a8a21abda
commit
f15ed48f59
5 changed files with 14 additions and 18 deletions
|
@ -64,7 +64,7 @@ docker run -it -d --name py3-kms \
|
||||||
-v /etc/localtime:/etc/localtime:ro \
|
-v /etc/localtime:/etc/localtime:ro \
|
||||||
--restart unless-stopped ghcr.io/py-kms-organization/py-kms:[TAG]
|
--restart unless-stopped ghcr.io/py-kms-organization/py-kms:[TAG]
|
||||||
```
|
```
|
||||||
You can omit the `-e SQLITE=...` and `-p 8080:8080` option if you plan to use the `minimal` or `latest` image, which does not include the respective module support.
|
You can omit the `-p 8080:8080` option if you plan to use the `minimal` or `latest` image, which does not include the `sqlite` module support.
|
||||||
|
|
||||||
### Systemd
|
### Systemd
|
||||||
If you are running a Linux distro using `systemd`, create the file: `sudo nano /etc/systemd/system/py3-kms.service`, then add the following (change it where needed) and save:
|
If you are running a Linux distro using `systemd`, create the file: `sudo nano /etc/systemd/system/py3-kms.service`, then add the following (change it where needed) and save:
|
||||||
|
|
|
@ -53,7 +53,6 @@ e.g. because it could not reach the server. The default is 120 minutes (2 hours)
|
||||||
|
|
||||||
-s or --sqlite [<SQLFILE>]
|
-s or --sqlite [<SQLFILE>]
|
||||||
> Use this option to store request information from unique clients in an SQLite database. Deactivated by default.
|
> Use this option to store request information from unique clients in an SQLite database. Deactivated by default.
|
||||||
If enabled the default database file is _pykms_database.db_. You can also provide a specific location.
|
|
||||||
|
|
||||||
-t0 or --timeout-idle <TIMEOUTIDLE>
|
-t0 or --timeout-idle <TIMEOUTIDLE>
|
||||||
> Maximum inactivity time (in seconds) after which the connection with the client is closed.
|
> Maximum inactivity time (in seconds) after which the connection with the client is closed.
|
||||||
|
|
|
@ -4,13 +4,12 @@ import binascii
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
import socket
|
|
||||||
|
|
||||||
from pykms_Structure import Structure
|
from pykms_Structure import Structure
|
||||||
from pykms_DB2Dict import kmsDB2Dict
|
from pykms_DB2Dict import kmsDB2Dict
|
||||||
from pykms_PidGenerator import epidGenerator
|
from pykms_PidGenerator import epidGenerator
|
||||||
from pykms_Filetimes import filetime_to_dt
|
from pykms_Filetimes import filetime_to_dt
|
||||||
from pykms_Sql import sql_initialize, sql_update, sql_update_epid
|
from pykms_Sql import sql_update, sql_update_epid
|
||||||
from pykms_Format import justify, byterize, enco, deco, pretty_printer
|
from pykms_Format import justify, byterize, enco, deco, pretty_printer
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -214,7 +213,6 @@ could be detected as not genuine !{end}" %currentClientCount)
|
||||||
'product' : infoDict["skuId"]})
|
'product' : infoDict["skuId"]})
|
||||||
# Create database.
|
# Create database.
|
||||||
if self.srv_config['sqlite']:
|
if self.srv_config['sqlite']:
|
||||||
sql_initialize(self.srv_config['sqlite'])
|
|
||||||
sql_update(self.srv_config['sqlite'], infoDict)
|
sql_update(self.srv_config['sqlite'], infoDict)
|
||||||
|
|
||||||
return self.createKmsResponse(kmsRequest, currentClientCount, appName)
|
return self.createKmsResponse(kmsRequest, currentClientCount, appName)
|
||||||
|
|
|
@ -9,21 +9,20 @@ import uuid
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import pickle
|
|
||||||
import socketserver
|
import socketserver
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
import selectors
|
import selectors
|
||||||
from tempfile import gettempdir
|
|
||||||
from time import monotonic as time
|
from time import monotonic as time
|
||||||
|
|
||||||
import pykms_RpcBind, pykms_RpcRequest
|
import pykms_RpcBind, pykms_RpcRequest
|
||||||
from pykms_RpcBase import rpcBase
|
from pykms_RpcBase import rpcBase
|
||||||
from pykms_Dcerpc import MSRPCHeader
|
from pykms_Dcerpc import MSRPCHeader
|
||||||
from pykms_Misc import check_setup, check_lcid, check_dir, check_other
|
from pykms_Misc import check_setup, check_lcid, check_other
|
||||||
from pykms_Misc import KmsParser, KmsParserException, KmsParserHelp
|
from pykms_Misc import KmsParser, KmsParserException, KmsParserHelp
|
||||||
from pykms_Misc import kms_parser_get, kms_parser_check_optionals, kms_parser_check_positionals, kms_parser_check_connect
|
from pykms_Misc import kms_parser_get, kms_parser_check_optionals, kms_parser_check_positionals, kms_parser_check_connect
|
||||||
from pykms_Format import enco, deco, pretty_printer, justify
|
from pykms_Format import enco, deco, pretty_printer, justify
|
||||||
from pykms_Connect import MultipleListener
|
from pykms_Connect import MultipleListener
|
||||||
|
from pykms_Sql import sql_initialize
|
||||||
|
|
||||||
srv_version = "py-kms_2020-10-01"
|
srv_version = "py-kms_2020-10-01"
|
||||||
__license__ = "The Unlicense"
|
__license__ = "The Unlicense"
|
||||||
|
@ -190,8 +189,7 @@ for server OSes and Office >=5', 'def' : None, 'des' : "clientcount"},
|
||||||
'def' : 120, 'des': "activation"},
|
'def' : 120, 'des': "activation"},
|
||||||
'renewal' : {'help' : 'Use this option to specify the renewal interval (in minutes). Default is \"10080\" minutes (7 days).',
|
'renewal' : {'help' : 'Use this option to specify the renewal interval (in minutes). Default is \"10080\" minutes (7 days).',
|
||||||
'def' : 1440 * 7, 'des' : "renewal"},
|
'def' : 1440 * 7, 'des' : "renewal"},
|
||||||
'sql' : {'help' : 'Use this option to store request information from unique clients in an SQLite database. Deactivated by default. \
|
'sql' : {'help' : 'Use this option to store request information from unique clients in an SQLite database. Deactivated by default.', 'def' : False,
|
||||||
If enabled the default .db file is \"pykms_database.db\". You can also provide a specific location.', 'def' : False,
|
|
||||||
'file': os.path.join('.', 'pykms_database.db'), 'des' : "sqlite"},
|
'file': os.path.join('.', 'pykms_database.db'), 'des' : "sqlite"},
|
||||||
'hwid' : {'help' : 'Use this option to specify a HWID. The HWID must be an 16-character string of hex characters. \
|
'hwid' : {'help' : 'Use this option to specify a HWID. The HWID must be an 16-character string of hex characters. \
|
||||||
The default is \"364F463A8863D35F\" or type \"RANDOM\" to auto generate the HWID.',
|
The default is \"364F463A8863D35F\" or type \"RANDOM\" to auto generate the HWID.',
|
||||||
|
@ -364,16 +362,19 @@ def server_check():
|
||||||
|
|
||||||
# Check sqlite.
|
# Check sqlite.
|
||||||
if srv_config['sqlite']:
|
if srv_config['sqlite']:
|
||||||
if isinstance(srv_config['sqlite'], str):
|
if srv_config['sqlite'] is True: # Resolve bool to the default path
|
||||||
check_dir(srv_config['sqlite'], 'srv', log_obj = loggersrv.error, argument = '-s/--sqlite')
|
|
||||||
elif srv_config['sqlite'] is True:
|
|
||||||
srv_config['sqlite'] = srv_options['sql']['file']
|
srv_config['sqlite'] = srv_options['sql']['file']
|
||||||
|
if os.path.isdir(srv_config['sqlite']):
|
||||||
|
pretty_printer(log_obj = loggersrv.warning,
|
||||||
|
put_text = "{reverse}{yellow}{bold}You specified a folder instead of a database file! This behavior is not officially supported anymore, please change your start parameters soon.{end}")
|
||||||
|
srv_config['sqlite'] = os.path.join(srv_config['sqlite'], 'pykms_database.db')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
sql_initialize(srv_config['sqlite'])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pretty_printer(log_obj = loggersrv.warning,
|
pretty_printer(log_obj = loggersrv.warning,
|
||||||
put_text = "{reverse}{yellow}{bold}Module 'sqlite3' not installed, database support disabled.{end}")
|
put_text = "{reverse}{yellow}{bold}Module 'sqlite3' not installed, database support disabled.{end}")
|
||||||
srv_config['sqlite'] = False
|
srv_config['sqlite'] = False
|
||||||
|
|
||||||
# Check other specific server options.
|
# Check other specific server options.
|
||||||
|
|
|
@ -23,12 +23,10 @@ def sql_initialize(dbName):
|
||||||
try:
|
try:
|
||||||
con = sqlite3.connect(dbName)
|
con = sqlite3.connect(dbName)
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
cur.execute("CREATE TABLE clients(clientMachineId TEXT, machineName TEXT, applicationId TEXT, skuId TEXT, \
|
cur.execute("CREATE TABLE clients(clientMachineId TEXT, machineName TEXT, applicationId TEXT, skuId TEXT, licenseStatus TEXT, lastRequestTime INTEGER, kmsEpid TEXT, requestCount INTEGER)")
|
||||||
licenseStatus TEXT, lastRequestTime INTEGER, kmsEpid TEXT, requestCount INTEGER)")
|
|
||||||
|
|
||||||
except sqlite3.Error as e:
|
except sqlite3.Error as e:
|
||||||
pretty_printer(log_obj = loggersrv.error, to_exit = True,
|
pretty_printer(log_obj = loggersrv.error, to_exit = True, put_text = "{reverse}{red}{bold}Sqlite Error: %s. Exiting...{end}" %str(e))
|
||||||
put_text = "{reverse}{red}{bold}Sqlite Error: %s. Exiting...{end}" %str(e))
|
|
||||||
finally:
|
finally:
|
||||||
if con:
|
if con:
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue