mirror of
https://github.com/riptidewave93/UNVR-NAS.git
synced 2025-02-15 03:51:54 +00:00
* Write a mock ustorage tool to parse disk info for ulcmd * Pass system temp info from unvr-fan-daemon to mock-ubnt-api via tmp file * add mock ubnt-tools to make ulcmd happy and report our SN * code cleanup and documentation update
48 lines
1,015 B
Python
Executable file
48 lines
1,015 B
Python
Executable file
#!/usr/bin/python3
|
|
import os
|
|
|
|
from flask import Flask, jsonify
|
|
from functools import lru_cache
|
|
import socket
|
|
|
|
|
|
def __get_system_temp():
|
|
try:
|
|
with open("/tmp/.unvr_temp", "r") as f:
|
|
return float(f.read())
|
|
except (IOError, OSError, PermissionError) as e:
|
|
print(f"Warning: Unable to get device temp!")
|
|
return None
|
|
|
|
|
|
@lru_cache(None)
|
|
def __get_omv_version():
|
|
return os.popen("dpkg-query -W -f='${Version}' openmediavault").read()
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/api/info")
|
|
def api_info():
|
|
payload = {
|
|
"isSetup": True,
|
|
"hostname": socket.gethostname(),
|
|
"hardware": {
|
|
"firmwareVersion": f"OMV {__get_omv_version()}", # OMV version
|
|
},
|
|
"cpu": {
|
|
"temperature": __get_system_temp(),
|
|
},
|
|
}
|
|
return jsonify(payload)
|
|
|
|
|
|
# No controllers for you
|
|
@app.route("/api/controllers")
|
|
def api_controllers():
|
|
return jsonify([])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=11081)
|